diff --git a/web-ui/src/components/precedents/extracted-halachot.tsx b/web-ui/src/components/precedents/extracted-halachot.tsx index 28281f1..018ec3a 100644 --- a/web-ui/src/components/precedents/extracted-halachot.tsx +++ b/web-ui/src/components/precedents/extracted-halachot.tsx @@ -1,9 +1,12 @@ "use client"; import { useMemo, useState } from "react"; +import { Check, X, RotateCcw } from "lucide-react"; +import { toast } from "sonner"; import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; import { CorroborationBadge } from "@/components/precedents/corroboration-badge"; -import type { Halacha } from "@/lib/api/precedent-library"; +import { useUpdateHalacha, type Halacha } from "@/lib/api/precedent-library"; const RULE_TYPE_LABELS: Record = { binding: "הלכה מחייבת", @@ -47,13 +50,26 @@ export function ReviewStatusPill({ status }: { status: Halacha["review_status"] ); } -/* Read-only roll-up of every halacha extracted from a precedent — - * approved + pending + rejected. The "ממתין לאישור" tab only surfaces - * pending items globally; this section is the per-case view. To act on - * an item (approve / edit / reject), go to the review tab — keeping the - * surfaces separated avoids duplicate review UX in two places. */ +/* Roll-up of every halacha extracted from a precedent — approved + + * pending + rejected. The "ממתין לאישור" tab surfaces pending items + * globally; this section is the per-case view, with inline status + * actions so the chair can flip a single ruling (e.g. approve one that + * was rejected) without leaving the precedent. */ export function ExtractedHalachotSection({ halachot }: { halachot: Halacha[] }) { const [filter, setFilter] = useState("all"); + const update = useUpdateHalacha(); + + const setStatus = async ( + h: Halacha, + status: "approved" | "rejected" | "pending_review", + ) => { + try { + await update.mutateAsync({ id: h.id, patch: { review_status: status } }); + toast.success("עודכן"); + } catch (e) { + toast.error(e instanceof Error ? e.message : "שגיאה"); + } + }; const counts = useMemo(() => { const c = { all: halachot.length, approved: 0, pending: 0, rejected: 0 }; @@ -204,6 +220,62 @@ export function ExtractedHalachotSection({ halachot }: { halachot: Halacha[] }) ))} ) : null} + + {/* Inline status actions — contextual per current review_status */} +
+ {h.review_status === "rejected" && ( + <> + + + + )} + {(h.review_status === "approved" || h.review_status === "published") && ( + <> + + + + )} + {h.review_status === "pending_review" && ( + <> + + + + )} +
))}