From b630795e48ca5f6e8ffc35e3c49ffdfb5bc32ee2 Mon Sep 17 00:00:00 2001 From: Parth <143504541+parrth20@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:55:50 +0530 Subject: [PATCH] refactor(settings): replace hardcoded password verify copy with i18n keys (#1143) --- .../settings/AccountXpubsDialog.tsx | 1 + src/components/settings/SeedPhraseDialog.tsx | 1 + .../utils/PasswordVerificationForm.tsx | 27 ++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/settings/AccountXpubsDialog.tsx b/src/components/settings/AccountXpubsDialog.tsx index 3ed13a60..5d0cbdde 100644 --- a/src/components/settings/AccountXpubsDialog.tsx +++ b/src/components/settings/AccountXpubsDialog.tsx @@ -285,6 +285,7 @@ export const AccountXpubsDialog = ({ { setTimeLeft(autoCloseTimeout) setPasswordVerifiedAt(Date.now()) diff --git a/src/components/settings/SeedPhraseDialog.tsx b/src/components/settings/SeedPhraseDialog.tsx index 22001bc5..01f47396 100644 --- a/src/components/settings/SeedPhraseDialog.tsx +++ b/src/components/settings/SeedPhraseDialog.tsx @@ -114,6 +114,7 @@ export const SeedPhraseDialog = ({ { setTimeLeft(autoCloseTimeout) setPasswordVerifiedAt(Date.now()) diff --git a/src/components/utils/PasswordVerificationForm.tsx b/src/components/utils/PasswordVerificationForm.tsx index 0019a092..7d59e329 100644 --- a/src/components/utils/PasswordVerificationForm.tsx +++ b/src/components/utils/PasswordVerificationForm.tsx @@ -18,7 +18,14 @@ type PasswordVerificationFormValues = { const debouncedHashPassword = debounce(hashPassword, 210) -const passwordVerificationFormSchema = (walletFileName: WalletFileName, hashedPassword: string, t: TFunction) => { +type PasswordVerificationI18nKeyPrefix = 'settings.seed_modal.verification' | 'settings.xpubs_modal.verification' + +const passwordVerificationFormSchema = ( + walletFileName: WalletFileName, + hashedPassword: string, + t: TFunction, + i18nKeyPrefix: PasswordVerificationI18nKeyPrefix, +) => { return yup .object({ password: yup @@ -28,13 +35,13 @@ const passwordVerificationFormSchema = (walletFileName: WalletFileName, hashedPa try { const hashed = await debouncedHashPassword(value, walletFileName) if (hashedPassword !== hashed) { - const errorMessage = t(/*TODO: i18n*/ 'Incorrect password. Please try again.') + const errorMessage = t(`${i18nKeyPrefix}.text_error_password_incorrect`) return new yup.ValidationError(errorMessage, undefined, 'password', undefined, true) } return true } catch (error: unknown) { const reason = (error instanceof Error ? error.message : undefined) || t('global.errors.reason_unknown') - const errorMessage = t(/*TODO: i18n*/ 'Error while verifying given password. {{ reason }}', { reason }) + const errorMessage = t(`${i18nKeyPrefix}.text_error`, { reason }) throw new yup.ValidationError(errorMessage, undefined, 'password', undefined, true) } }), @@ -49,6 +56,7 @@ type PasswordVerificationFormProps = { onCancel?: () => void | Promise className?: string disabled?: boolean + i18nKeyPrefix: PasswordVerificationI18nKeyPrefix } export const PasswordVerificationForm = ({ @@ -58,13 +66,14 @@ export const PasswordVerificationForm = ({ disabled, className, onCancel, + i18nKeyPrefix, }: PasswordVerificationFormProps) => { const { t } = useTranslation() const [showPassword, setShowPassword] = useState(false) const schema = useMemo(() => { - return passwordVerificationFormSchema(walletFileName, hashedPassword, t) - }, [walletFileName, hashedPassword, t]) + return passwordVerificationFormSchema(walletFileName, hashedPassword, t, i18nKeyPrefix) + }, [walletFileName, hashedPassword, t, i18nKeyPrefix]) const { register, @@ -82,7 +91,7 @@ export const PasswordVerificationForm = ({
void doOnSubmit(event)} className={cn('flex flex-col gap-4', className)} noValidate>
- {t(/* TODO: i18n */ 'Password')} + {t(`${i18nKeyPrefix}.label_password`)}