From 5d2e05184fdf1f11d2b612c10af5f2733ec18459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=B1=D8=B2=D8=A7=D8=AF=20=D9=82=D8=AF=D8=B1?= =?UTF-8?q?=D8=AA=DB=8C?= Date: Sun, 27 Jul 2025 15:34:59 +0330 Subject: [PATCH] fix: toast color change on close fixed (new state for loading) --- .../authentication/components/OtpVerifyForm.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/features/authentication/components/OtpVerifyForm.tsx b/src/features/authentication/components/OtpVerifyForm.tsx index e4ddd1f..0748f42 100644 --- a/src/features/authentication/components/OtpVerifyForm.tsx +++ b/src/features/authentication/components/OtpVerifyForm.tsx @@ -23,9 +23,9 @@ export function OtpVerifyForm({ }: OtpVerifyFormProps) { const [otpCode, setOtpCode] = useState(''); const [otpDigitInvalid, setOtpDigitInvalid] = useState(false); - const [verifyStatus, setVerifyStatus] = useState< - 'loading' | 'success' | 'failed' - >(); + const [verifyStatus, setVerifyStatus] = useState<'success' | 'failed'>(); + const [verifyStatusLoading, setVerifyStatusLoading] = + useState(false); const [verifyAlertOpen, setVerifyAlertOpen] = useState(false); const { t } = useTranslation('authentication'); @@ -40,13 +40,14 @@ export function OtpVerifyForm({ setOtpDigitInvalid(true); } else { setOtpDigitInvalid(false); - setVerifyStatus('loading'); - // Change setTimeout to api call + setVerifyStatusLoading(true); + // Change setTimeout to api call setTimeout(() => { setVerifyAlertOpen(true); setVerifyStatus('success'); onOTPVerified(otpCode); + setVerifyStatusLoading(false); }, 1000); } }; @@ -128,7 +129,7 @@ export function OtpVerifyForm({ onChange={(value) => handleDigitInputChange(value as string[])} /> -