"use client"; import { useState } from "react"; import { Alert, Input, Modal } from "../../UI"; import { ArchivedCarMaintenanceTable } from "./ArchivedCarMaintananceTable"; import { ArchivedCarMaintenanceDetailPanel } from "./ArchivedCarMaintananceDetailpanel"; import { useArchivedCarMaintenance } from "@/src/hooks/archive/UseArchivedCarsMaintanance"; import type { CarMaintenance } from "@/src/types/carMaintanance"; interface ArchivedCarsMaintenanceModalProps { /** A car's id to scope the archive to one vehicle, or `null` for the global (all-cars) archive. */ carId: string | null; /** Shown in the header, e.g. "تويوتا لاند كروزر — أ ب ج 1234". Ignored for the global view. */ carLabel?: string; onClose: () => void; } export function ArchivedCarsMaintenanceModal({ carId, carLabel, onClose }: ArchivedCarsMaintenanceModalProps) { const [viewRecord, setViewRecord] = useState(null); const { records, loading, total, pages, error, page, search, setPage, handleSearch, setError, } = useArchivedCarMaintenance(carId); return ( {viewRecord && ( setViewRecord(null)} /> )}
handleSearch(e.target.value)} dir="rtl" icon={