"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import { Check, CheckCircle2 } from "lucide-react"; import { toast } from "sonner"; import { AppShell } from "@/components/app-shell"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { useFeedbackList, useResolveFeedback, CATEGORY_LABELS, CATEGORY_COLORS, BLOCK_LABELS, type ChairFeedback, type FeedbackCategory, } from "@/lib/api/feedback"; /** * מרכז הערות יו"ר — הדף המרכזי לטיפול בכל הערות דפנה שנרשמו על טיוטות * (chair_feedback). מאגד הערות מכל התיקים במקום אחד, מאפשר סינון לפי * "טרם יושמו" וקטגוריה, וסימון כל הערה כיושמה. מוזן מ-/api/feedback. */ function formatDate(iso?: string | null): string { if (!iso) return ""; try { return new Date(iso).toLocaleDateString("he-IL", { day: "numeric", month: "long", year: "numeric", }); } catch { return ""; } } function FeedbackCard({ fb }: { fb: ChairFeedback }) { const resolve = useResolveFeedback(); const onResolve = () => { resolve.mutate( { feedbackId: fb.id, applied_to: [], fold: true }, { onSuccess: (res) => toast.success( res.fold_queued ? "סומנה כיושמה — הלקח נשלח ל-CEO לקיפול לקובץ הידע" : "ההערה סומנה כיושמה", ), onError: (e) => toast.error(e instanceof Error ? e.message : "שגיאה בסימון"), }, ); }; return (
{CATEGORY_LABELS[fb.category]} {BLOCK_LABELS[fb.block_id] ?? fb.block_id} {fb.case_number ? ( תיק {fb.case_number} ) : ( ללא תיק )} {formatDate(fb.created_at)}

{fb.feedback_text}

{fb.lesson_extracted ? (
לקח שהופק

{fb.lesson_extracted}

) : null}
{fb.resolved ? ( יושמה ) : ( )}
); } type CatFilter = "all" | FeedbackCategory; export default function FeedbackPage() { const [unresolvedOnly, setUnresolvedOnly] = useState(true); const [category, setCategory] = useState("all"); const { data, isPending, error } = useFeedbackList({ unresolved_only: unresolvedOnly, category: category === "all" ? undefined : category, }); const items = useMemo(() => data ?? [], [data]); const unresolvedCount = useMemo( () => items.filter((f) => !f.resolved).length, [items], ); const categories: { key: CatFilter; label: string }[] = [ { key: "all", label: "הכל" }, { key: "missing_content", label: CATEGORY_LABELS.missing_content }, { key: "wrong_tone", label: CATEGORY_LABELS.wrong_tone }, { key: "wrong_structure", label: CATEGORY_LABELS.wrong_structure }, { key: "factual_error", label: CATEGORY_LABELS.factual_error }, { key: "style", label: CATEGORY_LABELS.style }, { key: "other", label: CATEGORY_LABELS.other }, ]; return (
שערים אנושיים · יו״ר הוועדה

הערות יו״ר

כל ההערות שנרשמו על טיוטות — מכל התיקים. סמן כל הערה כיושמה לאחר שהלקח הוטמע.

{unresolvedCount}
טרם יושמו
{/* Filters */}
{categories.map((c) => ( ))}
{error ? ( שגיאה בטעינת ההערות. נסה לרענן. ) : isPending ? (
{[0, 1, 2].map((i) => ( ))}
) : items.length === 0 ? (

אין הערות בקטגוריה זו.

{unresolvedOnly && (

כל ההערות יושמו ✓

)}
) : (
{items.map((fb) => ( ))}
)}
); }