"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import { flexRender, getCoreRowModel, getFilteredRowModel, getSortedRowModel, useReactTable, type ColumnDef, type SortingState, } from "@tanstack/react-table"; import { toast } from "sonner"; import { AppShell } from "@/components/app-shell"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Skeleton } from "@/components/ui/skeleton"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { useCases, useRestoreCase, type Case } from "@/lib/api/cases"; import { APPEAL_SUBTYPE_LABELS } from "@/lib/practice-area"; function formatDate(iso?: string | null) { if (!iso) return "—"; try { return new Date(iso).toLocaleDateString("he-IL", { day: "2-digit", month: "2-digit", year: "numeric", }); } catch { return iso; } } function RestoreButton({ caseNumber }: { caseNumber: string }) { const restore = useRestoreCase(caseNumber); return ( ); } const columns: ColumnDef[] = [ { accessorKey: "case_number", header: "מס׳ ערר", cell: ({ row }) => ( {row.original.case_number} ), }, { accessorKey: "title", header: "כותרת", cell: ({ row }) => (
{row.original.title}
), }, { accessorKey: "appeal_subtype", header: "תחום", cell: ({ row }) => { const s = row.original.appeal_subtype; if (!s || s === "unknown") return ; return ( {APPEAL_SUBTYPE_LABELS[s]} ); }, }, { accessorKey: "archived_at", header: "תאריך ארכוב", cell: ({ row }) => ( {formatDate(row.original.archived_at)} ), }, { id: "actions", header: "", cell: ({ row }) => , }, ]; export default function ArchivePage() { const { data, isPending, error } = useCases(true, "archived"); const [sorting, setSorting] = useState([ { id: "archived_at", desc: true }, ]); const [globalFilter, setGlobalFilter] = useState(""); const rows = useMemo(() => data ?? [], [data]); const table = useReactTable({ data: rows, columns, state: { sorting, globalFilter }, onSortingChange: setSorting, onGlobalFilterChange: setGlobalFilter, getCoreRowModel: getCoreRowModel(), getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel(), globalFilterFn: (row, _colId, filterValue: string) => { if (!filterValue) return true; const needle = filterValue.toLowerCase(); return ( row.original.case_number.toLowerCase().includes(needle) || row.original.title.toLowerCase().includes(needle) ); }, }); return (
ארכיון תיקי ערר

תיקים סגורים

תיקים שסגרו את הטיפול בהם. שחזור מחזיר את התיק לרשימה הראשית ופותח מחדש את הפרויקט המקביל ב-Paperclip.

setGlobalFilter(e.target.value)} placeholder="חיפוש לפי מס׳ ערר או כותרת…" className="max-w-sm bg-surface" dir="rtl" /> {table.getFilteredRowModel().rows.length} תיקים בארכיון
{table.getHeaderGroups().map((hg) => ( {hg.headers.map((header) => ( {flexRender( header.column.columnDef.header, header.getContext(), )} {{ asc: " ▲", desc: " ▼" }[ header.column.getIsSorted() as string ] ?? ""} ))} ))} {isPending ? ( Array.from({ length: 3 }).map((_, i) => ( {columns.map((_c, j) => ( ))} )) ) : error ? ( שגיאה בטעינת ארכיון: {error.message} ) : table.getRowModel().rows.length === 0 ? (
{globalFilter ? "אין תיקים תואמים לחיפוש" : "אין תיקים בארכיון"}
) : ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender( cell.column.columnDef.cell, cell.getContext(), )} ))} )) )}
); }