"use client"; import { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { useCorpus, useCompare, type CompareSide, type PatternEntry, } from "@/lib/api/training"; /* * Compare two decisions from the style corpus side-by-side. Uses the * training/compare endpoint which already does the heavy lifting (pattern * extraction, section stats, shared/unique pattern sets). Our job is * layout: two columns of metadata + section bars, plus a third "shared" * section listing patterns that appear in both. */ function SideColumn({ side }: { side: CompareSide }) { return (

{side.decision_number || "—"}

{side.decision_date || "—"} · {(side.chars / 1000).toFixed(1)}K תווים

{side.subjects.length > 0 && (
{side.subjects.map((s) => ( {s} ))}
)} {side.sections.length > 0 && (

חלוקה לחלקים

    {side.sections.map((sec) => (
  • {sec.type} {(sec.chars / 1000).toFixed(1)}K
  • ))}
)}

דפוסי סגנון שנמצאו: {side.patterns_count}

); } function PatternList({ title, items, tone, }: { title: string; items: PatternEntry[]; tone: "shared" | "a" | "b"; }) { const toneClass = tone === "shared" ? "bg-success-bg border-success/40" : tone === "a" ? "bg-info-bg border-info/40" : "bg-gold-wash border-gold/40"; const toneHeading = tone === "shared" ? "text-success" : tone === "a" ? "text-info" : "text-gold-deep"; return (

{title} {items.length}

{items.length === 0 ? (

) : ( )}
); } export function ComparePanel() { const { data: corpus, isPending } = useCorpus(); const [a, setA] = useState(null); const [b, setB] = useState(null); const cmp = useCompare(a, b); return (

בחר שתי החלטות להשוואה

{(["a", "b"] as const).map((slot) => (
))}
{a && b && a === b && (

בחר שתי החלטות שונות

)} {cmp.error && ( {cmp.error.message} )} {cmp.isPending && a && b && a !== b && ( )} {cmp.data && ( <>
)}
); }