fix(frontend): enhance species badges, smart symptom matching, and sync charity total
This commit is contained in:
1 parent
330d960502
commit
30fb8f3e83
18 files changed
+16952
-14903
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import React, { useState, useMemo, useEffect } from "react";
|
||||
import { Product } from "../lib/data/products";
|
||||
import { productService } from "../lib/services/productService";
|
||||
import { isSpeciesCompatible, matchesMedicalSymptom } from "../lib/petCompatibility";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import { PetProfileSkeleton } from "./Skeleton";
|
||||
import SafeImage from "./SafeImage";
|
||||
@@ -164,15 +165,13 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
// 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 (!isSpeciesCompatible(p.suitableFor, activePet.type)) return;
|
||||
const matchedCondition = matchesMedicalSymptom(activePet.medicalConditions, p.symptoms, p.benefits);
|
||||
|
||||
if (matchedSymptoms.length > 0 && !picks.some(x => x.product.id === p.id)) {
|
||||
if (matchedCondition && !picks.some(x => x.product.id === p.id)) {
|
||||
picks.push({
|
||||
product: p,
|
||||
reason: `پیشنهاد هوشمند برای تسکین ${matchedSymptoms.join(" و ")}`
|
||||
reason: `پیشنهاد هوشمند برای تسکین ${matchedCondition}`
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -182,7 +181,7 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
if (activePet.age >= 7) {
|
||||
const seniorSupplements = products.filter(p =>
|
||||
(p.id === "herz-vital" || p.slug?.includes("herz") || p.name.includes("قلب") || p.benefits?.includes("مسن")) &&
|
||||
(p.suitableFor === activePet.type || p.suitableFor === "هر دو")
|
||||
isSpeciesCompatible(p.suitableFor, activePet.type)
|
||||
);
|
||||
seniorSupplements.forEach(p => {
|
||||
if (!picks.some(x => x.product.id === p.id)) {
|
||||
@@ -192,7 +191,7 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
} else if (activePet.age > 0 && activePet.age <= 1) {
|
||||
const growthSupplements = products.filter(p =>
|
||||
(p.name.includes("رشد") || p.benefits?.includes("تغذیه توله") || p.benefits?.includes("کلسیم")) &&
|
||||
(p.suitableFor === activePet.type || p.suitableFor === "هر دو")
|
||||
isSpeciesCompatible(p.suitableFor, activePet.type)
|
||||
);
|
||||
growthSupplements.forEach(p => {
|
||||
if (!picks.some(x => x.product.id === p.id)) {
|
||||
@@ -204,7 +203,7 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
if (activePet.activityLevel === "زیاد") {
|
||||
const performanceSupplements = products.filter(p =>
|
||||
(p.name.includes("انرژی") || p.benefits?.includes("عضله") || p.benefits?.includes("مفصل")) &&
|
||||
(p.suitableFor === activePet.type || p.suitableFor === "هر دو")
|
||||
isSpeciesCompatible(p.suitableFor, activePet.type)
|
||||
);
|
||||
performanceSupplements.forEach(p => {
|
||||
if (!picks.some(x => x.product.id === p.id)) {
|
||||
|
||||
Reference in new issue
Block a user