refactored code
This commit is contained in:
1 parent
5ed4c9a8ec
commit
d326361a03
46 files changed
+230
-592
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
@@ -9,29 +8,12 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { getStatusLabel, getStatusOptions, getRegionOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { getStatusOptions, getRegionOptions, StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={STATUS_BADGE_VARIANTS[status]} icon={STATUS_ICONS[status]} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstName", "lastName", "phone", "status"] as const;
|
||||
@@ -180,7 +162,7 @@ export default function LoanOrderMobilesPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <LoanOrderStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} prefix="loanOrderStatus" />,
|
||||
size: 180,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user