"use client"; import React, { useState } from "react"; import { motion, AnimatePresence } from "motion/react"; import { useSettingsStore } from "../lib/store/settingsStore"; import { Dog, Cat, ChevronLeft, ChevronRight, ShieldCheck, Activity, Bone, Sparkles, Pill, Sparkle } from "lucide-react"; import { toPersian, cn } from "../lib/utils"; import { useRouter } from "next/navigation"; import { useUserStore } from "../lib/store/userStore"; import { useUIStore } from "../lib/store/uiStore"; import { usePetStore } from "../lib/store/usePetStore"; interface SmartAdvisorProps { onComplete?: (data: any) => void; } const MEDICAL_OPTIONS = [ { id: "joint_surgery", label: "جراحی مفاصل", condition: "جراحی مفاصل" }, { id: "recent_birth", label: "زایمان اخیر", condition: "زایمان اخیر" }, { id: "pregnancy", label: "بارداری", condition: "بارداری" }, { id: "digestion", label: "مشکلات گوارشی", condition: "مشکلات گوارشی" }, { id: "hair_loss", label: "ریزش موی شدید", condition: "ریزش موی شدید" }, { id: "appetite", label: "بی‌اشتهایی", condition: "بی‌اشتهایی" }, ]; export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorProps & { rules?: any[] }) { const router = useRouter(); const { isLoggedIn } = useUserStore(); const setLoginModalOpen = useUIStore(state => state.setLoginModalOpen); const { addPet, setActivePet } = usePetStore(); const texts = useSettingsStore(state => state.texts); const medicalOptions = React.useMemo(() => { const jsonStr = texts['medical_options']; if (jsonStr) { try { return JSON.parse(jsonStr) as typeof MEDICAL_OPTIONS; } catch (e) { console.error("Failed to parse medical_options JSON:", e); } } return MEDICAL_OPTIONS; }, [texts]); const [step, setStep] = useState(1); // Step 1 Data const [name, setName] = useState(""); const [type, setType] = useState<"سگ" | "گربه">("سگ"); const [breed, setBreed] = useState(""); // Step 2 Data const [age, setAge] = useState(3); const [weight, setWeight] = useState(10); const [activityLevel, setActivityLevel] = useState<"کم" | "متوسط" | "زیاد">("متوسط"); // Step 3 Data const [medicalConditions, setMedicalConditions] = useState([]); const handleNext = () => setStep(s => s + 1); const handleBack = () => setStep(s => s - 1); const handleSubmit = () => { const data = { name, type, breed, age, weight, activityLevel, medicalConditions }; if (onComplete) { onComplete(data); } else { if (!isLoggedIn) { setLoginModalOpen(true, data); } else { const newPet: any = { ...data, id: Date.now().toString(), reminders: [], logs: [], consumptions: [] }; addPet(newPet); setActivePet(newPet.id); router.push('/profile'); } } }; return (
تکنولوژی پایش هوشمند

دستیار سلامت کانی‌نا

فقط چند قدم تا صدور شناسنامه هوشمند و دریافت پیشنهادات تخصصی

{/* Progress Indicator */}
{step === 1 && (

گام اول: هویت بصری

همدم شما رو با چه اسمی صدا می‌زنید؟

setName(e.target.value)} placeholder="لوسی، تدی..." className="w-full bg-white border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canina-blue/20 outline-none font-black text-lg font-vazir" />
setBreed(e.target.value)} placeholder="ژرمن، پرشین..." className="w-full bg-white border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canina-blue/20 outline-none font-bold font-vazir" />
)} {step === 2 && (

گام دوم: پایش فیزیکی

اطلاعات فیزیکی دقیق به دوزبندی صحیح مکمل‌ها کمک می‌کند

{toPersian(age.toString())}
{toPersian(weight.toString())}
{["کم", "متوسط", "زیاد"].map(level => ( ))}
)} {step === 3 && (

گام آخر: سوابق و حساسیت‌ها

در صورت وجود هر یک از موارد زیر، آن را تیک بزنید

{medicalOptions.map((opt) => ( ))}
)}
); }