diff --git a/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx b/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx index 170cd01d3..d4f986942 100644 --- a/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx +++ b/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx @@ -7,7 +7,6 @@ import { object, string } from 'yup'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import disableAccountTwoFactor from '@/api/account/disableAccountTwoFactor'; -import { httpErrorToHuman } from '@/api/http'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; @@ -16,11 +15,10 @@ interface Values { } export default ({ ...props }: RequiredModalProps) => { - const { addError, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes); + const { clearAndAddHttpError } = useStoreActions((actions: Actions) => actions.flashes); const updateUserData = useStoreActions((actions: Actions) => actions.user.updateUserData); const submit = ({ password }: Values, { setSubmitting }: FormikHelpers) => { - clearFlashes('account:two-factor'); disableAccountTwoFactor(password) .then(() => { updateUserData({ useTotp: false }); @@ -29,7 +27,7 @@ export default ({ ...props }: RequiredModalProps) => { .catch(error => { console.error(error); - addError({ message: httpErrorToHuman(error), key: 'account:two-factor' }); + clearAndAddHttpError({ error: error, key: 'account:two-factor' }); setSubmitting(false); }); };