"use client"; import { motion, AnimatePresence } from "framer-motion"; import { Progress } from "@/components/ui/progress"; import { CheckCircle2, XCircle, Clock } from "lucide-react"; import { useState } from "react"; import { ScrollArea } from "@/components/ui/scroll-area"; import { cn } from "@/lib/utils"; import { useTranslation } from "react-i18next"; interface TestProgressProps { isVisible: boolean; models: Array<{ id: string; name: string; testStatus?: "success" | "error" | "testing"; }>; isComplete: boolean; } export function TestProgress({ isVisible, models, isComplete, }: TestProgressProps) { const { t } = useTranslation("common"); const [expandedSection, setExpandedSection] = useState< "success" | "error" | null >(null); const totalModels = models.length; const testedModels = models.filter( (m) => m.testStatus && m.testStatus !== "testing" ).length; const successModels = models.filter((m) => m.testStatus === "success"); const failedModels = isComplete ? models.filter((m) => m.testStatus !== "success") : models.filter((m) => m.testStatus === "error"); const pendingModels = models.filter( (m) => !m.testStatus || m.testStatus === "testing" ); const progress = (testedModels / totalModels) * 100; const StatusSection = ({ type, models, count, icon, color, label, }: { type: "success" | "error" | "pending"; models: typeof successModels; count: number; icon: JSX.Element; color: string; label: string; }) => (
type !== "pending" && setExpandedSection( expandedSection === type ? null : (type as "success" | "error") ) } >
{icon}
{count}
{label}
); return ( {isVisible && (
{isComplete ? ( <> {t("models.test.result.complete")}
} color="bg-green-50" label={t("models.test.status.valid")} />
} color="bg-red-50" label={t("models.test.status.invalid")} />
) : ( <>
} color="bg-green-50" label={t("models.test.status.valid")} /> } color="bg-red-50" label={t("models.test.status.invalid")} /> } color="bg-blue-50" label={t("models.test.status.pending")} />
{t("models.test.progress.title")} {testedModels} / {totalModels}
)} {expandedSection && (
{expandedSection === "success" ? t("models.test.result.success") : t("models.test.result.failed")}
{(expandedSection === "success" ? successModels : failedModels ).map((model) => ( {expandedSection === "success" ? ( ) : ( )} {model.name} ))}
)}
)}
); }