import { useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Trash2, Pencil } from "lucide-react"; import { useLoanOrderById, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders"; import { Skeleton } from "@/components/ui/skeleton"; import { StatusBadge } from "@/components/ui/statusBadge"; import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react"; import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi"; import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents"; import { ConfirmDialog } from "@/components/confirmDialog"; import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants"; // ─── Status config ──────────────────────────────────────────────────────────── const STATUS_ICON: Record = { pending: AlertCircle, approved: CheckCircle2, rejected: XCircle, completed: CheckCheck, }; function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderStatus }) { const { t } = useTranslation(); const variant = STATUS_BADGE_VARIANTS[status]; const Icon = STATUS_ICON[status]; return ; } // ─── Skeleton ───────────────────────────────────────────────────────────────── function LoanOrderViewSkeleton() { return (
{[...Array(6)].map((_, i) => (
{[...Array(3)].map((_, j) => ( ))}
))}
); } // ─── Page ───────────────────────────────────────────────────────────────────── export default function LoanOrderViewPage() { const { t } = useTranslation(); const navigate = useNavigate(); const { id } = useParams<{ id: string }>(); const deleteMutation = useDeleteLoanOrder(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const { data: order, isLoading } = useLoanOrderById(id!); const handleDelete = () => { setShowDeleteDialog(true); }; const confirmDelete = () => { deleteMutation.mutate(id!, { onSuccess: () => navigate("/loan-orders"), }); }; if (isLoading) return ; if (!order) { return
{t("common.notFound", "Tapylmady")}
; } const auditLogs: AuditRowProps[] = [ { id: "44548", action: t("audit.actions.view", "Görmek"), by: order.createdBy ?? "", target: `${t("loanOrders.title", "Karz sargyt")}: ${order.id}`, status: "FINISHED", date: order.createdAt ?? "", }, ]; return (
{/* ── Page header ──────────────────────────────────────────────────── */}

{t("loanOrders.view.title", "Karz sargyt giriş")}: {order.id}

{/* ── Row 1: Meta + Loan + Location ───────────────────────────────── */} {/* Meta */} {/* Loan */} {/* Location */} {/* ── Row 2: Personal + Contacts ──────────────────────────────────── */} {/* Personal */} {/* Contacts */} {/* ── Row 3: Employment + Passport info ───────────────────────────── */} {/* Employment */} {/* Passport info */} {/* ── Row 4: Passport images ───────────────────────────────────────── */} {/* ── Audit log ────────────────────────────────────────────────────── */}
); }