Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Resend invite fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vdavid committed Jun 19, 2024
1 parent f275393 commit 65b09e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/web/src/cody/management/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export module Client {
return { method: 'POST', urlSuffix: '/team/current/invites', requestBody }
}

export function resendInvite(inviteId: string): Call<Response> {
export function resendInvite(inviteId: string): Call<unknown> {
return { method: 'POST', urlSuffix: `/team/current/invites/${inviteId}/resend` }
}

Expand Down
4 changes: 2 additions & 2 deletions client/web/src/cody/management/api/react-query/invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export const useSendInvite = (): UseMutationResult<TeamInvite, Error, CreateTeam
})
}

export const useResendInvite = (): UseMutationResult<Response, Error, { inviteId: string }> => {
export const useResendInvite = (): UseMutationResult<unknown, Error, { inviteId: string }> => {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({ inviteId }) => callCodyProApi(Client.resendInvite(inviteId)),
mutationFn: async ({ inviteId }) => (await callCodyProApi(Client.resendInvite(inviteId))).json(),
onSuccess: () => queryClient.invalidateQueries({ queryKey: queryKeys.invites.teamInvites() }),
})
}
Expand Down
12 changes: 6 additions & 6 deletions client/web/src/cody/team/TeamMemberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ export const TeamMemberList: FunctionComponent<TeamMemberListProps> = ({
setLoading(true)
telemetryRecorder.recordEvent('cody.team.resendInvite', 'click', { privateMetadata: { teamId } })

const response = await resendInviteMutation.mutateAsync.call(undefined, { inviteId })
if (!response.ok) {
try {
await resendInviteMutation.mutateAsync.call(undefined, { inviteId })
setLoading(false)
setActionResult({ message: 'Invite resent.', isError: false })
} catch (error) {
setLoading(false)
setActionResult({
message: `We couldn't resend the invite (${response.status}). Please try again later.`,
message: `We couldn't resend the invite (${error}). Please try again later.`,
isError: true,
})
} else {
setLoading(false)
setActionResult({ message: 'Invite resent.', isError: false })
}
}

Expand Down

0 comments on commit 65b09e8

Please sign in to comment.