Added notifications to 2FA and fixed state

This commit is contained in:
Vladyslav Matsiiako
2023-02-19 20:11:24 -08:00
parent 2bdb20f42f
commit d5bc377e3d
2 changed files with 19 additions and 4 deletions
+6 -2
View File
@@ -60,6 +60,7 @@ export default function MFAStep({
}): JSX.Element {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
const [isLoadingResend, setIsLoadingResend] = useState(false);
const [mfaCode, setMfaCode] = useState('');
const [triesLeft, setTriesLeft] = useState<number | undefined>(undefined);
@@ -103,9 +104,12 @@ export default function MFAStep({
const handleResendMfaCode = async () => {
try {
setIsLoadingResend(true);
await sendMfaToken.mutateAsync({ email });
setIsLoadingResend(false);
} catch (err) {
console.error(err);
setIsLoadingResend(false);
}
}
@@ -137,13 +141,13 @@ export default function MFAStep({
<span className="text-bunker-400">{t('mfa:step2-resend-alert')}</span>
<u
className={`font-normal ${
isLoading
isLoadingResend
? 'text-bunker-400'
: 'text-primary-700 hover:text-primary duration-200'
}`}
>
<button disabled={isLoading} onClick={() => handleResendMfaCode()} type="button">
{isLoading
{isLoadingResend
? t('mfa:step2-resend-progress')
: t('mfa:step2-resend-submit')}
</button>