diff --git a/src/app/router/index.tsx b/src/app/router/index.tsx index 126dd5c..f342435 100644 --- a/src/app/router/index.tsx +++ b/src/app/router/index.tsx @@ -127,6 +127,8 @@ const DistrictsViewPage = lazy(() => import("@/pages/settings/location/districts const DistrictEditPage = lazy(() => import("@/pages/settings/location/districtsEdit")); const BranchesPage = lazy(() => import("@/pages/settings/location/branches")); + +const BackupsPage = lazy(() => import("@/pages/backups")); const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate")); const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView")); const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit")); @@ -949,6 +951,15 @@ export const router = createBrowserRouter([ ), }, + { + // Sidebar: /backups + path: "/backups", + element: ( + }> + + + ), + }, { // Sidebar: /settings/location/branches path: "/settings/location/branches", diff --git a/src/components/creditCardVisual.tsx b/src/components/creditCardVisual.tsx index c29654b..e895ab7 100644 --- a/src/components/creditCardVisual.tsx +++ b/src/components/creditCardVisual.tsx @@ -32,7 +32,7 @@ export function CreditCardVisual({ return (
{/* Glow effects */}
diff --git a/src/components/dataTable.tsx b/src/components/dataTable.tsx index 44aa8ce..9fd4319 100644 --- a/src/components/dataTable.tsx +++ b/src/components/dataTable.tsx @@ -124,7 +124,8 @@ interface SelectAllDropdownProps { isAllTotalSelected: boolean totalCount: number pageCount: number - onSelectPage: (checked: boolean) => void + onTogglePage: (checked: boolean) => void + onSelectThisPage: () => void onSelectAll: () => void onClearAll: () => void } @@ -135,7 +136,8 @@ function SelectAllDropdown({ isAllTotalSelected, totalCount, pageCount, - onSelectPage, + onTogglePage, + onSelectThisPage, onSelectAll, onClearAll, }: SelectAllDropdownProps) { @@ -143,28 +145,42 @@ function SelectAllDropdown({ const ref = useRef(null) useOutsideClick(ref, () => setOpen(false)) - const checkboxChecked = isAllPageSelected || (isSomePageSelected && 'indeterminate') + const checkboxChecked = isAllTotalSelected || isAllPageSelected + ? true + : isSomePageSelected + ? 'indeterminate' + : false return ( -
+
onSelectPage(!!value)} + checked={checkboxChecked} + onCheckedChange={(value) => onTogglePage(!!value)} aria-label="Select all on page" + onClick={(e) => e.stopPropagation()} + className="after:content-none" /> {open && ( -
+
), - cell: ({ row }) => ( - row.toggleSelected(!!value)} - aria-label="Select row" - onClick={(e) => e.stopPropagation()} - /> - ), + cell: ({ row, table }) => { + const isSelected = allTotalSelected || row.getIsSelected() + return ( + { + if (allTotalSelected && !value) { + const newSelection: RowSelectionState = {} + table.getRowModel().rows.forEach((r) => { + if (r.id !== row.id) { + newSelection[r.id] = true + } + }) + table.setRowSelection(newSelection) + setAllTotalSelected(false) + } else { + row.toggleSelected(!!value) + } + }} + aria-label="Select row" + onClick={(e) => e.stopPropagation()} + /> + ) + }, enableSorting: false, enableHiding: false, size: 48, @@ -357,6 +405,7 @@ export function DataTable({ + +
+ ), + }, + ] + + 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 ( +
+
+

+ + {t('backups.title', 'Bekaplar')} +

+
+ +
+ { 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()} + /> + + String(row.id)} + currentPage={page} + totalPages={totalPages} + totalCount={total} + onPageChange={setPage} + /> +
+ + !open && setDeleteId(null)}> + + + {t('backups.deleteConfirm.title', 'Eminsiňizmi?')} + + {t('backups.deleteConfirm.description', 'Bu backup pozulsynmy? Bu amal yzyna gaýtarylmaz.')} + + + + {t('common.cancel', 'Ýatyr')} + + {deleteBackup.isPending ? t('common.deleting', 'Pozulýar...') : t('common.delete', 'Poz')} + + + + +
+ ) +} diff --git a/src/pages/cardDepartment/cardRequisitesView/index.tsx b/src/pages/cardDepartment/cardRequisitesView/index.tsx index be6a5fb..e6ed400 100644 --- a/src/pages/cardDepartment/cardRequisitesView/index.tsx +++ b/src/pages/cardDepartment/cardRequisitesView/index.tsx @@ -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 = { pending: "warning", approved: "success", rejected: "error", -}; +} const STATUS_ICON: Record = { 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 {status}; - return ( - - ); + const { t } = useTranslation() + const variant = STATUS_VARIANT[status] + const Icon = STATUS_ICON[status] + if (!variant) return {status} + return } -// ─── 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
{children}
+} + +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 ( -

+
+ {title && ( +
+

+ {title} +

+
+ )} {children} -

- ); -} - -// ─── Passport image row ─────────────────────────────────────────────────────── - -function PassportImageRow({ label, url }: { label: string; url?: string }) { - const { t } = useTranslation(); - return ( -
-
- {label} -
-
- {url ? ( - <> - {label} - - - {t("Download", "Göçürip al")} - - - ) : ( - — - )} -
- ); + ) } // ─── 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 (
- +
- ); + ) } - if (!data) { + if (isError || !data) { return ( -
- {t("Not found", "Tapylmady")} +
+ {t("common.notFound", "Maglumat tapylmady")}
- ); + ) } - return ( -
- {/* Header */} -
-

- {t("Card requisite detail", "Kart rekwizit giňişleýin")}: {data.id} +
+ + {/* ── Page header ──────────────────────────────────────────────────── */} +
+

+ {t("cardRequisite.viewTitle", "Kart rekwizit giňişleýin")}: {data.id}

+ + + + + + + + {t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")} + + + {t("cardRequisite.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} {data.id} + + + + + {t("common.cancel", "Ýatyr")} + + deleteMutation.mutate(data.id, { onSuccess: () => navigate("/card-requisites") })} + > + {t("common.delete", "Poz")} + + + + + -
- {/* General info */} -
- {data.id} - - {data.created_at} - - - - - {data.note || "—"} - - {data.first_name && data.last_name ? ( - - {data.last_name}_{data.first_name} ({data.first_name}) - - ) : ( - "—" - )} - -
+ {/* ── Row 1: Meta + Kart + Lokasiýa ────────────────────────────────── */} + + + + {data.id} + + + {data.created_at} + + + + + + {data.note || "—"} + + + {data.first_name && data.last_name ? ( + + {data.last_name}_{data.first_name} + + ) : "—"} + + - {/* Card */} - {t("Card", "Kart")} -
- - {data.card_number} - - - {data.card_expiry_month} - - - {data.card_expiry_year} - -
+ + + {data.card_number} + + + {data.card_expiry_month} + + + {data.card_expiry_year} + + - {/* Location */} - {t("Location", "Lokasiýa")} -
- - {data.province_name ?? "—"} - - - - {data.branch_name ?? "—"} - - -
+ + + {data.province_name ?? "—"} + + + {data.branch_name ?? "—"} + + +
- {/* Personal */} - - {t("Personal information", "Şahsy maglumatlar")} - -
- - {[data.first_name, data.last_name, data.middle_name] - .filter(Boolean) - .join(" ")} - - - {data.birth_date} - - {data.phone} -
+ {/* ── Row 2: Şahsy + Pasport maglumatlary ──────────────────────────── */} + + + + {[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(" ")} + + + {data.birth_date} + + + {data.phone} + + - {/* Passport */} - {t("Passport", "Pasport")} -
- - {data.passport_series} - - - {data.passport_number} - - - - - -
+ + + {data.passport_series} + + + {data.passport_number} + + +
+ + {/* ── Row 3: Passport images ────────────────────────────────────────── */} + + + + + + + + + + + + + + - {/* Delete dialog */} - - - - - {t("Are you sure?", "Eminsiňizmi?")} - - - {t( - "This action cannot be undone.", - "Bu amal yzyna gaýtarylmaz. Kart rekwiziti hemişelik öçüriler.", - )} - - - - {t("Cancel", "Ýatyr")} - - {deleteMutation.isPending - ? t("Deleting...", "Öçürilýär...") - : t("Delete", "Öçür")} - - - -
- ); + ) } diff --git a/src/pages/cardDepartment/orderNewCard/index.tsx b/src/pages/cardDepartment/orderNewCard/index.tsx index 9247b44..1f8bfd2 100644 --- a/src/pages/cardDepartment/orderNewCard/index.tsx +++ b/src/pages/cardDepartment/orderNewCard/index.tsx @@ -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} diff --git a/src/pages/settings/loan/loanTypesView/index.tsx b/src/pages/settings/loan/loanTypesView/index.tsx index b488eea..bc72fd8 100644 --- a/src/pages/settings/loan/loanTypesView/index.tsx +++ b/src/pages/settings/loan/loanTypesView/index.tsx @@ -42,7 +42,7 @@ export default function LoanTypeViewPage() { // ── Skeleton ─────────────────────────────────────────────────────────────── if (isLoading) { return ( -
+
@@ -68,7 +68,7 @@ export default function LoanTypeViewPage() { // ── View ─────────────────────────────────────────────────────────────────── return ( -
+
{/* Page header */} diff --git a/src/pages/settings/users/permissions/index.tsx b/src/pages/settings/users/permissions/index.tsx index 4df3660..ec0b9d6 100644 --- a/src/pages/settings/users/permissions/index.tsx +++ b/src/pages/settings/users/permissions/index.tsx @@ -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} diff --git a/src/pages/settings/users/roles/index.tsx b/src/pages/settings/users/roles/index.tsx index 13191f9..5987a4d 100644 --- a/src/pages/settings/users/roles/index.tsx +++ b/src/pages/settings/users/roles/index.tsx @@ -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} diff --git a/src/pages/users/allUsersView/index.tsx b/src/pages/users/allUsersView/index.tsx index b206bd5..dad507a 100644 --- a/src/pages/users/allUsersView/index.tsx +++ b/src/pages/users/allUsersView/index.tsx @@ -122,7 +122,7 @@ export default function UserViewPage() { } return ( -
+
{/* Title + actions */}

diff --git a/src/pages/users/clientsView/index.tsx b/src/pages/users/clientsView/index.tsx index 2aa951b..3d07d9d 100644 --- a/src/pages/users/clientsView/index.tsx +++ b/src/pages/users/clientsView/index.tsx @@ -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 ? ( - - - - - + ) : ( - - - - - - ) + + ); } // ─── CollapsibleSection ─────────────────────────────────────────────────────── diff --git a/src/pages/users/operatorsView/index.tsx b/src/pages/users/operatorsView/index.tsx index a55859a..1d5866b 100644 --- a/src/pages/users/operatorsView/index.tsx +++ b/src/pages/users/operatorsView/index.tsx @@ -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 ? ( - - - - - + ) : ( - - - - - + ); }