"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 { useFeedbackList, useResolveFeedback, useCreateFeedback, CATEGORY_LABELS, BLOCK_LABELS, type ChairFeedback, type FeedbackCategory, } from "@/lib/api/feedback"; import { formatDateLong } from "@/lib/format-date"; /** * מרכז הערות יו"ר — הדף המרכזי לטיפול בכל הערות דפנה שנרשמו על טיוטות * (chair_feedback). מאגד הערות מכל התיקים במקום אחד, מאפשר סינון לפי * "טרם יושמו" וקטגוריה, וסימון כל הערה כיושמה. מוזן מ-/api/feedback. */ // category chip styling per mockup 06 (.c-missing / .c-tone / .c-struct / .c-fact / .c-style) const CAT_CHIP: Record = { missing_content: "bg-warn-bg text-warn", wrong_tone: "bg-info-bg text-info", wrong_structure: "bg-gold-wash text-gold-deep border border-rule", factual_error: "bg-danger-bg text-danger", style: "bg-rule-soft text-ink-soft", other: "bg-rule-soft text-ink-soft", }; const formatDate = (iso?: string | null) => formatDateLong(iso); 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 ( {/* meta row — where · category chip · when (mockup 06 .meta) */}
{fb.case_number ? ( ערר {fb.case_number} ) : ( "ללא תיק" )} · {BLOCK_LABELS[fb.block_id] ?? fb.block_id} {CATEGORY_LABELS[fb.category]} {formatDate(fb.created_at)}

{fb.feedback_text}

{fb.lesson_extracted ? (

לקח שחולץ: {fb.lesson_extracted}

) : null} {/* action row — gold CTA / applied pill (mockup 06 .actrow) */}
{fb.resolved ? ( יושם ) : ( )}
); } type CatFilter = "all" | FeedbackCategory; const BLOCK_OPTIONS = [ "block-vav", "block-zayin", "block-chet", "block-tet", "block-yod", "block-yod-alef", ]; function AddFeedbackForm() { const create = useCreateFeedback(); const [caseNumber, setCaseNumber] = useState(""); const [blockId, setBlockId] = useState("block-yod"); const [category, setCategory] = useState("missing_content"); const [text, setText] = useState(""); const onSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!text.trim()) { toast.error("יש להזין את תוכן ההערה"); return; } create.mutate( { case_number: caseNumber.trim() || undefined, block_id: blockId, category, feedback_text: text.trim(), }, { onSuccess: () => { toast.success("ההערה נשמרה"); setCaseNumber(""); setText(""); }, onError: (err) => toast.error(err instanceof Error ? err.message : "שגיאה בשמירה"), }, ); }; const fieldCls = "w-full text-[0.84rem] text-ink bg-parchment border border-rule rounded-md px-3 py-2"; const labelCls = "block text-[0.76rem] text-ink-muted font-medium mt-2.5 mb-1"; return (

הוסף הערה

setCaseNumber(e.target.value)} placeholder="לדוגמה: 1126-08-25" className={fieldCls} dir="rtl" />