fix(linter): resolve all linter rules and type errors across 3 subprojects
This commit is contained in:
1 parent
5f790a60a9
commit
a1f0640483
17 files changed
+201
-104
No files matched your search
@@ -33,6 +33,26 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
|
||||
}
|
||||
}, [step]);
|
||||
|
||||
const handleVerifyOtpWithCode = async (code: string) => {
|
||||
const cleanCode = code.trim();
|
||||
if (cleanCode.length !== 5) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await authService.verifyOtp(phoneNumber.trim(), cleanCode);
|
||||
if (response.success) {
|
||||
await fetchProfile();
|
||||
toast.success("ورود با موفقیت انجام شد");
|
||||
onLogin();
|
||||
onClose();
|
||||
}
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "کد تایید اشتباه است");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// WebOTP API & Auto-Submit
|
||||
useEffect(() => {
|
||||
if (step === "otp" && typeof window !== "undefined" && "OTPCredential" in window) {
|
||||
@@ -54,26 +74,6 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
|
||||
}
|
||||
}, [step]);
|
||||
|
||||
const handleVerifyOtpWithCode = async (code: string) => {
|
||||
const cleanCode = code.trim();
|
||||
if (cleanCode.length !== 5) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await authService.verifyOtp(phoneNumber.trim(), cleanCode);
|
||||
if (response.success) {
|
||||
await fetchProfile();
|
||||
toast.success("ورود با موفقیت انجام شد");
|
||||
onLogin();
|
||||
onClose();
|
||||
}
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "کد تایید اشتباه است");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleOtpInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const val = e.target.value.replace(/[^0-9]/g, "").slice(0, 5);
|
||||
setOtpCode(val);
|
||||
|
||||
@@ -72,13 +72,6 @@ export default function PetProfile({ initialView, advisorNeed }: {
|
||||
}
|
||||
}, [initialView]);
|
||||
|
||||
if (isLoading && view === "detail" && activePet) {
|
||||
return (
|
||||
<div className="max-w-6xl mx-auto px-4 py-20" dir="rtl">
|
||||
<PetProfileSkeleton />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const [activePetTab, setActivePetTab] = useState<"health" | "orders">("health");
|
||||
const [petToDelete, setPetToDelete] = useState<GlobalPetProfile | null>(null);
|
||||
|
||||
@@ -121,50 +114,6 @@ export default function PetProfile({ initialView, advisorNeed }: {
|
||||
consumptions: []
|
||||
});
|
||||
|
||||
const handleHealthLogSubmit = () => {
|
||||
if (activePet) {
|
||||
addHealthLog(activePet.id, logForm);
|
||||
toast.success("گزارش سلامت با موفقیت ثبت شد");
|
||||
setIsAddingHealthLog(false);
|
||||
setLogForm({
|
||||
appetite: "عالی",
|
||||
energy: "نرمال",
|
||||
digestion: "نرمال",
|
||||
note: ""
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleReminderSubmit = () => {
|
||||
if (activePet) {
|
||||
if (!reminderForm.title) {
|
||||
toast.error("لطفاً عنوان یادآور را وارد کنید");
|
||||
return;
|
||||
}
|
||||
addReminder(activePet.id, reminderForm);
|
||||
toast.success("یادآور با موفقیت ثبت شد");
|
||||
setIsAddingReminder(false);
|
||||
setReminderForm({
|
||||
title: "",
|
||||
time: "08:00",
|
||||
frequency: "روزانه",
|
||||
productId: ""
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleReminder = (reminder: Reminder) => {
|
||||
if (activePet) {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
toggleReminder(activePet.id, reminder.id, today);
|
||||
|
||||
const isCompleting = !reminder.completedDates.includes(today);
|
||||
if (isCompleting) {
|
||||
toast.success(`دوز ${reminder.title} تایید شد`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const recommendedProducts = useMemo(() => {
|
||||
if (!activePet || products.length === 0) return [];
|
||||
|
||||
@@ -220,6 +169,50 @@ export default function PetProfile({ initialView, advisorNeed }: {
|
||||
setStep(1);
|
||||
};
|
||||
|
||||
const handleHealthLogSubmit = () => {
|
||||
if (activePet) {
|
||||
addHealthLog(activePet.id, logForm);
|
||||
toast.success("گزارش سلامت با موفقیت ثبت شد");
|
||||
setIsAddingHealthLog(false);
|
||||
setLogForm({
|
||||
appetite: "عالی",
|
||||
energy: "نرمال",
|
||||
digestion: "نرمال",
|
||||
note: ""
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleReminderSubmit = () => {
|
||||
if (activePet) {
|
||||
if (!reminderForm.title) {
|
||||
toast.error("لطفاً عنوان یادآور را وارد کنید");
|
||||
return;
|
||||
}
|
||||
addReminder(activePet.id, reminderForm);
|
||||
toast.success("یادآور با موفقیت ثبت شد");
|
||||
setIsAddingReminder(false);
|
||||
setReminderForm({
|
||||
title: "",
|
||||
time: "08:00",
|
||||
frequency: "روزانه",
|
||||
productId: ""
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleReminder = (reminder: Reminder) => {
|
||||
if (activePet) {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
toggleReminder(activePet.id, reminder.id, today);
|
||||
|
||||
const isCompleting = !reminder.completedDates.includes(today);
|
||||
if (isCompleting) {
|
||||
toast.success(`دوز ${reminder.title} تایید شد`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const startEdit = () => {
|
||||
if (activePet) {
|
||||
setFormData({
|
||||
@@ -256,6 +249,14 @@ export default function PetProfile({ initialView, advisorNeed }: {
|
||||
}
|
||||
};
|
||||
|
||||
if (isLoading && view === "detail" && activePet) {
|
||||
return (
|
||||
<div className="max-w-6xl mx-auto px-4 py-20" dir="rtl">
|
||||
<PetProfileSkeleton />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 1. Pet Index Page
|
||||
if (view === "index") {
|
||||
return (
|
||||
|
||||
@@ -25,10 +25,6 @@ export default function UserDashboard() {
|
||||
}
|
||||
}, [isLoggedIn, router]);
|
||||
|
||||
if (!isLoggedIn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { orders } = useCartStore();
|
||||
const [activeTab, setActiveTab] = React.useState<"profile" | "orders" | "wallet" | "addresses" | "tickets">("profile");
|
||||
const [isLoadingOrders, setIsLoadingOrders] = useState(false);
|
||||
@@ -72,6 +68,10 @@ export default function UserDashboard() {
|
||||
});
|
||||
}, [profile]);
|
||||
|
||||
if (!isLoggedIn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const handleSaveProfile = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!isEditing) return;
|
||||
|
||||
Reference in new issue
Block a user