feat(symptoms): integrate full symptoms dictionary across SmartAdvisor, PetProfile, and Product Badges

- Expand SmartAdvisor options to include all clinical symptoms (joint pain, limp, diarrhea, hair loss, tartar, eye care, etc.)
- Dynamically match active pet symptoms against product symptoms in PetProfile recommended products engine
- Display specific symptom match badges (e.g. توصیه شده برای درد مفاصل لوسی) directly on product cards
This commit is contained in:
parsa aghaei 2026-07-21 12:36:23 +03:30
parent ffa6da7978
commit 6d568d56ae
3 changed files with 34 additions and 33 deletions

View File

@ -86,10 +86,12 @@ const ArchiveProductCard: React.FC<{ product: Product }> = ({ product }) => {
if (!activePet) return null;
const sameSpecies = product.suitableFor === activePet.type || product.suitableFor === "هر دو";
const helpsSymptom = (activePet.medicalConditions || []).some(s => product.symptoms.includes(s));
const matchedSymptom = (activePet.medicalConditions || []).find(mc =>
(product.symptoms || []).some(s => mc.includes(s) || s.includes(mc))
);
if (!sameSpecies) return { type: 'alert', text: `مخصوص ${product.suitableFor}` };
if (helpsSymptom) return { type: 'success', text: `توصیه شده برای راهکار ${activePet.name}` };
if (matchedSymptom) return { type: 'success', text: `توصیه شده برای ${matchedSymptom} ${activePet.name}` };
if (sameSpecies) return { type: 'neutral', text: `مناسب برای ${activePet.name}` };
return null;

View File

@ -165,36 +165,29 @@ export default function PetProfile({ initialView, advisorNeed }: {
let picks: { product: Product, reason?: string }[] = [];
// Priority: Medical Conditions
if (activePet.medicalConditions.includes("جراحی مفاصل")) {
const gag = products.find(p => p.id === "canhydrox-gag");
if (gag) picks.push({ product: gag, reason: "پیشنهاد ویژه بر اساس سوابق جراحی مفاصل" });
// Priority 1: Match activePet.medicalConditions directly against product.symptoms
if (activePet.medicalConditions && activePet.medicalConditions.length > 0) {
products.forEach(p => {
if (p.suitableFor !== activePet.type && p.suitableFor !== "هر دو") return;
const matchedSymptoms = (p.symptoms || []).filter(s =>
activePet.medicalConditions.some(mc => mc.includes(s) || s.includes(mc))
);
if (matchedSymptoms.length > 0 && !picks.some(x => x.product.id === p.id)) {
picks.push({
product: p,
reason: `پیشنهاد هوشمند برای تسکین ${matchedSymptoms.join(" و ")}`
});
}
});
}
if (activePet.medicalConditions.includes("زایمان اخیر") || activePet.medicalConditions.includes("بارداری")) {
const booster = products.find(p => p.id === "immun-booster");
if (booster) picks.push({ product: booster, reason: "حمایت حیاتی دوران بارداری و زایمان" });
}
if (activePet.medicalConditions.includes("مشکلات گوارشی")) {
const moor = products.find(p => p.id === "moor-tranke");
if (moor) picks.push({ product: moor, reason: "تنظیم تخصصی سیستم گوارش" });
}
if (activePet.medicalConditions.includes("ریزش موی شدید")) {
const lachs = products.find(p => p.id === "lachs-ol");
if (lachs) picks.push({ product: lachs, reason: "تقویت تارهای مو و کنترل ریزش" });
}
if (activePet.medicalConditions.includes("بی‌اشتهایی")) {
const energy = products.find(p => p.id === "energy-gel");
if (energy) picks.push({ product: energy, reason: "تامین فوری انرژی و تحریک اشتها" });
}
// Biological factors
// Priority 2: Biological factors
if (activePet.age > 7) {
const heart = products.find(p => p.id === "herz-vital");
if (heart && !picks.some(x => x.product.id === heart.id)) picks.push({ product: heart, reason: "محافظت از قلب پت‌های مسن" });
const heart = products.find(p => p.id === "herz-vital" || p.slug?.includes("herz"));
if (heart && !picks.some(x => x.product.id === heart.id)) {
picks.push({ product: heart, reason: "محافظت از قلب پت‌های مسن" });
}
}
// Fill defaults if needed

View File

@ -26,12 +26,18 @@ interface SmartAdvisorProps {
}
const MEDICAL_OPTIONS = [
{ 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: "appetite", label: "بی‌اشتهایی و کاهش وزن", condition: "بی‌اشتهایی" },
{ id: "dental", label: "جرم دندان و بوی بد دهان", condition: "جرم دندان" },
{ id: "eye", label: "مشکلات یا شستشوی چشم", condition: "چشم" },
{ id: "recent_birth", label: "زایمان اخیر", condition: "زایمان اخیر" },
{ id: "pregnancy", label: "بارداری", condition: "بارداری" },
{ id: "digestion", label: "مشکلات گوارشی", condition: "مشکلات گوارشی" },
{ id: "hair_loss", label: "ریزش موی شدید", condition: "ریزش موی شدید" },
{ id: "appetite", label: "بی‌اشتهایی", condition: "بی‌اشتهایی" },
{ id: "pregnancy", label: "بارداری و شیردهی", condition: "بارداری" },
];
export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorProps & { rules?: any[] }) {