Skip to content

Commit

Permalink
Update AddMembers.tsx
Browse files Browse the repository at this point in the history
fix the bugs in location --> impress/src/frontend/apps/impress/src/features/docs/members/members-add/components/AddMembers.tsx
  • Loading branch information
aniruddhaadak80 committed Oct 22, 2024
1 parent 0f0f812 commit 0af2765
Showing 1 changed file with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,28 @@ export const AddMembers = ({ currentRole, doc }: ModalAddMembersProps) => {
})
: t(`Failed to add the member in the document.`);

if (
dataError.cause?.[0] ===
'Document invitation with this Email address and Document already exists.'
) {
messageError = t('"{{email}}" is already invited to the document.', {
email: dataError['data']?.value,
});
const onError = (dataError: APIErrorUser) => {
const email = dataError['data']?.value;
const statusCode = dataError.status; // Assuming `status` is available
let messageError = t('An error occurred.');

if (statusCode === 400) { // Bad Request
messageError = email
? t(`Failed to create the invitation for {{email}}.`, { email })
: t('Failed to add the member in the document.');
} else if (statusCode === 409) { // Conflict
if (dataError.cause?.some(cause => cause.includes('invitation') && cause.includes(email))) {
messageError = t('"{{email}}" is already invited to the document.', { email });
} else if (dataError.cause?.some(cause => cause.includes('associated to a registered user') && cause.includes(email))) {
messageError = t('"{{email}}" is already a member of the document.', { email });
}
} else {
messageError = t('An unexpected error occurred. Please try again.');
}

if (
dataError.cause?.[0] ===
'This email is already associated to a registered user.'
) {
messageError = t('"{{email}}" is already member of the document.', {
email: dataError['data']?.value,
});
}
toast(messageError, VariantType.ERROR, toastOptions);
};


toast(messageError, VariantType.ERROR, toastOptions);
};
Expand Down

0 comments on commit 0af2765

Please sign in to comment.