diff --git a/frontend/application/components/SmartAdvisor.tsx b/frontend/application/components/SmartAdvisor.tsx index 02408d22..a77ef8d4 100644 --- a/frontend/application/components/SmartAdvisor.tsx +++ b/frontend/application/components/SmartAdvisor.tsx @@ -25,19 +25,24 @@ interface SmartAdvisorProps { onComplete?: (data: any) => void; } -const MEDICAL_OPTIONS = [ +const CURRENT_SYMPTOMS = [ { id: "joint_pain", label: "درد مفاصل و لنگیدن", condition: "درد مفاصل" }, - { id: "joint_surgery", label: "جراحی مفاصل", condition: "جراحی مفاصل" }, - { id: "puppy_growth", label: "رشد سریع توله‌سگ", condition: "رشد سریع توله‌سگ" }, - { id: "tendon", label: "ضعف تاندون و رباط", condition: "تاندون" }, - { id: "diarrhea", label: "اسهال و یبوست", condition: "اسهال" }, - { id: "weakness", label: "ضعف بعد از بیماری", condition: "ضعف بعد از بیماری" }, { id: "hair_loss", label: "ریزش مو، خارش و خشکی پوست", condition: "ریزش مو" }, + { id: "diarrhea", label: "اسهال، یبوست و مشکلات گوارشی", condition: "اسهال" }, { id: "appetite", label: "بی‌اشتهایی و کاهش وزن", condition: "بی‌اشتهایی" }, { id: "dental", label: "جرم دندان و بوی بد دهان", condition: "جرم دندان" }, - { id: "eye", label: "مشکلات یا شستشوی چشم", condition: "چشم" }, - { id: "recent_birth", label: "زایمان اخیر", condition: "زایمان اخیر" }, - { id: "pregnancy", label: "بارداری و شیردهی", condition: "بارداری" }, + { id: "eye", label: "ترشحات یا مشکلات چشم", condition: "چشم" }, + { id: "puppy_growth", label: "رشد سریع و تعادل استخوانی", condition: "رشد سریع توله‌سگ" }, + { id: "tendon", label: "سفتی عضلات و ضعف تاندون", condition: "تاندون" }, +]; + +const MEDICAL_HISTORIES = [ + { id: "joint_surgery", label: "سابقه جراحی مفاصل/استخوان", condition: "جراحی مفاصل" }, + { id: "recent_birth", label: "زایمان اخیر / شیردهی فعال", condition: "زایمان اخیر" }, + { id: "pregnancy", label: "دوران بارداری", condition: "بارداری" }, + { id: "weakness", label: "ضعف بعد از بیماری / نقاهت", condition: "ضعف بعد از بیماری" }, + { id: "heart", label: "نارسایی یا حساسیت قلبی", condition: "نارسایی قلبی" }, + { id: "parasite", label: "سابقه آلودگی انگلی", condition: "آلودگی انگلی" }, ]; export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorProps & { rules?: any[] }) { @@ -47,17 +52,6 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro const { addPet, setActivePet } = usePetStore(); const texts = useSettingsStore(state => state.texts); const getText = useSettingsStore(state => state.getText); - 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); @@ -73,7 +67,8 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro const [weight, setWeight] = useState(10); const [activityLevel, setActivityLevel] = useState<"کم" | "متوسط" | "زیاد">("متوسط"); - // Step 3 Data + // Step 3 Data (Symptoms) & Step 4 Data (History) + const [currentSymptoms, setCurrentSymptoms] = useState([]); const [medicalConditions, setMedicalConditions] = useState([]); const handleNext = () => { @@ -90,8 +85,9 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro const handleBack = () => setStep(s => s - 1); const handleSubmit = () => { + const combinedConditions = Array.from(new Set([...currentSymptoms, ...medicalConditions])); const data = { - name, type, breed, age, weight, activityLevel, medicalConditions + name, type, breed, age, weight, activityLevel, medicalConditions: combinedConditions }; if (onComplete) { onComplete(data); @@ -120,7 +116,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro {getText('advisor_badge', "تکنولوژی پایش هوشمند")}

{getText('advisor_title', "دستیار سلامت کانینا")}

-

{getText('advisor_subtitle', "فقط چند قدم تا صدور شناسنامه هوشمند و دریافت پیشنهادات تخصصی")}

+

{getText('advisor_subtitle', "فقط ۴ قدم تا صدور شناسنامه هوشمند و دریافت پیشنهادات تخصصی")}

@@ -129,7 +125,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
@@ -283,7 +279,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro onClick={handleNext} className="flex-[2] py-6 bg-medical-gray-900 text-white rounded-3xl font-black text-lg hover:bg-canina-blue focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-medical-gray-900/10 flex items-center justify-center gap-3 font-vazir min-h-[48px]" > - {getText('advisor_next_final', "گام نهایی سلامت")} + {getText('advisor_next_symptoms', "بررسی علائم بالینی فعلی")} @@ -299,12 +295,63 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro className="space-y-8" >
-

{getText('advisor_step3_title', "گام آخر: سوابق و حساسیت‌ها")}

-

{getText('advisor_step3_desc', "در صورت وجود هر یک از موارد زیر، آن را تیک بزنید")}

+

{getText('advisor_step3_symptoms_title', "گام سوم: علائم بالینی فعلی")}

+

{getText('advisor_step3_symptoms_desc', "آیا همدم شما در حال حاضر هیچ‌کدام از علائم زیر را تجربه می‌کند؟")}

- {medicalOptions.map((opt) => ( + {CURRENT_SYMPTOMS.map((opt) => ( + + ))} +
+ +
+ + +
+ + )} + + {step === 4 && ( + +
+

{getText('advisor_step4_history_title', "گام چهارم: سوابق پزشکی و جراحی")}

+

{getText('advisor_step4_history_desc', "در صورت وجود سابقه جراحی، بارداری یا نارسایی، آن را مشخص کنید")}

+
+ +
+ {MEDICAL_HISTORIES.map((opt) => (