"use client"; import { useState } from "react"; import { Alert } from "../../UI"; import { ArchivedBranchTable } from "./ArchivedBranchTable"; import { ArchivedBranchDetailModal } from "./ArchivedBranchDetailModal"; import { useArchivedBranches } from "@/src/hooks/archive/useArchiveBranch"; import type { ArchivedBranch } from "@/src/types/branch"; interface ArchivedBranchesModalProps { onClose: () => void; } export function ArchivedBranchesModal({ onClose }: ArchivedBranchesModalProps) { // hold the full object, not just the id — no GET /branches/archived/{id} route exists const [viewBranch, setViewBranch] = useState(null); const { branches, loading, total, pages, error, page, search, setPage, handleSearch, clearError, } = useArchivedBranches(); return (
{ if (e.target === e.currentTarget) onClose(); }} style={{ position: "fixed", inset: 0, zIndex: 70, background: "rgba(15,23,42,0.6)", backdropFilter: "blur(4px)", display: "flex", alignItems: "flex-start", justifyContent: "center", padding: "2rem 1rem", overflowY: "auto", }} > {viewBranch && ( setViewBranch(null)} /> )}
e.stopPropagation()} style={{ width: "100%", maxWidth: 920, background: "var(--color-surface-sunken)", borderRadius: "var(--radius-xl)", border: "1px solid var(--color-border)", boxShadow: "0 24px 64px rgba(0,0,0,.2)", overflow: "hidden", }} > {/* header */}

الأرشيف

الفروع المؤرشفة ({total})

{/* body */}
{/* search */}
handleSearch(e.target.value)} dir="rtl" style={{ width: "100%", height: 40, paddingRight: 36, paddingLeft: 12, borderRadius: "var(--radius-lg)", border: "1px solid var(--color-border)", background: "var(--color-surface)", fontSize: 13, outline: "none", fontFamily: "var(--font-sans)", color: "var(--color-text-primary)", }} />
{/* general fetch error — fallback UI */} {error && } setViewBranch(branch)} onPageChange={setPage} />
); }