diff --git a/src/languages/en.ts b/src/languages/en.ts index 513188826027..fad403ef1ce0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1943,6 +1943,34 @@ const translations = { `We've been unable to deliver SMS messages to ${login}, so we've suspended it for 24 hours. Please try validating your number:`, validationFailed: 'Validation failed because it hasn’t been 24 hours since your last attempt.', validationSuccess: 'Your number has been validated! Click below to send a new magic sign-in code.', + pleaseWaitBeforeTryingAgain: ({timeData}: {timeData?: {days?: number; hours?: number; minutes?: number}}) => { + if (!timeData) { + return 'Please wait a moment before trying again.'; + } + + const parts = []; + if (timeData.days) { + parts.push(`${timeData.days} ${timeData.days === 1 ? 'day' : 'days'}`); + } + if (timeData.hours) { + parts.push(`${timeData.hours} ${timeData.hours === 1 ? 'hour' : 'hours'}`); + } + if (timeData.minutes) { + parts.push(`${timeData.minutes} ${timeData.minutes === 1 ? 'minute' : 'minutes'}`); + } + + let timeText; + if (parts.length === 1) { + timeText = parts.at(0); + } else if (parts.length === 2) { + timeText = parts.join(' and '); + } else { + const lastPart = parts.pop(); + timeText = `${parts.join(', ')} and ${lastPart}`; + } + + return `Please wait ${timeText} before trying again.`; + }, }, welcomeSignUpForm: { join: 'Join', diff --git a/src/languages/es.ts b/src/languages/es.ts index 870b6fb73706..4f706032e1b8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1947,6 +1947,34 @@ const translations = { `No hemos podido entregar mensajes SMS a ${login}, así que lo hemos suspendido durante 24 horas. Por favor, intenta validar tu número:`, validationFailed: 'La validación falló porque no han pasado 24 horas desde tu último intento.', validationSuccess: '¡Tu número ha sido validado! Haz clic abajo para enviar un nuevo código mágico de inicio de sesión.', + pleaseWaitBeforeTryingAgain: ({timeData}: {timeData?: {days?: number; hours?: number; minutes?: number}}) => { + if (!timeData) { + return 'Por favor, espera un momento antes de intentarlo de nuevo.'; + } + + const parts = []; + if (timeData.days) { + parts.push(`${timeData.days} ${timeData.days === 1 ? 'día' : 'días'}`); + } + if (timeData.hours) { + parts.push(`${timeData.hours} ${timeData.hours === 1 ? 'hora' : 'horas'}`); + } + if (timeData.minutes) { + parts.push(`${timeData.minutes} ${timeData.minutes === 1 ? 'minuto' : 'minutos'}`); + } + + let timeText; + if (parts.length === 1) { + timeText = parts.at(0); + } else if (parts.length === 2) { + timeText = parts.join(' y '); + } else { + const lastPart = parts.pop(); + timeText = `${parts.join(', ')} y ${lastPart}`; + } + + return `Por favor, espera ${timeText} antes de intentarlo de nuevo.`; + }, }, welcomeSignUpForm: { join: 'Unirse', diff --git a/src/pages/signin/SMSDeliveryFailurePage.tsx b/src/pages/signin/SMSDeliveryFailurePage.tsx index ac8d04f556fa..953a0dfc0a8b 100644 --- a/src/pages/signin/SMSDeliveryFailurePage.tsx +++ b/src/pages/signin/SMSDeliveryFailurePage.tsx @@ -29,7 +29,22 @@ function SMSDeliveryFailurePage() { }, [credentials?.login]); const SMSDeliveryFailureMessage = account?.smsDeliveryFailureStatus?.message; + + type TimeData = { + days?: number; + hours?: number; + minutes?: number; + }; + + const timeData = useMemo(() => { + if (!SMSDeliveryFailureMessage) { + return null; + } + return JSON.parse(SMSDeliveryFailureMessage) as TimeData; + }, [SMSDeliveryFailureMessage]); + const hasSMSDeliveryFailure = account?.smsDeliveryFailureStatus?.hasSMSDeliveryFailure; + const isReset = account?.smsDeliveryFailureStatus?.isReset; const errorText = useMemo(() => (account ? getLatestErrorMessage(account) : ''), [account]); @@ -48,7 +63,7 @@ function SMSDeliveryFailurePage() { - {translate('smsDeliveryFailurePage.validationFailed')} {SMSDeliveryFailureMessage} + {translate('smsDeliveryFailurePage.validationFailed')} {timeData && translate('smsDeliveryFailurePage.pleaseWaitBeforeTryingAgain', {timeData})}