chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s

This commit is contained in:
parsa committed 2026-08-07 07:39:26 +03:30
1 parent 4659a7b1de
commit 9f11d8fb2d
98 files changed
+1272 -1009

No files matched your search

+31 -20
View File
@@ -33,9 +33,12 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
}
}, [step]);
const handleVerifyOtpWithCode = async (code: string) => {
const handleVerifyOtpWithCode = React.useCallback(async (code: string) => {
const cleanCode = code.trim();
if (cleanCode.length !== 5) return;
if (cleanCode.length !== 5) {
toast.error("کد تایید باید ۵ رقم باشد");
return;
}
setIsLoading(true);
try {
@@ -46,33 +49,36 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
onLogin();
onClose();
}
} catch (err: any) {
toast.error(err.message || "کد تایید اشتباه است");
} catch (err: unknown) {
const errObj = err as { message?: string };
toast.error(errObj.message || "کد تایید اشتباه است");
} finally {
setIsLoading(false);
}
};
}, [phoneNumber, fetchProfile, onLogin, onClose]);
// WebOTP API & Auto-Submit
useEffect(() => {
if (step === "otp" && typeof window !== "undefined" && "OTPCredential" in window) {
const ac = new AbortController();
(navigator as any).credentials
.get({
const creds = (navigator as unknown as { credentials?: { get?: (opt: unknown) => Promise<{ code?: string }> } }).credentials;
if (creds && creds.get) {
creds.get({
otp: { transport: ["sms"] },
signal: ac.signal,
})
.then((otp: any) => {
.then((otp) => {
if (otp && otp.code) {
setOtpCode(otp.code);
handleVerifyOtpWithCode(otp.code);
}
})
.catch(() => {});
}
return () => ac.abort();
}
}, [step]);
}, [step, handleVerifyOtpWithCode]);
const handleOtpInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const val = e.target.value.replace(/[^0-9]/g, "").slice(0, 5);
@@ -94,11 +100,13 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
// Reset modal state when closed or opened
useEffect(() => {
if (!isOpen) {
setStep("phone");
setPhoneNumber("");
setOtpCode("");
setIsLoading(false);
setCountdown(0);
Promise.resolve().then(() => {
setStep("phone");
setPhoneNumber("");
setOtpCode("");
setIsLoading(false);
setCountdown(0);
});
}
}, [isOpen]);
@@ -121,15 +129,17 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
setIsLoading(true);
try {
const res = await authService.sendOtp(cleanPhone);
if ((res as any).code) {
toast.info(`کد تایید (تست): ${(res as any).code}`, { duration: 10000 });
const resObj = res as unknown as { code?: string };
if (resObj.code) {
toast.info(`کد تایید (تست): ${resObj.code}`, { duration: 10000 });
} else {
toast.success("کد تایید پیامک شد");
}
setStep("otp");
setCountdown(120); // 2 minutes cooldown
} catch (err: any) {
toast.error(err.message || "خطا در ارسال کد تایید");
} catch (err: unknown) {
const errObj = err as { message?: string };
toast.error(errObj.message || "خطا در ارسال کد تایید");
} finally {
setIsLoading(false);
}
@@ -147,8 +157,9 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
await authService.sendOtp(phoneNumber.trim());
toast.success("کد تایید جدید ارسال شد");
setCountdown(120);
} catch (err: any) {
toast.error(err.message || "خطا در ارسال مجدد کد تایید");
} catch (err: unknown) {
const errObj = err as { message?: string };
toast.error(errObj.message || "خطا در ارسال مجدد کد تایید");
} finally {
setIsLoading(false);
}