From 27fc0b84d68464158bd80b3253dbd91434c4212b Mon Sep 17 00:00:00 2001 From: Hentry Martin Date: Thu, 31 Jul 2025 22:09:08 +0200 Subject: [PATCH] fix: show error when invite comes from an closed opportunity --- src/containers/ProjectInvitations/index.js | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/containers/ProjectInvitations/index.js b/src/containers/ProjectInvitations/index.js index 58e6f20d..fc9c4e49 100644 --- a/src/containers/ProjectInvitations/index.js +++ b/src/containers/ProjectInvitations/index.js @@ -46,16 +46,22 @@ const ProjectInvitations = ({ match, auth, isProjectLoading, history, projectDet const updateInvite = useCallback(async (status, source) => { setIsUpdating(status) - await updateProjectMemberInvite(projectId, invitation.id, status, source) - - // await for the project details to propagate - await delay(1000) - await loadProjectInvites(projectId) - toastr.success('Success', `Successfully ${status} the invitation.`) - - // await for the project details to fetch - await delay(1000) - history.push(status === PROJECT_MEMBER_INVITE_STATUS_ACCEPTED ? `/projects/${projectId}/challenges` : '/projects') + try { + await updateProjectMemberInvite(projectId, invitation.id, status, source) + + // await for the project details to propagate + await delay(1000) + await loadProjectInvites(projectId) + toastr.success('Success', `Successfully ${status} the invitation.`) + + // await for the project details to fetch + await delay(1000) + history.push(status === PROJECT_MEMBER_INVITE_STATUS_ACCEPTED ? `/projects/${projectId}/challenges` : '/projects') + } catch (e) { + toastr.error('Error', e.response.data.message) + await delay(1000) + history.push('/projects') + } }, [projectId, invitation, loadProjectInvites, history]) const acceptInvite = useCallback(() => updateInvite(PROJECT_MEMBER_INVITE_STATUS_ACCEPTED, source), [updateInvite, source])