fix(pets): resolve pet registration flow, missing assets, 401 guard, and add none option to symptoms
Deploy Canina / deploy (push) Successful in 1m51s
Deploy Canina / deploy (push) Successful in 1m51s
This commit is contained in:
1 parent
93126c1724
commit
cc8f52cb3f
19 files changed
+115704
-115146
No files matched your search
@@ -4,7 +4,7 @@ import { useEffect } from "react";
|
||||
import Header from "../components/Header";
|
||||
import Footer from "../components/Footer";
|
||||
import { NetworkBanner } from "../components/NetworkBanner";
|
||||
import { Toaster } from "sonner";
|
||||
import { Toaster, toast } from "sonner";
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
|
||||
import CartDrawer from "../components/CartDrawer";
|
||||
@@ -121,8 +121,31 @@ export default function ClientLayout({ children }: { children: React.ReactNode }
|
||||
setLoginModalOpen(false);
|
||||
clearAdvisorData();
|
||||
}}
|
||||
onLogin={() => {
|
||||
onLogin={async () => {
|
||||
setLoginModalOpen(false);
|
||||
if (advisorData) {
|
||||
try {
|
||||
const { usePetStore } = await import("../lib/store/usePetStore");
|
||||
const petToSave = {
|
||||
name: String(advisorData.name || "پت من"),
|
||||
type: (advisorData.type as "سگ" | "گربه") || "سگ",
|
||||
breed: String(advisorData.breed || ""),
|
||||
age: Number(advisorData.age || 1),
|
||||
weight: Number(advisorData.weight || 10),
|
||||
activityLevel: (advisorData.activityLevel as "کم" | "متوسط" | "زیاد") || "متوسط",
|
||||
medicalConditions: Array.isArray(advisorData.medicalConditions) ? advisorData.medicalConditions : [],
|
||||
reminders: [],
|
||||
logs: [],
|
||||
consumptions: []
|
||||
};
|
||||
await usePetStore.getState().addPet(petToSave);
|
||||
toast.success(`شناسنامه سلامت ${petToSave.name} با موفقیت ثبت شد`);
|
||||
clearAdvisorData();
|
||||
router.push('/profile');
|
||||
} catch (e) {
|
||||
console.error("Auto pet registration after login failed:", e);
|
||||
}
|
||||
}
|
||||
}}
|
||||
petName={advisorData?.name as string | undefined}
|
||||
isAdvisorContext={!!advisorData}
|
||||
|
||||
Reference in new issue
Block a user