diff --git a/signup-ui/public/locales/en.json b/signup-ui/public/locales/en.json
index 2e285463..a5b54e36 100644
--- a/signup-ui/public/locales/en.json
+++ b/signup-ui/public/locales/en.json
@@ -62,7 +62,8 @@
"page_under_construction_detail": "Our experts are working hard to make this page available. Meanwhile, we request you to please visit after some time.",
"something_went_wrong": "Something went wrong!",
"something_went_wrong_detail": "Our experts are working hard to make things working again.",
- "attempts_left": "{attemptLeft, plural, =0 {0 of {totalAttempt} attempts left. Please try again after {attemptRetryAfter} minutes.} other {{attemptLeft} of {totalAttempt} attempts left}}",
+ "attempts_left": "{attemptLeft, plural, =0 {0 of {totalAttempt} attempts left} other {{attemptLeft} of {totalAttempt} attempts left}}",
+ "attempts_left_and_retry": "{attemptLeft, plural, =0 {0 of {totalAttempt} attempts left. Please try again after {attemptRetryAfter} minutes.} other {{attemptLeft} of {totalAttempt} attempts left}}",
"captcha_token_validation": "Please verify that you are a human.",
"username_validation": "Enter a valid username",
"username_lead_zero_validation": "Number cannot start with zero. Enter a valid mobile number.",
diff --git a/signup-ui/public/locales/km.json b/signup-ui/public/locales/km.json
index efac5a54..c9bdb9ea 100644
--- a/signup-ui/public/locales/km.json
+++ b/signup-ui/public/locales/km.json
@@ -62,7 +62,8 @@
"page_under_construction_detail": "អ្នកជំនាញកំពុងធ្វើការដើម្បីឱ្យទំព័រនេះអាចប្រើប្រាស់បាន។ សូមចូលម្ដងទៀតនៅពេលក្រោយ។",
"something_went_wrong": "មានអ្វីមួយខុសប្រក្រតី!",
"something_went_wrong_detail": "អ្នកជំនាញកំពុងធ្វើការដើម្បីឱ្យអ្វីៗដំណើរការឡើងវិញ។",
- "attempts_left": "{attemptLeft, plural, =0 {ការព្យាយាមនៅសល់ 0 នៃ {totalAttempt}។ សូមព្យាយាមម្តងទៀតនៅ {attemptRetryAfter} នាទីបន្ទាប់។} other {ការព្យាយាមនៅសល់ {attemptLeft} នៃ {totalAttempt}}}",
+ "attempts_left": "{attemptLeft, plural, =0 {ការព្យាយាមនៅសល់ 0 នៃ {totalAttempt}} other {ការព្យាយាមនៅសល់ {attemptLeft} នៃ {totalAttempt}}}",
+ "attempts_left_and_retry": "{attemptLeft, plural, =0 {ការព្យាយាមនៅសល់ 0 នៃ {totalAttempt}។ សូមព្យាយាមម្តងទៀតនៅ {attemptRetryAfter} នាទីបន្ទាប់។} other {ការព្យាយាមនៅសល់ {attemptLeft} នៃ {totalAttempt}}}",
"captcha_token_validation": "សូមបញ្ជាក់ថាអ្នកជាមនុស្ស",
"username_validation": "សូមបញ្ចូលឈ្មោះអ្នកប្រើប្រាស់ត្រឹមត្រូវ",
"username_lead_zero_validation": "លេខមិនអាចចាប់ផ្តើមដោយលេខសូន្យបានទេ។បញ្ចូលលេខទូរស័ព្ទដែលត្រឹមត្រូវ។",
diff --git a/signup-ui/src/components/resend-attempt.tsx b/signup-ui/src/components/resend-attempt.tsx
index a428f452..cef25ff8 100644
--- a/signup-ui/src/components/resend-attempt.tsx
+++ b/signup-ui/src/components/resend-attempt.tsx
@@ -4,22 +4,24 @@ interface ResendAttemptProps {
currentAttempts: number;
totalAttempts: number;
attemptRetryAfter?: number;
+ showRetry?: boolean;
}
export const ResendAttempt = ({
currentAttempts,
totalAttempts,
- attemptRetryAfter = 5,
+ attemptRetryAfter = 300,
+ showRetry = false,
}: ResendAttemptProps) => {
const { t } = useTranslation();
return (
<>
{currentAttempts < totalAttempts && (
- {t("attempts_left", {
+ {t(showRetry ? "attempts_left_and_retry" : "attempts_left", {
attemptLeft: currentAttempts,
totalAttempt: totalAttempts,
- attemptRetryAfter: attemptRetryAfter,
+ attemptRetryAfter: attemptRetryAfter / 60,
})}
)}
diff --git a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx
index d3639b7f..59b9c120 100644
--- a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx
+++ b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx
@@ -30,9 +30,9 @@ import {
Error,
GenerateChallengeRequestDto,
ResetPasswordForm,
+ ResetPasswordPossibleInvalid,
SettingsDto,
VerifyChallengeRequestDto,
- ResetPasswordPossibleInvalid,
} from "~typings/types";
import { resetPasswordFormDefaultValues } from "../ResetPasswordPage";
@@ -129,15 +129,10 @@ export const Otp = ({ methods, settings }: OtpProps) => {
};
return generateChallengeMutation.mutate(generateChallengeRequestDto, {
- onSuccess: ({ errors }) => {
+ onSuccess: ({ response, errors }) => {
pinInputRef.current?.clear();
setValue("otp", "", { shouldValidate: true });
- setResendAttempts((resendAttempt) => resendAttempt - 1);
- restartResendOtpTotalSecs(
- getTimeoutTime(settings.response.configs["resend.delay"])
- );
-
if (errors && errors.length > 0) {
if (errors[0].errorCode === "invalid_transaction") {
setCriticalError(errors[0]);
@@ -145,6 +140,13 @@ export const Otp = ({ methods, settings }: OtpProps) => {
setChallengeVerificationError(errors[0]);
}
}
+
+ if (errors.length === 0 && response?.status === "SUCCESS") {
+ setResendAttempts((resendAttempt) => resendAttempt - 1);
+ restartResendOtpTotalSecs(
+ getTimeoutTime(settings.response.configs["resend.delay"])
+ );
+ }
},
});
}
@@ -204,9 +206,10 @@ export const Otp = ({ methods, settings }: OtpProps) => {
onSuccess: ({ errors }) => {
if (errors.length > 0) {
if (
- ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes(
- errors[0].errorCode
- )
+ [
+ "invalid_transaction",
+ ...ResetPasswordPossibleInvalid,
+ ].includes(errors[0].errorCode)
) {
setCriticalError(errors[0]);
} else {
@@ -349,9 +352,10 @@ export const Otp = ({ methods, settings }: OtpProps) => {
currentAttempts={resendAttempts}
totalAttempts={settings.response.configs["resend.attempts"]}
attemptRetryAfter={settings.response.configs["otp.blocked"]}
+ showRetry={resendAttempts === 0 && resendOtpTotalSecs === 0}
/>
)}
- {resendAttempts === 0 && (
+ {resendAttempts === 0 && resendOtpTotalSecs === 0 && (