Skip to content

Commit e30bf26

Browse files
authored
refactor(account-center): optimize security verification code UI (#8110)
- Update resend message to include "Not received yet?" prefix with styled link - Fix spacing issue in resend countdown by placing space inside span tag - Change phone verification title from "Enter phone verification code" to "Enter SMS verification code"
1 parent 27b894c commit e30bf26

File tree

20 files changed

+171
-152
lines changed

20 files changed

+171
-152
lines changed

packages/account-center/src/pages/CodeFlow/IdentifierVerifyStep.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Button from '@experience/shared/components/Button';
2-
import DynamicT from '@experience/shared/components/DynamicT';
32
import VerificationCodeInput, {
43
defaultLength,
54
} from '@experience/shared/components/VerificationCode';
65
import { type TFuncKey } from 'i18next';
76
import { useContext, useEffect, useMemo, useState } from 'react';
8-
import { useTranslation } from 'react-i18next';
7+
import { Trans, useTranslation } from 'react-i18next';
98

109
import LoadingContext from '@ac/Providers/LoadingContextProvider/LoadingContext';
1110
import PageContext from '@ac/Providers/PageContextProvider/PageContext';
11+
import SwitchVerificationMethodLink from '@ac/components/SwitchVerificationMethodLink';
1212
import useApi from '@ac/hooks/use-api';
1313
import useErrorHandler from '@ac/hooks/use-error-handler';
1414
import SecondaryPageLayout from '@ac/layouts/SecondaryPageLayout';
@@ -31,6 +31,7 @@ type Props = {
3131
readonly onSubmit: (code: string) => void;
3232
readonly onBack: () => void;
3333
readonly onInvalidCode: () => void;
34+
readonly onSwitchMethod?: () => void;
3435
readonly sendCode: (
3536
accessToken: string,
3637
identifier: string
@@ -50,6 +51,7 @@ const IdentifierVerifyStep = ({
5051
onSubmit,
5152
onBack,
5253
onInvalidCode,
54+
onSwitchMethod,
5355
sendCode,
5456
}: Props) => {
5557
const { t } = useTranslation();
@@ -133,21 +135,26 @@ const IdentifierVerifyStep = ({
133135
/>
134136
<div className={styles.message}>
135137
{countdown > 0 ? (
136-
<DynamicT
137-
forKey="account_center.code_verification.resend_countdown"
138-
interpolation={{ seconds: countdown }}
139-
/>
138+
<Trans components={{ span: <span className={styles.highlight} /> }}>
139+
{t('account_center.code_verification.resend_countdown', { seconds: countdown })}
140+
</Trans>
140141
) : (
141-
<button
142-
className={styles.resendButton}
143-
type="button"
144-
disabled={loading}
145-
onClick={() => {
146-
void handleResend();
142+
<Trans
143+
components={{
144+
a: (
145+
<button
146+
className={styles.resendButton}
147+
type="button"
148+
disabled={loading}
149+
onClick={() => {
150+
void handleResend();
151+
}}
152+
/>
153+
),
147154
}}
148155
>
149-
<DynamicT forKey="account_center.code_verification.resend" />
150-
</button>
156+
{t('account_center.code_verification.resend')}
157+
</Trans>
151158
)}
152159
</div>
153160
<Button
@@ -164,6 +171,9 @@ const IdentifierVerifyStep = ({
164171
onSubmit(codeInput.join(''));
165172
}}
166173
/>
174+
{onSwitchMethod && (
175+
<SwitchVerificationMethodLink className={styles.switchMethod} onClick={onSwitchMethod} />
176+
)}
167177
</div>
168178
</SecondaryPageLayout>
169179
);

packages/account-center/src/pages/CodeFlow/index.module.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@
2424
align-items: center;
2525
}
2626

27+
.highlight {
28+
margin-inline-start: _.unit(1);
29+
color: var(--color-brand-default);
30+
}
31+
2732
.resendButton {
2833
background: transparent;
2934
border: none;
3035
padding: 0;
31-
font: var(--font-body-2-medium);
32-
color: var(--color-primary-50);
36+
font: var(--font-body-2);
37+
color: var(--color-brand-default);
3338
cursor: pointer;
3439

3540
&:disabled {
@@ -41,3 +46,7 @@
4146
.submit {
4247
align-self: flex-start;
4348
}
49+
50+
.switchMethod {
51+
margin-top: _.unit(2);
52+
}

packages/phrases-experience/src/locales/ar/account-center.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const account_center = {
4646
phone: {
4747
title: 'ربط رقم الهاتف',
4848
description: 'اربط رقم هاتفك لتسجيل الدخول أو للمساعدة في استعادة الحساب.',
49-
verification_title: 'أدخل رمز التحقق عبر الهاتف',
49+
verification_title: 'أدخل رمز التحقق عبر الرسائل القصيرة',
5050
verification_description: 'تم إرسال رمز التحقق إلى هاتفك {{phone_number}}.',
5151
success: 'تم ربط الهاتف الأساسي بنجاح.',
5252
verification_required: 'انتهت صلاحية التحقق. يرجى التحقق من هويتك مرة أخرى.',
@@ -64,8 +64,8 @@ const account_center = {
6464

6565
code_verification: {
6666
send: 'إرسال رمز التحقق',
67-
resend: 'إعادة إرسال الرمز',
68-
resend_countdown: 'لم تستلمه بعد؟ أعد الإرسال بعد {{seconds}} ث.',
67+
resend: 'لم تستلمه بعد؟ <a>إعادة إرسال رمز التحقق</a>',
68+
resend_countdown: 'لم تستلمه بعد؟<span> أعد الإرسال بعد {{seconds}} ث.</span>',
6969
},
7070

7171
email_verification: {
@@ -74,8 +74,8 @@ const account_center = {
7474
email_label: 'عنوان البريد الإلكتروني',
7575
send: 'إرسال رمز التحقق',
7676
description: 'تم إرسال رمز التحقق إلى بريدك الإلكتروني {{email}}. أدخل الرمز للمتابعة.',
77-
resend: 'إعادة إرسال الرمز',
78-
resend_countdown: 'لم تستلمه بعد؟ أعد الإرسال بعد {{seconds}} ث.',
77+
resend: 'لم تستلمه بعد؟ <a>إعادة إرسال رمز التحقق</a>',
78+
resend_countdown: 'لم تستلمه بعد؟<span> أعد الإرسال بعد {{seconds}} ث.</span>',
7979
error_send_failed: 'فشل إرسال رمز التحقق. يرجى المحاولة لاحقًا.',
8080
error_verify_failed: 'فشل التحقق. يرجى إدخال الرمز مرة أخرى.',
8181
error_invalid_code: 'رمز التحقق غير صالح أو منتهي الصلاحية.',
@@ -86,8 +86,8 @@ const account_center = {
8686
phone_label: 'رقم الهاتف',
8787
send: 'إرسال رمز التحقق',
8888
description: 'تم إرسال رمز التحقق إلى هاتفك {{phone}}. أدخل الرمز للمتابعة.',
89-
resend: 'إعادة إرسال الرمز',
90-
resend_countdown: 'لم تستلمه بعد؟ أعد الإرسال بعد {{seconds}} ث.',
89+
resend: 'لم تستلمه بعد؟ <a>إعادة إرسال رمز التحقق</a>',
90+
resend_countdown: 'لم تستلمه بعد؟<span> أعد الإرسال بعد {{seconds}} ث.</span>',
9191
error_send_failed: 'فشل إرسال رمز التحقق. يرجى المحاولة لاحقًا.',
9292
error_verify_failed: 'فشل التحقق. يرجى إدخال الرمز مرة أخرى.',
9393
error_invalid_code: 'رمز التحقق غير صالح أو منتهي الصلاحية.',

packages/phrases-experience/src/locales/de/account-center.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const account_center = {
5151
title: 'Telefonnummer verknüpfen',
5252
description:
5353
'Verknüpfe deine Telefonnummer, um dich anzumelden oder die Kontowiederherstellung zu unterstützen.',
54-
verification_title: 'Telefon-Bestätigungscode eingeben',
54+
verification_title: 'SMS-Bestätigungscode eingeben',
5555
verification_description:
5656
'Der Bestätigungscode wurde an dein Telefon {{phone_number}} gesendet.',
5757
success: 'Primäre Telefonnummer wurde erfolgreich verknüpft.',
@@ -70,8 +70,8 @@ const account_center = {
7070

7171
code_verification: {
7272
send: 'Bestätigungscode senden',
73-
resend: 'Code erneut senden',
74-
resend_countdown: 'Noch nichts erhalten? Erneut senden nach {{seconds}} s.',
73+
resend: 'Noch nichts erhalten? <a>Bestätigungscode erneut senden</a>',
74+
resend_countdown: 'Noch nichts erhalten?<span> Erneut senden nach {{seconds}} s.</span>',
7575
},
7676

7777
email_verification: {
@@ -82,8 +82,8 @@ const account_center = {
8282
send: 'Bestätigungscode senden',
8383
description:
8484
'Der Bestätigungscode wurde an deine E-Mail {{email}} gesendet. Gib den Code ein, um fortzufahren.',
85-
resend: 'Code erneut senden',
86-
resend_countdown: 'Noch nichts erhalten? Erneut senden nach {{seconds}} s.',
85+
resend: 'Noch nichts erhalten? <a>Bestätigungscode erneut senden</a>',
86+
resend_countdown: 'Noch nichts erhalten?<span> Erneut senden nach {{seconds}} s.</span>',
8787
error_send_failed:
8888
'Bestätigungscode konnte nicht gesendet werden. Bitte versuche es später noch einmal.',
8989
error_verify_failed: 'Verifizierung fehlgeschlagen. Bitte gib den Code erneut ein.',
@@ -97,8 +97,8 @@ const account_center = {
9797
send: 'Bestätigungscode senden',
9898
description:
9999
'Der Bestätigungscode wurde an dein Telefon {{phone}} gesendet. Gib den Code ein, um fortzufahren.',
100-
resend: 'Code erneut senden',
101-
resend_countdown: 'Noch nichts erhalten? Erneut senden nach {{seconds}} s.',
100+
resend: 'Noch nichts erhalten? <a>Bestätigungscode erneut senden</a>',
101+
resend_countdown: 'Noch nichts erhalten?<span> Erneut senden nach {{seconds}} s.</span>',
102102
error_send_failed:
103103
'Bestätigungscode konnte nicht gesendet werden. Bitte versuche es später noch einmal.',
104104
error_verify_failed: 'Verifizierung fehlgeschlagen. Bitte gib den Code erneut ein.',

packages/phrases-experience/src/locales/en/account-center.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const account_center = {
4747
phone: {
4848
title: 'Link phone number',
4949
description: 'Link your phone number to sign in or help with account recovery.',
50-
verification_title: 'Enter phone verification code',
50+
verification_title: 'Enter SMS verification code',
5151
verification_description: 'The verification code has been sent to your phone {{phone_number}}.',
5252
success: 'Primary phone linked successfully.',
5353
verification_required: 'Verification expired. Please verify your identity again.',
@@ -65,8 +65,8 @@ const account_center = {
6565

6666
code_verification: {
6767
send: 'Send verification code',
68-
resend: 'Resend code',
69-
resend_countdown: 'Not received yet? Resend after {{seconds}}s.',
68+
resend: 'Not received yet? <a>Resend verification code</a>',
69+
resend_countdown: 'Not received yet?<span> Resend after {{seconds}}s.</span>',
7070
},
7171

7272
email_verification: {
@@ -77,8 +77,8 @@ const account_center = {
7777
send: 'Send verification code',
7878
description:
7979
'The verification code has been sent to your email {{email}}. Enter the code to continue.',
80-
resend: 'Resend code',
81-
resend_countdown: 'Not received yet? Resend after {{seconds}}s.',
80+
resend: 'Not received yet? <a>Resend verification code</a>',
81+
resend_countdown: 'Not received yet?<span> Resend after {{seconds}}s.</span>',
8282
error_send_failed: 'Failed to send verification code. Please try again later.',
8383
error_verify_failed: 'Verification failed. Please enter the code again.',
8484
error_invalid_code: 'The verification code is invalid or has expired.',
@@ -91,8 +91,8 @@ const account_center = {
9191
send: 'Send verification code',
9292
description:
9393
'The verification code has been sent to your phone {{phone}}. Enter the code to continue.',
94-
resend: 'Resend code',
95-
resend_countdown: 'Not received yet? Resend after {{seconds}}s.',
94+
resend: 'Not received yet? <a>Resend verification code</a>',
95+
resend_countdown: 'Not received yet?<span> Resend after {{seconds}}s.</span>',
9696
error_send_failed: 'Failed to send verification code. Please try again later.',
9797
error_verify_failed: 'Verification failed. Please enter the code again.',
9898
error_invalid_code: 'The verification code is invalid or has expired.',

packages/phrases-experience/src/locales/es/account-center.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const account_center = {
4949
title: 'Vincular número de teléfono',
5050
description:
5151
'Vincula tu número de teléfono para iniciar sesión o ayudar con la recuperación de la cuenta.',
52-
verification_title: 'Ingresa el código de verificación del teléfono',
52+
verification_title: 'Ingresa el código de verificación SMS',
5353
verification_description:
5454
'El código de verificación se ha enviado a tu teléfono {{phone_number}}.',
5555
success: 'Teléfono principal vinculado correctamente.',
@@ -68,8 +68,8 @@ const account_center = {
6868

6969
code_verification: {
7070
send: 'Enviar código de verificación',
71-
resend: 'Reenviar código',
72-
resend_countdown: '¿Aún no lo recibes? Reenvía después de {{seconds}} s.',
71+
resend: '¿Aún no lo recibes? <a>Reenviar código de verificación</a>',
72+
resend_countdown: '¿Aún no lo recibes?<span> Reenvía después de {{seconds}} s.</span>',
7373
},
7474

7575
email_verification: {
@@ -80,8 +80,8 @@ const account_center = {
8080
send: 'Enviar código de verificación',
8181
description:
8282
'El código de verificación se ha enviado a tu correo {{email}}. Ingresa el código para continuar.',
83-
resend: 'Reenviar código',
84-
resend_countdown: '¿Aún no lo recibes? Reenvía después de {{seconds}} s.',
83+
resend: '¿Aún no lo recibes? <a>Reenviar código de verificación</a>',
84+
resend_countdown: '¿Aún no lo recibes?<span> Reenvía después de {{seconds}} s.</span>',
8585
error_send_failed: 'No se pudo enviar el código de verificación. Inténtalo de nuevo más tarde.',
8686
error_verify_failed: 'La verificación falló. Ingresa el código nuevamente.',
8787
error_invalid_code: 'El código de verificación no es válido o ha expirado.',
@@ -94,8 +94,8 @@ const account_center = {
9494
send: 'Enviar código de verificación',
9595
description:
9696
'El código de verificación se ha enviado a tu teléfono {{phone}}. Ingresa el código para continuar.',
97-
resend: 'Reenviar código',
98-
resend_countdown: '¿Aún no lo recibes? Reenvía después de {{seconds}} s.',
97+
resend: '¿Aún no lo recibes? <a>Reenviar código de verificación</a>',
98+
resend_countdown: '¿Aún no lo recibes?<span> Reenvía después de {{seconds}} s.</span>',
9999
error_send_failed: 'No se pudo enviar el código de verificación. Inténtalo de nuevo más tarde.',
100100
error_verify_failed: 'La verificación falló. Ingresa el código nuevamente.',
101101
error_invalid_code: 'El código de verificación no es válido o ha expirado.',

packages/phrases-experience/src/locales/fr/account-center.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const account_center = {
4949
title: 'Lier le numéro de téléphone',
5050
description:
5151
'Liez votre numéro de téléphone pour vous connecter ou faciliter la récupération du compte.',
52-
verification_title: 'Saisissez le code de vérification du téléphone',
52+
verification_title: 'Saisissez le code de vérification SMS',
5353
verification_description:
5454
'Le code de vérification a été envoyé sur votre téléphone {{phone_number}}.',
5555
success: 'Téléphone principal lié avec succès.',
@@ -69,8 +69,8 @@ const account_center = {
6969

7070
code_verification: {
7171
send: 'Envoyer le code de vérification',
72-
resend: 'Renvoyer le code',
73-
resend_countdown: 'Pas encore reçu ? Renvoyez après {{seconds}} s.',
72+
resend: 'Pas encore reçu ? <a>Renvoyer le code de vérification</a>',
73+
resend_countdown: 'Pas encore reçu ?<span> Renvoyez après {{seconds}} s.</span>',
7474
},
7575

7676
email_verification: {
@@ -81,8 +81,8 @@ const account_center = {
8181
send: 'Envoyer le code de vérification',
8282
description:
8383
'Le code de vérification a été envoyé à votre e-mail {{email}}. Saisissez le code pour continuer.',
84-
resend: 'Renvoyer le code',
85-
resend_countdown: 'Pas encore reçu ? Renvoyez après {{seconds}} s.',
84+
resend: 'Pas encore reçu ? <a>Renvoyer le code de vérification</a>',
85+
resend_countdown: 'Pas encore reçu ?<span> Renvoyez après {{seconds}} s.</span>',
8686
error_send_failed: "Échec de l'envoi du code de vérification. Veuillez réessayer plus tard.",
8787
error_verify_failed: 'Échec de la vérification. Veuillez saisir le code à nouveau.',
8888
error_invalid_code: 'Le code de vérification est invalide ou a expiré.',
@@ -95,8 +95,8 @@ const account_center = {
9595
send: 'Envoyer le code de vérification',
9696
description:
9797
'Le code de vérification a été envoyé à votre téléphone {{phone}}. Saisissez le code pour continuer.',
98-
resend: 'Renvoyer le code',
99-
resend_countdown: 'Pas encore reçu ? Renvoyez après {{seconds}} s.',
98+
resend: 'Pas encore reçu ? <a>Renvoyer le code de vérification</a>',
99+
resend_countdown: 'Pas encore reçu ?<span> Renvoyez après {{seconds}} s.</span>',
100100
error_send_failed: "Échec de l'envoi du code de vérification. Veuillez réessayer plus tard.",
101101
error_verify_failed: 'Échec de la vérification. Veuillez saisir le code à nouveau.',
102102
error_invalid_code: 'Le code de vérification est invalide ou a expiré.',

packages/phrases-experience/src/locales/it/account-center.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const account_center = {
4848
phone: {
4949
title: 'Collega numero di telefono',
5050
description:
51-
'Collega il tuo numero di telefono per accedere o aiutare con il recupero dellaccount.',
52-
verification_title: 'Inserisci il codice di verifica del telefono',
51+
"Collega il tuo numero di telefono per accedere o aiutare con il recupero dell'account.",
52+
verification_title: 'Inserisci il codice di verifica SMS',
5353
verification_description:
5454
'Il codice di verifica è stato inviato al tuo telefono {{phone_number}}.',
5555
success: 'Telefono principale collegato correttamente.',
@@ -68,8 +68,8 @@ const account_center = {
6868

6969
code_verification: {
7070
send: 'Invia codice di verifica',
71-
resend: 'Invia di nuovo il codice',
72-
resend_countdown: "Non l'hai ricevuto? Reinvia dopo {{seconds}} s.",
71+
resend: "Non l'hai ricevuto? <a>Reinvia il codice di verifica</a>",
72+
resend_countdown: "Non l'hai ricevuto?<span> Reinvia dopo {{seconds}} s.</span>",
7373
},
7474

7575
email_verification: {
@@ -80,8 +80,8 @@ const account_center = {
8080
send: 'Invia codice di verifica',
8181
description:
8282
"Il codice di verifica è stato inviato all'e-mail {{email}}. Inserisci il codice per continuare.",
83-
resend: 'Invia di nuovo il codice',
84-
resend_countdown: "Non l'hai ricevuto? Reinvia dopo {{seconds}} s.",
83+
resend: "Non l'hai ricevuto? <a>Reinvia il codice di verifica</a>",
84+
resend_countdown: "Non l'hai ricevuto?<span> Reinvia dopo {{seconds}} s.</span>",
8585
error_send_failed: 'Invio del codice di verifica non riuscito. Riprova più tardi.',
8686
error_verify_failed: 'Verifica non riuscita. Inserisci di nuovo il codice.',
8787
error_invalid_code: 'Il codice di verifica non è valido o è scaduto.',
@@ -94,8 +94,8 @@ const account_center = {
9494
send: 'Invia codice di verifica',
9595
description:
9696
'Il codice di verifica è stato inviato al tuo telefono {{phone}}. Inserisci il codice per continuare.',
97-
resend: 'Invia di nuovo il codice',
98-
resend_countdown: "Non l'hai ricevuto? Reinvia dopo {{seconds}} s.",
97+
resend: "Non l'hai ricevuto? <a>Reinvia il codice di verifica</a>",
98+
resend_countdown: "Non l'hai ricevuto?<span> Reinvia dopo {{seconds}} s.</span>",
9999
error_send_failed: 'Invio del codice di verifica non riuscito. Riprova più tardi.',
100100
error_verify_failed: 'Verifica non riuscita. Inserisci di nuovo il codice.',
101101
error_invalid_code: 'Il codice di verifica non è valido o è scaduto.',

0 commit comments

Comments
 (0)