Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES-712 #31

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions signup-ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions signup-ui/public/locales/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "តម្លៃដែលបានបញ្ចូលមិនត្រឹមត្រូវ",
Expand Down
3 changes: 2 additions & 1 deletion signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
ResetPasswordForm,
SettingsDto,
VerifyChallengeRequestDto,
ResetPasswordPossibleInvalid,
} from "~typings/types";

import { resetPasswordFormDefaultValues } from "../ResetPasswordPage";
Expand Down Expand Up @@ -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
)
) {
Expand Down
6 changes: 3 additions & 3 deletions signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
))
)
Expand Down Expand Up @@ -149,7 +149,7 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => {
return (
<>
{criticalError &&
["invalid_transaction", "knowledgebase_mismatch"].includes(
["invalid_transaction", ...ResetPasswordPossibleInvalid].includes(
criticalError.errorCode
) && <ResetPasswordPopover />}
<Form {...methods}>
Expand Down
23 changes: 15 additions & 8 deletions signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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(
Expand All @@ -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 (
Expand All @@ -51,7 +58,7 @@ export const ResetPasswordPopover = () => {
<AlertDialogTitle className="flex flex-col items-center justify-center gap-y-4">
<>
<FailedIconSvg />
{["knowledgebase_mismatch"].includes(criticalError?.errorCode!!) ? t("invalid") : t("error")}
{ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!) ? t("invalid") : t("error")}
</>
</AlertDialogTitle>
<AlertDialogDescription className="break-all text-center text-muted-dark-gray">
Expand All @@ -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")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
Expand Down
12 changes: 12 additions & 0 deletions signup-ui/src/typings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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];
Expand Down
Loading