"use client"; import { Spinner } from "../UI"; import type { Client } from "../../types/client"; // ── Address count badge ──────────────────────────────────────────────────── function AddressBadge({ count }: { count: number }) { const hasAddr = count > 0; return ( {count} {count === 1 ? "عنوان" : "عناوين"} ); } // ── Status badge ─────────────────────────────────────────────────────────── function StatusBadge({ active }: { active?: boolean }) { const isActive = active !== false; return ( {isActive ? "نشط" : "غير نشط"} ); } // ── Icon button (mirrors UserTable's IconBtn) ────────────────────────────── function IconBtn({ onClick, title, color, bg, borderColor, children, }: { onClick: () => void; title: string; color: string; bg: string; borderColor: string; children: React.ReactNode; }) { return ( ); } // ── Shared card & header styles ──────────────────────────────────────────── const cardStyle: React.CSSProperties = { borderRadius: "var(--radius-xl)", border: "1px solid var(--color-border)", background: "var(--color-surface)", overflow: "hidden", boxShadow: "var(--shadow-card)", }; const thStyle: React.CSSProperties = { padding: "0.75rem 1.5rem", fontSize: 11, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.2em", color: "var(--color-text-muted)", background: "var(--color-surface-muted)", borderBottom: "1px solid var(--color-border)", }; // ── Props ────────────────────────────────────────────────────────────────── interface ClientTableProps { clients: Client[]; loading: boolean; search: string; page: number; pages: number; onEdit: (client: Client) => void; onDelete: (client: Client) => void; onAddFirst: () => void; onPageChange: (p: number) => void; /** Navigate to address management for a client */ onManageAddresses: (client: Client) => void; } // ── Main table ───────────────────────────────────────────────────────────── export function ClientTable({ clients, loading, search, page, pages, onEdit, onDelete, onAddFirst, onPageChange, onManageAddresses, }: ClientTableProps) { return (
{search ? `لا توجد نتائج لـ "${search}"` : "لا يوجد عملاء لعرضهم."}
{!search && ( )}{c.name}
{c.taxId && ({c.taxId}
)}