Skip to content

Commit

Permalink
feat: show retry after countdown is zero
Browse files Browse the repository at this point in the history
Signed-off-by: bunsy23 <[email protected]>
  • Loading branch information
bunsyy committed Jan 29, 2024
1 parent b3f4515 commit 0c3179b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion signup-ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
3 changes: 2 additions & 1 deletion signup-ui/public/locales/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "លេខមិនអាចចាប់ផ្តើមដោយលេខសូន្យបានទេ។បញ្ចូលលេខទូរស័ព្ទដែលត្រឹមត្រូវ។",
Expand Down
4 changes: 3 additions & 1 deletion signup-ui/src/components/resend-attempt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ interface ResendAttemptProps {
currentAttempts: number;
totalAttempts: number;
attemptRetryAfter?: number;
showRetry?: boolean;
}

export const ResendAttempt = ({
currentAttempts,
totalAttempts,
attemptRetryAfter = 300,
showRetry = false,
}: ResendAttemptProps) => {
const { t } = useTranslation();
return (
<>
{currentAttempts < totalAttempts && (
<div className="w-max rounded-md bg-[#FFF7E5] p-2 px-8 text-center text-sm font-semibold text-[#8B6105]">
{t("attempts_left", {
{t(showRetry ? "attempts_left_and_retry" : "attempts_left", {
attemptLeft: currentAttempts,
totalAttempt: totalAttempts,
attemptRetryAfter: attemptRetryAfter / 60,
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 @@ -352,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 && (
<Button
variant="link"
className="m-4 h-4 px-12 text-sm"
Expand Down
3 changes: 2 additions & 1 deletion signup-ui/src/pages/SignUpPage/Otp/Otp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,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 && (
<Button
variant="link"
className="m-4 h-4 text-sm"
Expand Down
1 change: 1 addition & 0 deletions signup-ui/src/resources.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface Resources {
something_went_wrong: string;
something_went_wrong_detail: string;
attempts_left: string;
attempts_left_and_retry: string;
captcha_token_validation: string;
username_validation: string;
username_lead_zero_validation: string;
Expand Down

0 comments on commit 0c3179b

Please sign in to comment.