import { useState, useEffect } from "react";
import useAnalyzer from "../hooks/useAnalyzer";
import { FIELDS } from "../data/responses";
export default function CompatibilityAnalyzer() {
const [fieldA, setFieldA] = useState(FIELDS[0].id);
const [fieldB, setFieldB] = useState(FIELDS[1].id);
const { isAnalyzing, compatResult, analyzeCompat } = useAnalyzer();
const [celebrate, setCelebrate] = useState(false);
useEffect(() => {
if (compatResult && compatResult.score >= 90 && !isAnalyzing) {
setCelebrate(true);
const timer = setTimeout(() => setCelebrate(false), 4000);
return () => clearTimeout(timer);
}
}, [compatResult, isAnalyzing]);
return (
{celebrate && (
{[...Array(20)].map((_, i) => {
const randomX = Math.random() * 100;
const randomDelay = Math.random() * 2;
const randomColor = compatResult.color || '#22c55e';
return (
);
})}
)}
{/* القلب النابض الاحترافي بين التخصصين */}
{compatResult && !isAnalyzing && (
= 90 ? "animate-heart-pulse border-emerald-500/30" : ""
}`}
style={{ animation: "fadeUp 0.5s ease both" }}
>
= 90 ? "opacity-40 scale-125 animate-glow-pulse" : "opacity-25"
}`}
style={{ background: compatResult.color || '#ffffff' }}
/>
{compatResult.score}%
{/* التعديل هنا: تغيير النص إلى نسبة التوافق */}
نسبة التوافق
"{compatResult.joke}"
= 90 ? "animate-ping" : ""}`}
style={{ background: compatResult.color || '#fff' }}
/>
{compatResult.verdict}
)}
);
}