Merge pull request #17639 from mozilla/FXA-10392

fix(settings): Fix error message if account deletion fails
This commit is contained in:
Valerie Pomerleau 2024-09-18 16:44:27 -07:00 коммит произвёл GitHub
Родитель a43a9ca37b 0a0f4ac4e1
Коммит 67c62d09c7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 5 добавлений и 7 удалений

Просмотреть файл

@ -18,8 +18,9 @@ import { Localized } from '@fluent/react';
import { AuthUiErrors } from '../../../lib/auth-errors/auth-errors';
import { hardNavigate } from 'fxa-react/lib/utils';
import LinkExternal from 'fxa-react/components/LinkExternal';
import { getErrorFtlId } from '../../../lib/error-utils';
import { getLocalizedErrorMessage } from '../../../lib/error-utils';
import GleanMetrics from '../../../lib/glean';
import { useFtlMsgResolver } from '../../../models/hooks';
type FormData = {
password: string;
@ -104,6 +105,7 @@ export const PageDeleteAccount = (_: RouteComponentProps) => {
);
const navigate = useNavigate();
const alertBar = useAlertBar();
const ftlMsgResolver = useFtlMsgResolver();
const goHome = useCallback(() => window.history.back(), []);
const account = useAccount();
@ -143,11 +145,7 @@ export const PageDeleteAccount = (_: RouteComponentProps) => {
);
hardNavigate('/', { delete_account_success: true }, true);
} catch (e) {
const localizedError = l10n.getString(
getErrorFtlId(AuthUiErrors.INCORRECT_PASSWORD),
null,
AuthUiErrors.INCORRECT_PASSWORD.message
);
const localizedError = getLocalizedErrorMessage(ftlMsgResolver, e);
if (e.errno === AuthUiErrors.INCORRECT_PASSWORD.errno) {
setErrorText(localizedError);
setValue('password', '');
@ -157,7 +155,7 @@ export const PageDeleteAccount = (_: RouteComponentProps) => {
}
}
},
[account, l10n, setErrorText, setValue, alertBar]
[account, setErrorText, setValue, alertBar, ftlMsgResolver]
);
const handleConfirmChange =