fix(frontend): enhance species badges, smart symptom matching, and sync charity total
Deploy Canina / deploy (push) Successful in 2m5s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 0s

This commit is contained in:
parsa aghaei committed 2026-09-05 16:37:35 +03:30
1 parent 330d960502
commit 30fb8f3e83
18 files changed
+16952 -14903

No files matched your search

@@ -57,6 +57,7 @@ import { usePetStore } from "../lib/store/usePetStore";
import { toast } from "sonner";
import api from "../lib/services/api";
import { DosageConfig } from "../lib/types";
import { isSuitableForDog, isSuitableForCat, isSuitableForBoth, isSpeciesCompatible, matchesMedicalSymptom } from "../lib/petCompatibility";
interface CalculatorState {
petType: "young" | "adult";
@@ -218,10 +219,8 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
const compatibility = useMemo(() => {
if (!activePet || !fullProduct) return null;
const sameSpecies = fullProduct.suitableFor === activePet.type || fullProduct.suitableFor === "هر دو";
const matchedSymptom = (activePet.medicalConditions || []).find(mc =>
(fullProduct.symptoms || []).some(s => mc.includes(s) || s.includes(mc))
);
const sameSpecies = isSpeciesCompatible(fullProduct.suitableFor, activePet.type);
const matchedSymptom = matchesMedicalSymptom(activePet.medicalConditions, fullProduct.symptoms, fullProduct.benefits);
if (!sameSpecies) return { type: 'alert', text: `مخصوص ${fullProduct.suitableFor}` };
if (matchedSymptom) return { type: 'success', text: `توصیه شده برای ${matchedSymptom} ${activePet.name}` };
@@ -469,12 +468,12 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
{/* Species Suitable Badges (Dog / Cat) */}
<div className="absolute bottom-4 left-4 flex gap-1.5 z-10 pointer-events-none">
{(product.suitableFor === "سگ" || product.suitableFor === "هر دو") && (
{isSuitableForDog(product.suitableFor) && (
<div className="w-7 h-7 bg-white/90 backdrop-blur-sm rounded-lg flex items-center justify-center text-medical-gray-600 border border-medical-gray-200 shadow-sm" title="مناسب برای سگ">
<Dog className="w-4 h-4 text-canina-blue" />
</div>
)}
{(product.suitableFor === "گربه" || product.suitableFor === "هر دو") && (
{isSuitableForCat(product.suitableFor) && (
<div className="w-7 h-7 bg-white/90 backdrop-blur-sm rounded-lg flex items-center justify-center text-medical-gray-600 border border-medical-gray-200 shadow-sm" title="مناسب برای گربه">
<Cat className="w-4 h-4 text-canina-blue" />
</div>
@@ -657,7 +656,24 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
compatibility.type === 'success' ? 'bg-emerald-100 text-emerald-800 border border-emerald-200' :
'bg-medical-gray-100 text-medical-gray-700 border border-medical-gray-200'
}`}>
{compatibility.type === 'alert' ? <AlertCircle className="w-3 h-3 shrink-0" /> : compatibility.type === 'success' ? <Heart className="w-3 h-3 shrink-0 text-emerald-600" /> : <Sparkles className="w-3 h-3 shrink-0 text-canina-blue" />}
{compatibility.type === 'alert' ? (
isSuitableForBoth(product.suitableFor) ? (
<span className="flex items-center gap-0.5">
<Dog className="w-3 h-3 shrink-0" />
<Cat className="w-3 h-3 shrink-0" />
</span>
) : isSuitableForCat(product.suitableFor) ? (
<Cat className="w-3 h-3 shrink-0" />
) : isSuitableForDog(product.suitableFor) ? (
<Dog className="w-3 h-3 shrink-0" />
) : (
<AlertCircle className="w-3 h-3 shrink-0" />
)
) : compatibility.type === 'success' ? (
<Heart className="w-3 h-3 shrink-0 text-emerald-600" />
) : (
<Sparkles className="w-3 h-3 shrink-0 text-canina-blue" />
)}
<span>{compatibility.text}</span>
</div>
)}