From 2d35a5c650149addaee8db2273f6366a6245c567 Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Mon, 26 Jan 2026 16:49:44 +0545 Subject: [PATCH 1/6] feat(user/invitation): update error handling --- .../components/Invitation/InvitationForm.tsx | 90 +++++++++++++++---- packages/user/src/locales/en/errors.json | 10 ++- packages/user/src/locales/fr/errors.json | 8 +- 3 files changed, 88 insertions(+), 20 deletions(-) diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index eaf6b9a1c..cd36ee79f 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -26,7 +26,7 @@ interface Properties { apps?: InvitationAppOption[]; expiryDateField?: InvitationExpiryDateField; onCancel?: () => void; - onSubmitted?: (response: AddInvitationResponse) => void; // afterSubmit + onSubmitted?: (response: AddInvitationResponse) => void; // eslint-disable-next-line @typescript-eslint/no-explicit-any prepareData?: (rawFormData: any) => any; roles?: InvitationRoleOption[]; @@ -42,11 +42,17 @@ export const InvitationForm = ({ roles, }: Properties) => { const { t, i18n } = useTranslation("invitations"); - const config = useConfig(); const [submitting, setSubmitting] = useState(false); - const [error, setError] = useState(false); + + // Stores the error code string (e.g. "USER_ALREADY_EXISTS_ERROR") + const [error, setError] = useState(null); + + // Stores dynamic values (email, role, app name) for the translation + const [errorParameters, setErrorParameters] = useState< + Record + >({}); const getDefaultValues = useCallback(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -56,7 +62,6 @@ export const InvitationForm = ({ if (apps?.length === 1) { const app = apps[0]; - defaultValues.app = app; filteredRoles = app.supportedRoles; } @@ -107,27 +112,78 @@ export const InvitationForm = ({ return parsedData; }; + const getErrorMessage = useCallback(() => { + switch (error) { + case "INVALID_EMAIL_ERROR": + return t("messages.invite.errors.INVALID_EMAIL_ERROR", errorParameters); + + case "INVITATION_ALREADY_EXISTS_ERROR": + return t( + "messages.invite.errors.INVITATION_ALREADY_EXISTS_ERROR", + errorParameters, + ); + + case "INVITATION_NOT_FOUND_ERROR": + return t( + "messages.invite.errors.INVITATION_NOT_FOUND_ERROR", + errorParameters, + ); + + case "ROLE_NOT_FOUND_ERROR": + return t( + "messages.invite.errors.ROLE_NOT_FOUND_ERROR", + errorParameters, + ); + + case "ROLE_NOT_SUPPORTED_ERROR": + return t( + "messages.invite.errors.ROLE_NOT_SUPPORTED_ERROR", + errorParameters, + ); + + case "USER_ALREADY_EXISTS_ERROR": + return t( + "messages.invite.errors.USER_ALREADY_EXISTS_ERROR", + errorParameters, + ); + + case "SOMETHING_WRONG": + case "GENERIC_ERROR": + default: + return t("messages.invite.errors.SOMETHING_WRONG"); + } + }, [error, errorParameters, t]); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const onSubmit = (data: any) => { setSubmitting(true); + setError(null); + setErrorParameters({}); const invitationData = prepareData ? prepareData(data) : getFormData(data); + const selectedApp = apps?.find((app) => app.id === data.app); + const parameters: Record = { + email: data.email, + role: data.role, + app: selectedApp ? selectedApp.name : data.app, + }; + addInvitation(invitationData, config.apiBaseUrl) .then((response) => { - if ("data" in response && response.data.status === "ERROR") { - // TODO better handle errors - setError(true); - } else { - toast.success(t("messages.invite.success")); - - if (onSubmitted) { - onSubmitted(response); - } + // Success case + toast.success(t("messages.invite.success")); + + if (onSubmitted) { + onSubmitted(response); } }) - .catch(() => { - setError(true); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + .catch((err: any) => { + const code = err?.response?.data?.code; + + setErrorParameters(parameters); + setError(code || "SOMETHING_WRONG"); }) .finally(() => { setSubmitting(false); @@ -180,9 +236,9 @@ export const InvitationForm = ({ <> {error && ( { - setError(false); + setError(null); }} severity="danger" /> diff --git a/packages/user/src/locales/en/errors.json b/packages/user/src/locales/en/errors.json index b3965bae6..afa19d1d8 100644 --- a/packages/user/src/locales/en/errors.json +++ b/packages/user/src/locales/en/errors.json @@ -2,7 +2,13 @@ "errors": { "401": "Invalid credentials. Please check your email or password and try again.", "emailAlreadyExists": "This email already exists. Please sign in instead.", - "incorrectPassword": "The current password you entered is incorrect.", - "otherErrors": "Oops! Something went wrong." + "incorrectPassword": "The current password you entered is incorrect", + "otherErrors": "Oops! Something went wrong.", + "INVALID_EMAIL_ERROR": "The provided email is invalid.", + "INVITATION_ALREADY_EXISTS_ERROR": "Invitation already exists for this email.", + "ROLE_NOT_FOUND_ERROR": "Role {role} does not exist", + "ROLE_NOT_SUPPORTED_ERROR": "App {app} does not support role USER.", + "SOMETHING_WRONG": "Something went wrong. Please try again.", + "USER_ALREADY_EXISTS_ERROR": "User with email {email} already exists" } } diff --git a/packages/user/src/locales/fr/errors.json b/packages/user/src/locales/fr/errors.json index c8cf561fa..03583b2cd 100644 --- a/packages/user/src/locales/fr/errors.json +++ b/packages/user/src/locales/fr/errors.json @@ -3,6 +3,12 @@ "401": "Invalid credentials. Please check your email or password and try again. (fr)", "emailAlreadyExists": "This email already exists. Please sign in instead. (fr)", "incorrectPassword": "The current password you entered is incorrect. (fr)", - "otherErrors": "Oops! Something went wrong (fr)." + "otherErrors": "Oops! Something went wrong (fr).", + "INVALID_EMAIL_ERROR": "The provided email is invalid. (fr)", + "INVITATION_ALREADY_EXISTS_ERROR": "Invitation already exists for this email. (fr)", + "ROLE_NOT_FOUND_ERROR": "Role {role} does not exist. (fr)", + "ROLE_NOT_SUPPORTED_ERROR": "App {app} does not support role USER. (fr)", + "SOMETHING_WRONG": "Something went wrong. Please try again. (fr)", + "USER_ALREADY_EXISTS_ERROR": "User with email {email} already exists. (fr)" } } From 6c4ae156079c7553408590f6c328d30db06f98f0 Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Tue, 27 Jan 2026 13:14:00 +0545 Subject: [PATCH 2/6] fix(user/invitation): maintain naming consistency over json file --- .../components/Invitation/InvitationForm.tsx | 26 +++++-------------- packages/user/src/locales/en/errors.json | 12 ++++----- packages/user/src/locales/fr/errors.json | 12 ++++----- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index cd36ee79f..2043ef7c8 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -115,42 +115,30 @@ export const InvitationForm = ({ const getErrorMessage = useCallback(() => { switch (error) { case "INVALID_EMAIL_ERROR": - return t("messages.invite.errors.INVALID_EMAIL_ERROR", errorParameters); + return t("messages.invite.errors.invalidEmail", errorParameters); case "INVITATION_ALREADY_EXISTS_ERROR": return t( - "messages.invite.errors.INVITATION_ALREADY_EXISTS_ERROR", + "messages.invite.errors.invitationAlreadyExists", errorParameters, ); case "INVITATION_NOT_FOUND_ERROR": - return t( - "messages.invite.errors.INVITATION_NOT_FOUND_ERROR", - errorParameters, - ); + return t("messages.invite.errors.invitationNotFound", errorParameters); case "ROLE_NOT_FOUND_ERROR": - return t( - "messages.invite.errors.ROLE_NOT_FOUND_ERROR", - errorParameters, - ); + return t("messages.invite.errors.roleNotFound", errorParameters); case "ROLE_NOT_SUPPORTED_ERROR": - return t( - "messages.invite.errors.ROLE_NOT_SUPPORTED_ERROR", - errorParameters, - ); + return t("messages.invite.errors.roleNotSupported", errorParameters); case "USER_ALREADY_EXISTS_ERROR": - return t( - "messages.invite.errors.USER_ALREADY_EXISTS_ERROR", - errorParameters, - ); + return t("messages.invite.errors.userAlreadyExists", errorParameters); case "SOMETHING_WRONG": case "GENERIC_ERROR": default: - return t("messages.invite.errors.SOMETHING_WRONG"); + return t("messages.invite.errors.somethingWrong"); } }, [error, errorParameters, t]); diff --git a/packages/user/src/locales/en/errors.json b/packages/user/src/locales/en/errors.json index afa19d1d8..d19d6f4c4 100644 --- a/packages/user/src/locales/en/errors.json +++ b/packages/user/src/locales/en/errors.json @@ -4,11 +4,11 @@ "emailAlreadyExists": "This email already exists. Please sign in instead.", "incorrectPassword": "The current password you entered is incorrect", "otherErrors": "Oops! Something went wrong.", - "INVALID_EMAIL_ERROR": "The provided email is invalid.", - "INVITATION_ALREADY_EXISTS_ERROR": "Invitation already exists for this email.", - "ROLE_NOT_FOUND_ERROR": "Role {role} does not exist", - "ROLE_NOT_SUPPORTED_ERROR": "App {app} does not support role USER.", - "SOMETHING_WRONG": "Something went wrong. Please try again.", - "USER_ALREADY_EXISTS_ERROR": "User with email {email} already exists" + "invalidEmail": "The provided email is invalid.", + "invitationAlreadyExists": "Invitation already exists for this email.", + "roleNotFound": "Role {role} does not exist", + "roleNotSupported": "App {app} does not support role USER.", + "somethingWrong": "Something went wrong. Please try again.", + "userAlreadyExists": "User with email {email} already exists" } } diff --git a/packages/user/src/locales/fr/errors.json b/packages/user/src/locales/fr/errors.json index 03583b2cd..08b335022 100644 --- a/packages/user/src/locales/fr/errors.json +++ b/packages/user/src/locales/fr/errors.json @@ -4,11 +4,11 @@ "emailAlreadyExists": "This email already exists. Please sign in instead. (fr)", "incorrectPassword": "The current password you entered is incorrect. (fr)", "otherErrors": "Oops! Something went wrong (fr).", - "INVALID_EMAIL_ERROR": "The provided email is invalid. (fr)", - "INVITATION_ALREADY_EXISTS_ERROR": "Invitation already exists for this email. (fr)", - "ROLE_NOT_FOUND_ERROR": "Role {role} does not exist. (fr)", - "ROLE_NOT_SUPPORTED_ERROR": "App {app} does not support role USER. (fr)", - "SOMETHING_WRONG": "Something went wrong. Please try again. (fr)", - "USER_ALREADY_EXISTS_ERROR": "User with email {email} already exists. (fr)" + "invalidEmail": "The provided email is invalid. (fr)", + "invitationAlreadyExists": "Invitation already exists for this email. (fr)", + "roleNotFound": "Role {role} does not exist. (fr)", + "roleNotSupported": "App {app} does not support role USER. (fr)", + "somethingWrong": "Something went wrong. Please try again. (fr)", + "userAlreadyExists": "User with email {email} already exists. (fr)" } } From 4dabf09456c4f6e38b3e71567c3182fca8d919fa Mon Sep 17 00:00:00 2001 From: kabin thakuri Date: Thu, 12 Feb 2026 18:18:58 +0545 Subject: [PATCH 3/6] refactor(user/invitation): update error handling logic --- .../components/Invitation/InvitationForm.tsx | 60 +++++++++---------- packages/user/src/constants.ts | 10 ++++ packages/user/src/locales/en/errors.json | 4 +- packages/user/src/locales/fr/errors.json | 4 +- 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index 2043ef7c8..f51e45400 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -10,6 +10,7 @@ import { toast } from "react-toastify"; import * as zod from "zod"; import { addInvitation } from "@/api/invitation"; +import { INVITATION_ERROR, SOMETHING_WRONG_ERROR } from "@/constants"; import { useConfig } from "@/hooks"; import { InvitationFormFields } from "./InvitationFormFields"; @@ -114,29 +115,29 @@ export const InvitationForm = ({ const getErrorMessage = useCallback(() => { switch (error) { - case "INVALID_EMAIL_ERROR": - return t("messages.invite.errors.invalidEmail", errorParameters); + case INVITATION_ERROR.INVALID_EMAIL: + return t("messages.invite.errors.invalidEmail", { + email: errorParameters?.email, + }); - case "INVITATION_ALREADY_EXISTS_ERROR": - return t( - "messages.invite.errors.invitationAlreadyExists", - errorParameters, - ); + case INVITATION_ERROR.INVITATION_ALREADY_EXISTS: + return t("messages.invite.errors.invitationAlreadyExists"); - case "INVITATION_NOT_FOUND_ERROR": - return t("messages.invite.errors.invitationNotFound", errorParameters); + case INVITATION_ERROR.ROLE_NOT_FOUND: + return t("messages.invite.errors.roleNotFound", { + role: errorParameters?.role, + }); - case "ROLE_NOT_FOUND_ERROR": - return t("messages.invite.errors.roleNotFound", errorParameters); + case INVITATION_ERROR.ROLE_NOT_SUPPORTED: + return t("messages.invite.errors.roleNotSupported", { + app: errorParameters?.app, + }); - case "ROLE_NOT_SUPPORTED_ERROR": - return t("messages.invite.errors.roleNotSupported", errorParameters); + case INVITATION_ERROR.USER_ALREADY_EXISTS: + return t("messages.invite.errors.userAlreadyExists", { + email: errorParameters?.email, + }); - case "USER_ALREADY_EXISTS_ERROR": - return t("messages.invite.errors.userAlreadyExists", errorParameters); - - case "SOMETHING_WRONG": - case "GENERIC_ERROR": default: return t("messages.invite.errors.somethingWrong"); } @@ -146,17 +147,9 @@ export const InvitationForm = ({ const onSubmit = (data: any) => { setSubmitting(true); setError(null); - setErrorParameters({}); const invitationData = prepareData ? prepareData(data) : getFormData(data); - const selectedApp = apps?.find((app) => app.id === data.app); - const parameters: Record = { - email: data.email, - role: data.role, - app: selectedApp ? selectedApp.name : data.app, - }; - addInvitation(invitationData, config.apiBaseUrl) .then((response) => { // Success case @@ -167,11 +160,18 @@ export const InvitationForm = ({ } }) // eslint-disable-next-line @typescript-eslint/no-explicit-any - .catch((err: any) => { - const code = err?.response?.data?.code; + .catch((error: any) => { + const code = error?.response?.data?.code || SOMETHING_WRONG_ERROR; + + const selectedApp = apps?.find((app) => app.id === data.app)?.name; + + setErrorParameters({ + email: data.email, + role: data.role, + app: selectedApp || data.app, + }); - setErrorParameters(parameters); - setError(code || "SOMETHING_WRONG"); + setError(code); }) .finally(() => { setSubmitting(false); diff --git a/packages/user/src/constants.ts b/packages/user/src/constants.ts index 95116a657..6c77997ee 100644 --- a/packages/user/src/constants.ts +++ b/packages/user/src/constants.ts @@ -1,3 +1,5 @@ +export const SOMETHING_WRONG_ERROR = "SOMETHING_WRONG"; + export const SUPERTOKENS_API_BASE_PATH_DEFAULT = "/auth"; export enum DEFAULT_PATHS { @@ -18,6 +20,14 @@ export enum DEFAULT_PATHS { PROFILE = "/profile", } +export enum INVITATION_ERROR { + INVALID_EMAIL = "INVALID_EMAIL_ERROR", + INVITATION_ALREADY_EXISTS = "INVITATION_ALREADY_EXISTS_ERROR", + ROLE_NOT_FOUND = "ROLE_NOT_FOUND_ERROR", + ROLE_NOT_SUPPORTED = "ROLE_NOT_SUPPORTED_ERROR", + USER_ALREADY_EXISTS = "USER_ALREADY_EXISTS_ERROR", +} + export enum EMAIL_VERIFICATION { EMAIL_ALREADY_VERIFIED = "EMAIL_ALREADY_VERIFIED", ERROR = "ERROR", diff --git a/packages/user/src/locales/en/errors.json b/packages/user/src/locales/en/errors.json index d19d6f4c4..647e8d94c 100644 --- a/packages/user/src/locales/en/errors.json +++ b/packages/user/src/locales/en/errors.json @@ -4,10 +4,10 @@ "emailAlreadyExists": "This email already exists. Please sign in instead.", "incorrectPassword": "The current password you entered is incorrect", "otherErrors": "Oops! Something went wrong.", - "invalidEmail": "The provided email is invalid.", + "invalidEmail": "The provided email {email} is invalid.", "invitationAlreadyExists": "Invitation already exists for this email.", "roleNotFound": "Role {role} does not exist", - "roleNotSupported": "App {app} does not support role USER.", + "roleNotSupported": "App {app} does not support the role.", "somethingWrong": "Something went wrong. Please try again.", "userAlreadyExists": "User with email {email} already exists" } diff --git a/packages/user/src/locales/fr/errors.json b/packages/user/src/locales/fr/errors.json index 08b335022..8d68a3c92 100644 --- a/packages/user/src/locales/fr/errors.json +++ b/packages/user/src/locales/fr/errors.json @@ -4,10 +4,10 @@ "emailAlreadyExists": "This email already exists. Please sign in instead. (fr)", "incorrectPassword": "The current password you entered is incorrect. (fr)", "otherErrors": "Oops! Something went wrong (fr).", - "invalidEmail": "The provided email is invalid. (fr)", + "invalidEmail": "The provided email {email} is invalid. (fr)", "invitationAlreadyExists": "Invitation already exists for this email. (fr)", "roleNotFound": "Role {role} does not exist. (fr)", - "roleNotSupported": "App {app} does not support role USER. (fr)", + "roleNotSupported": "App {app} does not support the role. (fr)", "somethingWrong": "Something went wrong. Please try again. (fr)", "userAlreadyExists": "User with email {email} already exists. (fr)" } From 7de50cd731e9ed148d1b4b2dfc5073ab6a2c601b Mon Sep 17 00:00:00 2001 From: kabin thakuri Date: Fri, 13 Feb 2026 09:59:33 +0545 Subject: [PATCH 4/6] chore(user): update invitation errors translation keys --- .../src/components/Invitation/InvitationForm.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index f51e45400..c2dffec1a 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -116,30 +116,30 @@ export const InvitationForm = ({ const getErrorMessage = useCallback(() => { switch (error) { case INVITATION_ERROR.INVALID_EMAIL: - return t("messages.invite.errors.invalidEmail", { + return t("errors.invalidEmail", { email: errorParameters?.email, }); case INVITATION_ERROR.INVITATION_ALREADY_EXISTS: - return t("messages.invite.errors.invitationAlreadyExists"); + return t("errors.invitationAlreadyExists"); case INVITATION_ERROR.ROLE_NOT_FOUND: - return t("messages.invite.errors.roleNotFound", { + return t("errors.roleNotFound", { role: errorParameters?.role, }); case INVITATION_ERROR.ROLE_NOT_SUPPORTED: - return t("messages.invite.errors.roleNotSupported", { + return t("errors.roleNotSupported", { app: errorParameters?.app, }); case INVITATION_ERROR.USER_ALREADY_EXISTS: - return t("messages.invite.errors.userAlreadyExists", { + return t("errors.userAlreadyExists", { email: errorParameters?.email, }); default: - return t("messages.invite.errors.somethingWrong"); + return t("errors.somethingWrong"); } }, [error, errorParameters, t]); From 280ab3fbdfbf0a6796949ec887f03f616325972c Mon Sep 17 00:00:00 2001 From: kabin thakuri Date: Fri, 13 Feb 2026 10:46:34 +0545 Subject: [PATCH 5/6] chore(user): update to fetch proper translation for error message --- .../user/src/components/Invitation/InvitationForm.tsx | 8 ++++++-- packages/user/src/locales/en/errors.json | 10 +++++----- packages/user/src/locales/fr/errors.json | 10 +++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index c2dffec1a..e0efaaaeb 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -118,28 +118,32 @@ export const InvitationForm = ({ case INVITATION_ERROR.INVALID_EMAIL: return t("errors.invalidEmail", { email: errorParameters?.email, + ns: "errors", }); case INVITATION_ERROR.INVITATION_ALREADY_EXISTS: - return t("errors.invitationAlreadyExists"); + return t("errors.invitationAlreadyExists", { ns: "errors" }); case INVITATION_ERROR.ROLE_NOT_FOUND: return t("errors.roleNotFound", { + ns: "errors", role: errorParameters?.role, }); case INVITATION_ERROR.ROLE_NOT_SUPPORTED: return t("errors.roleNotSupported", { app: errorParameters?.app, + ns: "errors", }); case INVITATION_ERROR.USER_ALREADY_EXISTS: return t("errors.userAlreadyExists", { email: errorParameters?.email, + ns: "errors", }); default: - return t("errors.somethingWrong"); + return t("errors.somethingWrong", { ns: "errors" }); } }, [error, errorParameters, t]); diff --git a/packages/user/src/locales/en/errors.json b/packages/user/src/locales/en/errors.json index 647e8d94c..fcded0349 100644 --- a/packages/user/src/locales/en/errors.json +++ b/packages/user/src/locales/en/errors.json @@ -3,12 +3,12 @@ "401": "Invalid credentials. Please check your email or password and try again.", "emailAlreadyExists": "This email already exists. Please sign in instead.", "incorrectPassword": "The current password you entered is incorrect", - "otherErrors": "Oops! Something went wrong.", - "invalidEmail": "The provided email {email} is invalid.", + "invalidEmail": "The provided email {{email}} is invalid.", "invitationAlreadyExists": "Invitation already exists for this email.", - "roleNotFound": "Role {role} does not exist", - "roleNotSupported": "App {app} does not support the role.", + "otherErrors": "Oops! Something went wrong.", + "roleNotFound": "Role {{role}} does not exist", + "roleNotSupported": "App {{app}} does not support the role.", "somethingWrong": "Something went wrong. Please try again.", - "userAlreadyExists": "User with email {email} already exists" + "userAlreadyExists": "User with email {{email}} already exists" } } diff --git a/packages/user/src/locales/fr/errors.json b/packages/user/src/locales/fr/errors.json index 8d68a3c92..2158b462e 100644 --- a/packages/user/src/locales/fr/errors.json +++ b/packages/user/src/locales/fr/errors.json @@ -3,12 +3,12 @@ "401": "Invalid credentials. Please check your email or password and try again. (fr)", "emailAlreadyExists": "This email already exists. Please sign in instead. (fr)", "incorrectPassword": "The current password you entered is incorrect. (fr)", - "otherErrors": "Oops! Something went wrong (fr).", - "invalidEmail": "The provided email {email} is invalid. (fr)", + "invalidEmail": "The provided email {{email}} is invalid. (fr)", "invitationAlreadyExists": "Invitation already exists for this email. (fr)", - "roleNotFound": "Role {role} does not exist. (fr)", - "roleNotSupported": "App {app} does not support the role. (fr)", + "otherErrors": "Oops! Something went wrong (fr).", + "roleNotFound": "Role {{role}} does not exist. (fr)", + "roleNotSupported": "App {{app}} does not support the role. (fr)", "somethingWrong": "Something went wrong. Please try again. (fr)", - "userAlreadyExists": "User with email {email} already exists. (fr)" + "userAlreadyExists": "User with email {{email}} already exists. (fr)" } } From d70a9cf35caca6d1453468c8f2455bb5fbe27b70 Mon Sep 17 00:00:00 2001 From: kabin thakuri Date: Fri, 13 Feb 2026 11:33:45 +0545 Subject: [PATCH 6/6] chore(user): fix variable name in constants --- .../src/components/Invitation/InvitationForm.tsx | 12 ++++++------ packages/user/src/constants.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/user/src/components/Invitation/InvitationForm.tsx b/packages/user/src/components/Invitation/InvitationForm.tsx index e0efaaaeb..fb9df5c3b 100644 --- a/packages/user/src/components/Invitation/InvitationForm.tsx +++ b/packages/user/src/components/Invitation/InvitationForm.tsx @@ -10,7 +10,7 @@ import { toast } from "react-toastify"; import * as zod from "zod"; import { addInvitation } from "@/api/invitation"; -import { INVITATION_ERROR, SOMETHING_WRONG_ERROR } from "@/constants"; +import { INVITATION_ERRORS, SOMETHING_WRONG_ERROR } from "@/constants"; import { useConfig } from "@/hooks"; import { InvitationFormFields } from "./InvitationFormFields"; @@ -115,28 +115,28 @@ export const InvitationForm = ({ const getErrorMessage = useCallback(() => { switch (error) { - case INVITATION_ERROR.INVALID_EMAIL: + case INVITATION_ERRORS.INVALID_EMAIL: return t("errors.invalidEmail", { email: errorParameters?.email, ns: "errors", }); - case INVITATION_ERROR.INVITATION_ALREADY_EXISTS: + case INVITATION_ERRORS.INVITATION_ALREADY_EXISTS: return t("errors.invitationAlreadyExists", { ns: "errors" }); - case INVITATION_ERROR.ROLE_NOT_FOUND: + case INVITATION_ERRORS.ROLE_NOT_FOUND: return t("errors.roleNotFound", { ns: "errors", role: errorParameters?.role, }); - case INVITATION_ERROR.ROLE_NOT_SUPPORTED: + case INVITATION_ERRORS.ROLE_NOT_SUPPORTED: return t("errors.roleNotSupported", { app: errorParameters?.app, ns: "errors", }); - case INVITATION_ERROR.USER_ALREADY_EXISTS: + case INVITATION_ERRORS.USER_ALREADY_EXISTS: return t("errors.userAlreadyExists", { email: errorParameters?.email, ns: "errors", diff --git a/packages/user/src/constants.ts b/packages/user/src/constants.ts index 6c77997ee..b07084f8c 100644 --- a/packages/user/src/constants.ts +++ b/packages/user/src/constants.ts @@ -20,7 +20,7 @@ export enum DEFAULT_PATHS { PROFILE = "/profile", } -export enum INVITATION_ERROR { +export enum INVITATION_ERRORS { INVALID_EMAIL = "INVALID_EMAIL_ERROR", INVITATION_ALREADY_EXISTS = "INVITATION_ALREADY_EXISTS_ERROR", ROLE_NOT_FOUND = "ROLE_NOT_FOUND_ERROR",