chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s
Deploy Canina / deploy (push) Failing after 29s
This commit is contained in:
1 parent
4659a7b1de
commit
9f11d8fb2d
98 files changed
+1272
-1009
No files matched your search
@@ -1,8 +1,8 @@
|
||||
"use client";
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import { X, User, Building2, Heart, ShieldCheck, Phone, Key, LogIn, ArrowRight, RefreshCw, Lock, Upload, CheckCircle2 } from "lucide-react";
|
||||
import { useUserStore, UserRole } from "../lib/store/userStore";
|
||||
import { X, Building2, ShieldCheck, Phone, Key, LogIn, ArrowRight, RefreshCw, Lock, Upload, CheckCircle2 } from "lucide-react";
|
||||
import { useUserStore } from "../lib/store/userStore";
|
||||
import { authService } from "../lib/services/authService";
|
||||
import { toast } from "sonner";
|
||||
import { toPersian } from "../lib/utils";
|
||||
@@ -13,9 +13,8 @@ interface AuthModalProps {
|
||||
}
|
||||
|
||||
export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
const { setRole, setLoggedIn, fetchProfile } = useUserStore();
|
||||
const { fetchProfile } = useUserStore();
|
||||
const [view, setView] = useState<"login" | "register" | "otp-phone" | "otp" | "forgot-password" | "forgot-otp" | "reset-password" | "wholesale-request">("login");
|
||||
const [isWholesaleRequest, setIsWholesaleRequest] = useState(false);
|
||||
const [medicalLicense, setMedicalLicense] = useState("");
|
||||
const [businessName, setBusinessName] = useState("");
|
||||
const [documentUploaded, setDocumentUploaded] = useState(false);
|
||||
@@ -42,16 +41,18 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
// Reset modal state on open/close
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
setView("login");
|
||||
setPhoneNumber("");
|
||||
setPassword("");
|
||||
setNewPassword("");
|
||||
setEmail("");
|
||||
setFirstName("");
|
||||
setLastName("");
|
||||
setOtpCode("");
|
||||
setIsLoading(false);
|
||||
setCountdown(0);
|
||||
Promise.resolve().then(() => {
|
||||
setView("login");
|
||||
setPhoneNumber("");
|
||||
setPassword("");
|
||||
setNewPassword("");
|
||||
setEmail("");
|
||||
setFirstName("");
|
||||
setLastName("");
|
||||
setOtpCode("");
|
||||
setIsLoading(false);
|
||||
setCountdown(0);
|
||||
});
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
@@ -75,8 +76,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
toast.success("با موفقیت وارد شدید");
|
||||
onClose();
|
||||
}
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "خطا در ورود");
|
||||
} catch (err: unknown) {
|
||||
const errObj = err as { message?: string };
|
||||
toast.error(errObj.message || "خطا در ورود");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -96,8 +98,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
toast.success("ثبتنام با موفقیت انجام شد");
|
||||
onClose();
|
||||
}
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "خطا در ثبتنام");
|
||||
} catch (err: unknown) {
|
||||
const errObj = err as { message?: string };
|
||||
toast.error(errObj.message || "خطا در ثبتنام");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -114,15 +117,17 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
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("کد تایید پیامک شد");
|
||||
}
|
||||
setView("otp");
|
||||
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);
|
||||
}
|
||||
@@ -144,8 +149,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
toast.success("ورود موفقیتآمیز بود");
|
||||
onClose();
|
||||
}
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "کد تایید نامعتبر است");
|
||||
} catch (err: unknown) {
|
||||
const errObj = err as { message?: string };
|
||||
toast.error(errObj.message || "کد تایید نامعتبر است");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -158,8 +164,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
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);
|
||||
}
|
||||
@@ -175,15 +182,17 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
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("کد بازیابی رمز پیامک شد");
|
||||
}
|
||||
setView("forgot-otp");
|
||||
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);
|
||||
}
|
||||
@@ -200,8 +209,9 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
// Verify OTP - if success, allow password reset
|
||||
await authService.verifyOtp(phoneNumber.trim(), otpCode.trim());
|
||||
setView("reset-password");
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "کد تایید نامعتبر است");
|
||||
} catch (err: unknown) {
|
||||
const errObj = err as { message?: string };
|
||||
toast.error(errObj.message || "کد تایید نامعتبر است");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -215,12 +225,12 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
}
|
||||
setIsLoading(true);
|
||||
try {
|
||||
// Use authService to update password after OTP verification
|
||||
await authService.updateProfile({ password: newPassword } as any);
|
||||
await authService.updateProfile({ password: newPassword } as unknown as Parameters<typeof authService.updateProfile>[0]);
|
||||
toast.success("رمز عبور با موفقیت تغییر یافت");
|
||||
setView("login");
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "خطا در تغییر رمز");
|
||||
} catch (err: unknown) {
|
||||
const errObj = err as { message?: string };
|
||||
toast.error(errObj.message || "خطا در تغییر رمز");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -749,7 +759,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
|
||||
{countdown > 0 ? (
|
||||
<p className="text-xs font-bold text-medical-gray-400 text-center">ارسال مجدد پس از {toPersian(countdown)} ثانیه</p>
|
||||
) : (
|
||||
<button type="button" onClick={handleForgotSendOtp as any} disabled={isLoading} className="text-xs font-black text-canina-blue hover:underline flex items-center gap-1.5 justify-center mx-auto">
|
||||
<button type="button" onClick={handleForgotSendOtp} disabled={isLoading} className="text-xs font-black text-canina-blue hover:underline flex items-center gap-1.5 justify-center mx-auto">
|
||||
<RefreshCw className="w-3.5 h-3.5" />ارسال مجدد
|
||||
</button>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user