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
@@ -30,6 +30,7 @@ interface SmartAdvisorProps {
|
||||
}
|
||||
|
||||
const CURRENT_SYMPTOMS = [
|
||||
{ id: "none_symptom", label: "هیچکدام (سلامت کامل و بدون علامت)", condition: "هیچکدام (سلامت کامل)" },
|
||||
{ id: "joint_pain", label: "درد مفاصل و لنگیدن", condition: "درد مفاصل" },
|
||||
{ id: "hair_loss", label: "ریزش مو، خارش و خشکی پوست", condition: "ریزش مو" },
|
||||
{ id: "diarrhea", label: "اسهال، یبوست و مشکلات گوارشی", condition: "اسهال" },
|
||||
@@ -41,6 +42,7 @@ const CURRENT_SYMPTOMS = [
|
||||
];
|
||||
|
||||
const MEDICAL_HISTORIES = [
|
||||
{ id: "none_history", label: "هیچکدام (بدون سابقه بیماری و جراحی)", condition: "هیچکدام (بدون سابقه بیماری)" },
|
||||
{ id: "joint_surgery", label: "سابقه جراحی مفاصل/استخوان", condition: "جراحی مفاصل" },
|
||||
{ id: "recent_birth", label: "زایمان اخیر / شیردهی فعال", condition: "زایمان اخیر" },
|
||||
{ id: "pregnancy", label: "دوران بارداری", condition: "بارداری" },
|
||||
@@ -92,9 +94,41 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
const [weight, setWeight] = useState<number>(10);
|
||||
const [activityLevel, setActivityLevel] = useState<"کم" | "متوسط" | "زیاد">("متوسط");
|
||||
|
||||
// Step 3 Data (Symptoms) & Step 4 Data (History)
|
||||
const [currentSymptoms, setCurrentSymptoms] = useState<string[]>([]);
|
||||
const [medicalConditions, setMedicalConditions] = useState<string[]>([]);
|
||||
// Step 3 Data (Symptoms) & Step 4 Data (History) - default to none
|
||||
const [currentSymptoms, setCurrentSymptoms] = useState<string[]>(["هیچکدام (سلامت کامل)"]);
|
||||
const [medicalConditions, setMedicalConditions] = useState<string[]>(["هیچکدام (بدون سابقه بیماری)"]);
|
||||
|
||||
const toggleSymptom = (condition: string) => {
|
||||
if (condition === "هیچکدام (سلامت کامل)") {
|
||||
setCurrentSymptoms(["هیچکدام (سلامت کامل)"]);
|
||||
return;
|
||||
}
|
||||
setCurrentSymptoms(prev => {
|
||||
const filtered = prev.filter(c => c !== "هیچکدام (سلامت کامل)");
|
||||
if (filtered.includes(condition)) {
|
||||
const next = filtered.filter(c => c !== condition);
|
||||
return next.length === 0 ? ["هیچکدام (سلامت کامل)"] : next;
|
||||
} else {
|
||||
return [...filtered, condition];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const toggleMedicalHistory = (condition: string) => {
|
||||
if (condition === "هیچکدام (بدون سابقه بیماری)") {
|
||||
setMedicalConditions(["هیچکدام (بدون سابقه بیماری)"]);
|
||||
return;
|
||||
}
|
||||
setMedicalConditions(prev => {
|
||||
const filtered = prev.filter(c => c !== "هیچکدام (بدون سابقه بیماری)");
|
||||
if (filtered.includes(condition)) {
|
||||
const next = filtered.filter(c => c !== condition);
|
||||
return next.length === 0 ? ["هیچکدام (بدون سابقه بیماری)"] : next;
|
||||
} else {
|
||||
return [...filtered, condition];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleNext = () => {
|
||||
if (step === 1) {
|
||||
@@ -110,7 +144,8 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
const handleBack = () => setStep(s => s - 1);
|
||||
|
||||
const calculateRecommendation = async () => {
|
||||
const combinedConditions = Array.from(new Set([...currentSymptoms, ...medicalConditions]));
|
||||
const rawConditions = Array.from(new Set([...currentSymptoms, ...medicalConditions]));
|
||||
const combinedConditions = rawConditions.filter(c => !c.includes("هیچکدام"));
|
||||
|
||||
let matchedProd: Record<string, unknown> | null = null;
|
||||
|
||||
@@ -153,7 +188,8 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
const combinedConditions = Array.from(new Set([...currentSymptoms, ...medicalConditions]));
|
||||
const rawConditions = Array.from(new Set([...currentSymptoms, ...medicalConditions]));
|
||||
const combinedConditions = rawConditions.filter(c => !c.includes("هیچکدام"));
|
||||
const data = {
|
||||
name, type, breed, age, weight, activityLevel, medicalConditions: combinedConditions
|
||||
};
|
||||
@@ -469,11 +505,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
{CURRENT_SYMPTOMS.map((opt) => (
|
||||
<button
|
||||
key={opt.id}
|
||||
onClick={() => {
|
||||
setCurrentSymptoms(prev =>
|
||||
prev.includes(opt.condition) ? prev.filter(c => c !== opt.condition) : [...prev, opt.condition]
|
||||
);
|
||||
}}
|
||||
onClick={() => toggleSymptom(opt.condition)}
|
||||
className={`flex items-center gap-4 p-5 rounded-2xl border-2 transition-all text-right focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none min-h-[48px] ${currentSymptoms.includes(opt.condition) ? 'border-canina-blue bg-white shadow-md' : 'border-transparent bg-white/50 text-medical-gray-600 hover:bg-white'}`}
|
||||
>
|
||||
<div className={`w-8 h-8 rounded-lg flex items-center justify-center border ${currentSymptoms.includes(opt.condition) ? 'bg-canina-blue border-canina-blue text-white' : 'border-medical-gray-300 text-transparent'}`}>
|
||||
@@ -520,11 +552,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
{MEDICAL_HISTORIES.map((opt) => (
|
||||
<button
|
||||
key={opt.id}
|
||||
onClick={() => {
|
||||
setMedicalConditions(prev =>
|
||||
prev.includes(opt.condition) ? prev.filter(c => c !== opt.condition) : [...prev, opt.condition]
|
||||
);
|
||||
}}
|
||||
onClick={() => toggleMedicalHistory(opt.condition)}
|
||||
className={`flex items-center gap-4 p-5 rounded-2xl border-2 transition-all text-right focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none min-h-[48px] ${medicalConditions.includes(opt.condition) ? 'border-canina-blue bg-white shadow-md' : 'border-transparent bg-white/50 text-medical-gray-600 hover:bg-white'}`}
|
||||
>
|
||||
<div className={`w-8 h-8 rounded-lg flex items-center justify-center border ${medicalConditions.includes(opt.condition) ? 'bg-canina-blue border-canina-blue text-white' : 'border-medical-gray-300 text-transparent'}`}>
|
||||
|
||||
Reference in new issue
Block a user