Skip to content
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
28 changes: 28 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
28 changes: 28 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 16 additions & 1 deletion src/pages/signin/SMSDeliveryFailurePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,22 @@ function SMSDeliveryFailurePage() {
}, [credentials?.login]);

const SMSDeliveryFailureMessage = account?.smsDeliveryFailureStatus?.message;

type TimeData = {
days?: number;
hours?: number;
minutes?: number;
};

const timeData = useMemo<TimeData | null>(() => {
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]);
Expand All @@ -48,7 +63,7 @@ function SMSDeliveryFailurePage() {
<View style={[styles.mv3, styles.flexRow]}>
<View style={[styles.flex1]}>
<Text>
{translate('smsDeliveryFailurePage.validationFailed')} {SMSDeliveryFailureMessage}
{translate('smsDeliveryFailurePage.validationFailed')} {timeData && translate('smsDeliveryFailurePage.pleaseWaitBeforeTryingAgain', {timeData})}
</Text>
</View>
</View>
Expand Down