diff --git a/resources/scripts/components/dashboard/forms/SetupTwoFactorModal.tsx b/resources/scripts/components/dashboard/forms/SetupTwoFactorModal.tsx index 619067486..eb8e1a890 100644 --- a/resources/scripts/components/dashboard/forms/SetupTwoFactorModal.tsx +++ b/resources/scripts/components/dashboard/forms/SetupTwoFactorModal.tsx @@ -6,7 +6,6 @@ import getTwoFactorTokenUrl from '@/api/account/getTwoFactorTokenUrl'; import enableAccountTwoFactor from '@/api/account/enableAccountTwoFactor'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; -import { httpErrorToHuman } from '@/api/http'; import FlashMessageRender from '@/components/FlashMessageRender'; import Field from '@/components/elements/Field'; import tw from 'twin.macro'; @@ -22,20 +21,18 @@ export default ({ onDismissed, ...props }: RequiredModalProps) => { const [ recoveryTokens, setRecoveryTokens ] = useState([]); const updateUserData = useStoreActions((actions: Actions) => actions.user.updateUserData); - const { addError, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes); + const { clearAndAddHttpError } = useStoreActions((actions: Actions) => actions.flashes); useEffect(() => { - clearFlashes('account:two-factor'); getTwoFactorTokenUrl() .then(setToken) .catch(error => { console.error(error); - addError({ message: httpErrorToHuman(error), key: 'account:two-factor' }); + clearAndAddHttpError({ error: error, key: 'account:two-factor' }); }); }, []); const submit = ({ code }: Values, { setSubmitting }: FormikHelpers) => { - clearFlashes('account:two-factor'); enableAccountTwoFactor(code) .then(tokens => { setRecoveryTokens(tokens); @@ -43,7 +40,7 @@ export default ({ onDismissed, ...props }: RequiredModalProps) => { .catch(error => { console.error(error); - addError({ message: httpErrorToHuman(error), key: 'account:two-factor' }); + clearAndAddHttpError({ error: error, key: 'account:two-factor' }); }) .then(() => setSubmitting(false)); };