diff --git a/signup-ui/public/locales/en.json b/signup-ui/public/locales/en.json index bf4eb82b..2e285463 100644 --- a/signup-ui/public/locales/en.json +++ b/signup-ui/public/locales/en.json @@ -121,9 +121,9 @@ "not_registered": "Not Registered", "reset_pwd_failed": "Reset Password Failed", "identifier_already_registered": "Identifier already registered", - "identifier_not_found": "Identifier not found", - "invalid_kba_challenge": "Invalid Fullname challenge", - "kba_challenge_not_found": "Fullname challenge not found", + "identifier_not_found": "Invalid number or name. Please enter a registered mobile number and full name.", + "invalid_kba_challenge": "Invalid number or name. Please enter a registered mobile number and full name.", + "kba_challenge_not_found": "Invalid number or name. Please enter a registered mobile number and full name.", "identity_inactive": "Identifier inactive", "fetch_identity_failed": "Fetch Identifier Failed", "challenge_format_and_type_mismatch": "Challenge format and type mismatch", diff --git a/signup-ui/public/locales/km.json b/signup-ui/public/locales/km.json index a0a4d10b..efac5a54 100644 --- a/signup-ui/public/locales/km.json +++ b/signup-ui/public/locales/km.json @@ -121,12 +121,12 @@ "not_registered": "មិនបានចុះឈ្មោះ", "reset_pwd_failed": "ការកំណត់ពាក្យសម្ងាត់ឡើងវិញបានបរាជ័យ", "identifier_already_registered": "អត្តសញ្ញាណបានចុះឈ្មោះរួចហើយ", - "identifier_not_found": "រកមិនឃើញអត្តសញ្ញាណ", - "invalid_kba_challenge": "ឈ្មោះមិនត្រឹមត្រូវ", - "kba_challenge_not_found": "រកមិនឃើញឈ្មោះ", + "identifier_not_found": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", + "invalid_kba_challenge": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", + "kba_challenge_not_found": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", "identity_inactive": "អត្តសញ្ញាណអសកម្ម", "fetch_identity_failed": "ទាញ​យក​លេខ​សម្គាល់​បាន​បរាជ័យ", - "challenge_format_and_type_mismatch": "ទម្រង់និងប្រភេទមិនត្រូវគ្នា", + "challenge_format_and_type_mismatch": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", "knowledgebase_mismatch": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", "IDR-IDC-001": "រកមិនឃើញតម្លៃដែលបានបញ្ចូល", "IDR-IDC-002": "តម្លៃដែលបានបញ្ចូលមិនត្រឹមត្រូវ", diff --git a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx index 480120d1..d3639b7f 100644 --- a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx @@ -32,6 +32,7 @@ import { ResetPasswordForm, SettingsDto, VerifyChallengeRequestDto, + ResetPasswordPossibleInvalid, } from "~typings/types"; import { resetPasswordFormDefaultValues } from "../ResetPasswordPage"; @@ -203,7 +204,7 @@ export const Otp = ({ methods, settings }: OtpProps) => { onSuccess: ({ errors }) => { if (errors.length > 0) { if ( - ["invalid_transaction", "knowledgebase_mismatch"].includes( + ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( errors[0].errorCode ) ) { diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index ff6345d1..a276e496 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -14,7 +14,7 @@ import { validatePassword, validateUsername, } from "~pages/shared/validation"; -import { ResetPasswordForm, SettingsDto } from "~typings/types"; +import { ResetPasswordForm, ResetPasswordPossibleInvalid, SettingsDto } from "~typings/types"; import Otp from "./Otp"; import ResetPassword from "./ResetPassword"; @@ -108,7 +108,7 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { if ( step === ResetPasswordStep.ResetPasswordConfirmation || (criticalError && - ["invalid_transaction", "knowledgebase_mismatch"].includes( + ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( criticalError.errorCode )) ) @@ -149,7 +149,7 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { return ( <> {criticalError && - ["invalid_transaction", "knowledgebase_mismatch"].includes( + ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( criticalError.errorCode ) && }
diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx index bbdb3436..c6f32bc5 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx @@ -1,6 +1,6 @@ import { useCallback } from "react"; import { useTranslation } from "react-i18next"; -import { useLocation } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; import { ReactComponent as FailedIconSvg } from "~assets/svg/failed-icon.svg"; import { RESET_PASSWORD } from "~constants/routes"; @@ -20,9 +20,11 @@ import { criticalErrorSelector, useResetPasswordStore, } from "./useResetPasswordStore"; +import { ResetPasswordPossibleInvalid } from "~typings/types"; export const ResetPasswordPopover = () => { const { t } = useTranslation(); + const navigate = useNavigate(); const { data: settings } = useSettings(); const { criticalError } = useResetPasswordStore( @@ -37,11 +39,16 @@ export const ResetPasswordPopover = () => { const handleAction = (e: any) => { e.preventDefault(); - window.location.href = getSignInRedirectURL( - settings?.response.configs["signin.redirect-url"], - fromSignInHash, - RESET_PASSWORD - ); + if(ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!)) { + navigate(0) + } else { + window.location.href = getSignInRedirectURL( + settings?.response.configs["signin.redirect-url"], + fromSignInHash, + RESET_PASSWORD + ); + } + }; return ( @@ -51,7 +58,7 @@ export const ResetPasswordPopover = () => { <> - {["knowledgebase_mismatch"].includes(criticalError?.errorCode!!) ? t("invalid") : t("error")} + {ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!) ? t("invalid") : t("error")} @@ -63,7 +70,7 @@ export const ResetPasswordPopover = () => { onClick={handleAction} className="w-full bg-primary" > - {["knowledgebase_mismatch"].includes(criticalError?.errorCode!!) ? t("retry") : t("okay")} + {ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!) ? t("retry") : t("okay")} diff --git a/signup-ui/src/typings/types.ts b/signup-ui/src/typings/types.ts index bac84afc..e8530d9d 100644 --- a/signup-ui/src/typings/types.ts +++ b/signup-ui/src/typings/types.ts @@ -48,6 +48,14 @@ const RegisterStatusPossibleErrors = [ export type RegisterStatusErrors = (typeof RegisterStatusPossibleErrors)[number]; +export const ResetPasswordPossibleInvalid = [ + "knowledgebase_mismatch", + "identifier_not_found", + "invalid_kba_challenge", + "challenge_format_and_type_mismatch", + "kba_challenge_not_found" +]; + const ResetPasswordPossibleErrors = [ "invalid_transaction", "not_registered", @@ -56,6 +64,10 @@ const ResetPasswordPossibleErrors = [ "invalid_request", "reset_pwd_failed", "knowledgebase_mismatch", + "identifier_not_found", + "invalid_kba_challenge", + "challenge_format_and_type_mismatch", + "kba_challenge_not_found", ] as const; export type ResetPasswordErrors = (typeof ResetPasswordPossibleErrors)[number];