"use client"; import { useCallback, useEffect, useState } from "react"; import { Alert, Button, Spinner } from "../UI"; import { driverService } from "@/src/services/driver.service"; import { getStoredToken } from "@/src/lib/auth"; import { DriverReportPanel } from "../Driver_Report/driverReport"; import type { Driver } from "@/src/types/driver"; import { DRIVER_STATUS_MAP, DRIVER_CARD_TYPE_MAP, NATIONAL_ID_TYPE_MAP, } from "@/src/types/driver"; function fmtDate(iso?: string | null): string { if (!iso) return "—"; return new Date(iso).toLocaleDateString("ar-SA", { year: "numeric", month: "long", day: "numeric", }); } function isExpiringSoon(iso?: string | null): boolean { if (!iso) return false; return new Date(iso).getTime() - Date.now() <= 90 * 86_400_000; } function DetailRow({ label, value, mono = false, warn = false, }: { label: string; value: string; mono?: boolean; warn?: boolean; }) { return (
{label} {warn && value !== "—" ? "⚠ " : ""} {value}
); } function SectionHeading({ title }: { title: string }) { return (

{title}

); } function PhotoCard({ url, label }: { url?: string | null; label: string }) { const [imgError, setImgError] = useState(false); useEffect(() => { queueMicrotask(() => setImgError(false)); }, [url]); return (
{label}
{url && !imgError ? ( // eslint-disable-next-line @next/next/no-img-element {label} setImgError(true)} /> ) : (