refactored code, fixed checkbox

This commit is contained in:
@jcarymuhammedow committed 2026-05-22 18:51:45 +05:00
1 parent 4adc153503
commit d56620be2e
16 files changed
+640 -267

No files matched your search

+193
View File
@@ -0,0 +1,193 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Download, Trash2, Database, CheckCircle2, XCircle, Clock } from 'lucide-react'
import { Button } from '@/components/ui/button'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { DataTable, type ColumnDef } from '@/components/dataTable'
import { DataTableToolbar, type ColumnMeta } from '@/components/dataTableToolbar'
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
import type { VisibilityState } from '@tanstack/react-table'
import { useBackups, useCreateBackup, useDeleteBackup, useDownloadBackup } from '@/features/backups/hooks/useBackups'
import type { Backup, BackupStatus } from '@/features/backups/api/backupsApi'
const PER_PAGE = 25
const STATUS_CONFIG: Record<BackupStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
completed: { label: 'Tamamlandy', variant: 'success', icon: CheckCircle2 },
failed: { label: 'Şowsuz', variant: 'error', icon: XCircle },
in_progress: { label: 'Dowam edýär', variant: 'warning', icon: Clock },
}
function BackupStatusBadge({ status }: { status: BackupStatus }) {
const cfg = STATUS_CONFIG[status]
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
}
export default function BackupsPage() {
const { t } = useTranslation()
const [page, setPage] = useState(1)
const [perPage, setPerPage] = useState(PER_PAGE)
const [search, setSearch] = useState('')
const [deleteId, setDeleteId] = useState<number | null>(null)
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({})
const [columnOrder, setColumnOrder] = useState<string[]>([])
const { data, isLoading } = useBackups({ page, per_page: perPage, search })
const createBackup = useCreateBackup()
const downloadBackup = useDownloadBackup()
const deleteBackup = useDeleteBackup()
const columns: ColumnDef<Backup>[] = [
{
id: 'fileName',
accessorKey: 'fileName',
header: t('backups.col.fileName', 'Faýl ady'),
cell: ({ row }) => (
<span className="font-mono text-sm">{row.original.fileName}</span>
),
},
{
id: 'fileSize',
accessorKey: 'fileSize',
header: t('backups.col.fileSize', 'Ölçegi'),
cell: ({ row }) => <span>{row.original.fileSize}</span>,
size: 100,
},
{
id: 'status',
accessorKey: 'status',
header: t('backups.col.status', 'Status'),
cell: ({ row }) => <BackupStatusBadge status={row.original.status} />,
size: 140,
},
{
id: 'createdAt',
accessorKey: 'createdAt',
header: t('backups.col.createdAt', 'Döredilen wagty'),
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.createdAt}</span>,
size: 160,
},
{
id: 'createdBy',
accessorKey: 'createdBy',
header: t('backups.col.createdBy', 'Döreden'),
size: 100,
},
{
id: 'actions',
header: '',
enableHiding: false,
cell: ({ row }) => (
<div className="flex items-center gap-1 justify-end">
<Button
variant="ghost" size="icon" className="h-7 w-7"
onClick={() => downloadBackup.mutate(row.original.id)}
disabled={row.original.status === 'in_progress'}
title={t('common.download', 'Ýükle')}
>
<Download size={14} />
</Button>
<Button
variant="ghost" size="icon"
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
onClick={() => setDeleteId(row.original.id)}
title={t('common.delete', 'Poz')}
>
<Trash2 size={14} />
</Button>
</div>
),
},
]
const columnMeta: ColumnMeta[] = columns
.filter((c) => c.id !== 'actions')
.map((c) => ({
id: c.id!,
label: typeof c.header === 'string' ? c.header : c.id!,
}))
const total = data?.total ?? 0
const totalPages = Math.ceil(total / perPage)
const handleDelete = async () => {
if (deleteId === null) return
await deleteBackup.mutateAsync(deleteId)
setDeleteId(null)
}
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h1 className="text-xl font-semibold text-foreground flex items-center gap-2">
<Database className="size-5 text-muted-foreground" />
{t('backups.title', 'Bekaplar')}
</h1>
</div>
<div className="bg-card border border-border rounded-xl p-4">
<DataTableToolbar
searchValue={search}
onSearchChange={(v) => { setSearch(v); setPage(1) }}
searchPlaceholder={t('common.search', 'Gözlemek')}
columns={columnMeta}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
perPageOptions={[10, 25, 50, 100]}
perPage={perPage}
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
actionLabel={createBackup.isPending ? t('common.loading', 'Döredilýär...') : t('backups.create', 'Backup dörediň')}
onAction={() => createBackup.mutate()}
/>
<DataTable
columns={columns}
data={data?.data ?? []}
isLoading={isLoading}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
enableRowSelection
getRowId={(row) => String(row.id)}
currentPage={page}
totalPages={totalPages}
totalCount={total}
onPageChange={setPage}
/>
</div>
<AlertDialog open={deleteId !== null} onOpenChange={(open) => !open && setDeleteId(null)}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{t('backups.deleteConfirm.title', 'Eminsiňizmi?')}</AlertDialogTitle>
<AlertDialogDescription>
{t('backups.deleteConfirm.description', 'Bu backup pozulsynmy? Bu amal yzyna gaýtarylmaz.')}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
<AlertDialogAction
onClick={handleDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deleteBackup.isPending ? t('common.deleting', 'Pozulýar...') : t('common.delete', 'Poz')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
)
}
@@ -1,11 +1,14 @@
import { useState } from "react";
import { useParams, useNavigate, Link } from "react-router-dom";
import { useParams, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Download, Trash2, Pencil, DownloadCloud } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
useCardRequisite,
useDeleteCardRequisite,
useDownloadCardRequisite,
} from "@/features/cardRequisites/hooks/useCardRequisites";
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
import { Spinner } from "@/components/ui/spinner";
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Pencil, Trash2, Download } from "lucide-react";
import {
AlertDialog,
AlertDialogAction,
@@ -15,268 +18,262 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import {
useCardRequisite,
useDeleteCardRequisite,
useDownloadCardRequisite,
} from "@/features/cardRequisites/hooks/useCardRequisites";
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
import { InfoRow } from "@/components/viewPageComponents";
// ─── Status badge ─────────────────────────────────────────────────────────────
StatusBadge,
type StatusBadgeVariant,
} from "@/components/ui/statusBadge";
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
// ─── Status config ────────────────────────────────────────────────────────────
const STATUS_VARIANT: Record<CardRequisiteStatus, StatusBadgeVariant> = {
pending: "warning",
approved: "success",
rejected: "error",
};
}
const STATUS_ICON: Record<CardRequisiteStatus, React.ElementType> = {
pending: AlertCircle,
approved: CheckCircle2,
rejected: XCircle,
};
}
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
const { t } = useTranslation();
const variant = STATUS_VARIANT[status];
const Icon = STATUS_ICON[status];
if (!variant)
return <span className="text-xs text-muted-foreground">{status}</span>;
return (
<StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
);
const { t } = useTranslation()
const variant = STATUS_VARIANT[status]
const Icon = STATUS_ICON[status]
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
return <StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
}
// ─── Section header ───────────────────────────────────────────────────────────
// ─── Bento primitives ─────────────────────────────────────────────────────────
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
const colClass = {
1: "grid-cols-1",
2: "grid-cols-1 sm:grid-cols-2",
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
}[cols]
return <div className={`grid ${colClass} gap-4`}>{children}</div>
}
function BentoCard({
title,
span,
children,
}: {
title?: string
span?: "full" | 2 | 3
children: React.ReactNode
}) {
const spanClass =
span === "full" ? "sm:col-span-full" :
span === 2 ? "sm:col-span-2" :
span === 3 ? "sm:col-span-3" : ""
function SectionTitle({ children }: { children: React.ReactNode }) {
return (
<h2 className="text-base font-semibold text-foreground mt-6 mb-3">
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
{title && (
<div className="px-4 py-2.5 border-b border-border">
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
{title}
</p>
</div>
)}
{children}
</h2>
);
}
// ─── Passport image row ───────────────────────────────────────────────────────
function PassportImageRow({ label, url }: { label: string; url?: string }) {
const { t } = useTranslation();
return (
<div className="grid grid-cols-[220px_1fr] border-b border-border/50 last:border-0">
<div className="px-4 py-3 text-sm text-muted-foreground font-medium bg-muted/10">
{label}
</div>
<div className="px-4 py-4 flex flex-col gap-2">
{url ? (
<>
<img
src={url}
alt={label}
className="max-w-[200px] rounded-md border border-border object-cover"
/>
<a
href={url}
download
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
>
<DownloadCloud size={13} />
{t("Download", "Göçürip al")}
</a>
</>
) : (
<span className="text-muted-foreground text-sm">—</span>
)}
</div>
</div>
);
)
}
// ─── Page ─────────────────────────────────────────────────────────────────────
export default function CardRequisiteViewPage() {
const { t } = useTranslation();
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const { id } = useParams<{ id: string }>()
const navigate = useNavigate()
const { t } = useTranslation()
const [deleteOpen, setDeleteOpen] = useState(false);
const { data, isLoading } = useCardRequisite(id ?? "");
const deleteMutation = useDeleteCardRequisite();
const downloadMutation = useDownloadCardRequisite();
const handleDelete = async () => {
await deleteMutation.mutateAsync(id ?? "");
navigate("/card-requisites");
};
const { data, isLoading, isError } = useCardRequisite(id ?? "")
const deleteMutation = useDeleteCardRequisite()
const downloadMutation = useDownloadCardRequisite()
if (isLoading) {
return (
<div className="flex items-center justify-center py-24">
<Spinner className="size-7 text-primary" />
<Spinner className="size-8 text-primary" />
</div>
);
)
}
if (!data) {
if (isError || !data) {
return (
<div className="text-center py-24 text-muted-foreground">
{t("Not found", "Tapylmady")}
<div className="flex items-center justify-center py-24 text-muted-foreground">
{t("common.notFound", "Maglumat tapylmady")}
</div>
);
)
}
return (
<div className="space-y-0">
{/* Header */}
<div className="flex items-center justify-between mb-4">
<h1 className="text-xl font-semibold text-foreground">
{t("Card requisite detail", "Kart rekwizit giňişleýin")}: {data.id}
<div className="mx-auto flex flex-col gap-6">
{/* ── Page header ──────────────────────────────────────────────────── */}
<div className="flex items-start justify-between">
<h1 className="text-xl font-bold text-foreground">
{t("cardRequisite.viewTitle", "Kart rekwizit giňişleýin")}: {data.id}
</h1>
<div className="flex items-center gap-2">
<Button
variant="outline"
size="sm"
size="icon" variant="ghost"
className="h-8 w-8"
onClick={() => downloadMutation.mutate(data.id)}
disabled={downloadMutation.isPending}
>
<Download size={14} />
<Download size={15} />
</Button>
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
size="icon"
variant="ghost"
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
>
<Trash2 size={15} />
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")}
</AlertDialogTitle>
<AlertDialogDescription>
{t("cardRequisite.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} {data.id}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={deleteMutation.isPending}>
{t("common.cancel", "Ýatyr")}
</AlertDialogCancel>
<AlertDialogAction
disabled={deleteMutation.isPending}
className="bg-destructive hover:bg-destructive/90"
onClick={() => deleteMutation.mutate(data.id, { onSuccess: () => navigate("/card-requisites") })}
>
{t("common.delete", "Poz")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<Button
variant="outline"
size="sm"
className="text-destructive border-destructive/30 hover:bg-destructive/10"
onClick={() => setDeleteOpen(true)}
size="icon" variant="ghost" className="h-8 w-8"
onClick={() => navigate(`/card-requisites/${id}/edit`)}
>
<Trash2 size={14} />
</Button>
<Button variant="outline" size="sm" asChild>
<Link to={`/card-requisites/${data.id}/edit`}>
<Pencil size={14} />
</Link>
<Pencil size={15} />
</Button>
</div>
</div>
{/* General info */}
<div className="rounded-lg border border-border bg-card overflow-hidden">
<InfoRow label={t("ID", "ID")}>{data.id}</InfoRow>
<InfoRow label={t("Created at", "Döredilen wagty")}>
{data.created_at}
</InfoRow>
<InfoRow label={t("Status", "Status")}>
<CardRequisiteStatusBadge status={data.status} />
</InfoRow>
<InfoRow label={t("Note", "Bellik")}>{data.note || "—"}</InfoRow>
<InfoRow label={t("Requested by", "Sargyt eden:")}>
{data.first_name && data.last_name ? (
<span className="text-primary font-medium">
{data.last_name}_{data.first_name} ({data.first_name})
</span>
) : (
"—"
)}
</InfoRow>
</div>
{/* ── Row 1: Meta + Kart + Lokasiýa ────────────────────────────────── */}
<BentoGrid cols={3}>
<BentoCard title={t("cardRequisite.metaSection", "Esasy maglumatlar")}>
<InfoRow label={t("common.id", "ID")}>
<span className="font-mono">{data.id}</span>
</InfoRow>
<InfoRow label={t("cardRequisite.createdAt", "Döredilen wagty")}>
{data.created_at}
</InfoRow>
<InfoRow label={t("cardRequisite.status", "Status")}>
<CardRequisiteStatusBadge status={data.status} />
</InfoRow>
<InfoRow label={t("cardRequisite.note", "Bellik")}>
{data.note || "—"}
</InfoRow>
<InfoRow label={t("cardRequisite.createdBy", "Sargyt eden")}>
{data.first_name && data.last_name ? (
<span className="text-primary font-medium">
{data.last_name}_{data.first_name}
</span>
) : "—"}
</InfoRow>
</BentoCard>
{/* Card */}
<SectionTitle>{t("Card", "Kart")}</SectionTitle>
<div className="rounded-lg border border-border bg-card overflow-hidden">
<InfoRow label={t("Card number", "Kart belgisi")}>
{data.card_number}
</InfoRow>
<InfoRow label={t("Card expiry month", "Kart Möhleti (aý)")}>
{data.card_expiry_month}
</InfoRow>
<InfoRow label={t("Card expiry year", "Kart Möhleti (ýyl)")}>
{data.card_expiry_year}
</InfoRow>
</div>
<BentoCard title={t("cardRequisite.cardSection", "Kart")}>
<InfoRow label={t("cardRequisite.cardNumber", "Kart belgisi")}>
<span className="font-mono tracking-wider">{data.card_number}</span>
</InfoRow>
<InfoRow label={t("cardRequisite.cardExpireMonth", "Kart Möhleti (aý)")}>
{data.card_expiry_month}
</InfoRow>
<InfoRow label={t("cardRequisite.cardExpireYear", "Kart Möhleti (ýyl)")}>
{data.card_expiry_year}
</InfoRow>
</BentoCard>
{/* Location */}
<SectionTitle>{t("Location", "Lokasiýa")}</SectionTitle>
<div className="rounded-lg border border-border bg-card overflow-hidden">
<InfoRow label={t("Province", "Welaýat")}>
{data.province_name ?? "—"}
</InfoRow>
<InfoRow label={t("Branch", "Şahamça")}>
<span className="text-primary font-medium">
{data.branch_name ?? "—"}
</span>
</InfoRow>
</div>
<BentoCard title={t("cardRequisite.locationSection", "Lokasiýa")}>
<InfoRow label={t("cardRequisite.province", "Welaýat")}>
{data.province_name ?? "—"}
</InfoRow>
<InfoRow label={t("cardRequisite.branch", "Şahamça")}>
<span className="text-primary font-medium">{data.branch_name ?? "—"}</span>
</InfoRow>
</BentoCard>
</BentoGrid>
{/* Personal */}
<SectionTitle>
{t("Personal information", "Şahsy maglumatlar")}
</SectionTitle>
<div className="rounded-lg border border-border bg-card overflow-hidden">
<InfoRow label={t("Full name", "Doly ady")}>
{[data.first_name, data.last_name, data.middle_name]
.filter(Boolean)
.join(" ")}
</InfoRow>
<InfoRow label={t("Birth date", "Doglan güni")}>
{data.birth_date}
</InfoRow>
<InfoRow label={t("Phone", "Telefon")}>{data.phone}</InfoRow>
</div>
{/* ── Row 2: Şahsy + Pasport maglumatlary ──────────────────────────── */}
<BentoGrid cols={2}>
<BentoCard title={t("cardRequisite.personalSection", "Şahsy maglumatlar")}>
<InfoRow label={t("cardRequisite.fullName", "Doly ady")}>
{[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(" ")}
</InfoRow>
<InfoRow label={t("cardRequisite.birthDate", "Doglan güni")}>
{data.birth_date}
</InfoRow>
<InfoRow label={t("cardRequisite.phone", "Telefon")}>
{data.phone}
</InfoRow>
</BentoCard>
{/* Passport */}
<SectionTitle>{t("Passport", "Pasport")}</SectionTitle>
<div className="rounded-lg border border-border bg-card overflow-hidden">
<InfoRow label={t("Passport series", "Pasport seriýasy")}>
{data.passport_series}
</InfoRow>
<InfoRow label={t("Passport number", "Pasport belgisi")}>
{data.passport_number}
</InfoRow>
<PassportImageRow
label={t("Passport (page 1)", "Pasport (sahypa 1)")}
url={data.passport_page1_url}
/>
<PassportImageRow
label={t("Passport (pages 2-3)", "Pasport (2-3-nji sahypa)")}
url={data.passport_page2_3_url}
/>
<PassportImageRow
label={t("Passport (pages 8-9)", "Pasport (8-9 sahypa)")}
url={data.passport_page8_9_url}
/>
<PassportImageRow
label={t("Passport (page 32)", "Pasport (32-nji sahypa)")}
url={data.passport_page32_url}
/>
</div>
<BentoCard title={t("cardRequisite.passportSection", "Pasport")}>
<InfoRow label={t("cardRequisite.passportSeries", "Pasport seriýasy")}>
{data.passport_series}
</InfoRow>
<InfoRow label={t("cardRequisite.passportNumber", "Pasport belgisi")}>
{data.passport_number}
</InfoRow>
</BentoCard>
</BentoGrid>
{/* ── Row 3: Passport images ────────────────────────────────────────── */}
<BentoGrid cols={4}>
<BentoCard title={t("cardRequisite.passportFile1", "Sahypa 1")}>
<PassportImage
label={t("cardRequisite.passportFile1", "Pasport (sahypa 1)")}
src={data.passport_page1_url}
/>
</BentoCard>
<BentoCard title={t("cardRequisite.passportFile2", "Sahypa 2-3")}>
<PassportImage
label={t("cardRequisite.passportFile2", "Pasport (2-3-nji sahypa)")}
src={data.passport_page2_3_url}
/>
</BentoCard>
<BentoCard title={t("cardRequisite.passportFile3", "Sahypa 8-9")}>
<PassportImage
label={t("cardRequisite.passportFile3", "Pasport (8-9 sahypa)")}
src={data.passport_page8_9_url}
/>
</BentoCard>
<BentoCard title={t("cardRequisite.passportFile4", "Sahypa 32")}>
<PassportImage
label={t("cardRequisite.passportFile4", "Pasport (32-nji sahypa)")}
src={data.passport_page32_url}
/>
</BentoCard>
</BentoGrid>
{/* Delete dialog */}
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t("Are you sure?", "Eminsiňizmi?")}
</AlertDialogTitle>
<AlertDialogDescription>
{t(
"This action cannot be undone.",
"Bu amal yzyna gaýtarylmaz. Kart rekwiziti hemişelik öçüriler.",
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
<AlertDialogAction
onClick={handleDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deleteMutation.isPending
? t("Deleting...", "Öçürilýär...")
: t("Delete", "Öçür")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
);
)
}
@@ -315,6 +315,7 @@ export default function CardOrdersPage() {
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
enableRowSelection
getRowId={(row) => row.id}
currentPage={page}
totalPages={data?.totalPages ?? 1}
@@ -42,7 +42,7 @@ export default function LoanTypeViewPage() {
// ── Skeleton ───────────────────────────────────────────────────────────────
if (isLoading) {
return (
<div className="p-6 max-w-3xl">
<div className="p-6">
<Skeleton className="h-4 w-64 mb-4" />
<Skeleton className="h-7 w-80 mb-6" />
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
@@ -68,7 +68,7 @@ export default function LoanTypeViewPage() {
// ── View ───────────────────────────────────────────────────────────────────
return (
<div className="p-6 max-w-3xl">
<div className="p-6">
{/* Page header */}
@@ -153,6 +153,7 @@ export default function PermissionsPage() {
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
enableRowSelection
getRowId={(row) => String(row.id)}
currentPage={data?.meta?.current_page ?? 1}
totalPages={data?.meta?.last_page ?? 1}
+1
View File
@@ -153,6 +153,7 @@ export default function RolesPage() {
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
enableRowSelection
getRowId={(row) => String(row.id)}
currentPage={data?.meta?.current_page ?? 1}
totalPages={data?.meta?.last_page ?? 1}
+1 -1
View File
@@ -122,7 +122,7 @@ export default function UserViewPage() {
}
return (
<div className="p-6 max-w-4xl space-y-0">
<div className="p-6 space-y-0">
{/* Title + actions */}
<div className="flex items-start justify-between mb-6">
<h1 className="text-xl font-bold text-foreground leading-tight">
+4 -12
View File
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useParams, useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Pencil, Trash2, ChevronDown } from 'lucide-react'
import { Pencil, Trash2, ChevronDown, XCircle, CheckCircle2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { ConfirmDialog } from '@/components/confirmDialog'
import { InfoRow, AuditLog } from '@/components/viewPageComponents'
@@ -54,18 +54,10 @@ function BentoCard({
function ActiveIndicator({ active }: { active: boolean }) {
return active ? (
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
<path d="M2 6l3 3 5-5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</span>
<CheckCircle2 size={18} className="text-emerald-500" />
) : (
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-destructive text-destructive">
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
</svg>
</span>
)
<XCircle size={18} className="text-destructive" />
);
}
// ─── CollapsibleSection ───────────────────────────────────────────────────────
+3 -11
View File
@@ -1,6 +1,6 @@
import { useParams, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Pencil, Trash2, ChevronDown } from "lucide-react";
import { Pencil, Trash2, ChevronDown, CheckCircle2, XCircle, } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { ConfirmDialog } from "@/components/confirmDialog";
@@ -41,17 +41,9 @@ function BentoCard({ title, span, children }: { title?: string; span?: "full" |
function ActiveIndicator({ active }: { active: boolean }) {
return active ? (
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
<path d="M2 6l3 3 5-5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</span>
<CheckCircle2 size={18} className="text-emerald-500" />
) : (
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-destructive text-destructive">
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
</svg>
</span>
<XCircle size={18} className="text-destructive" />
);
}