added missin lang keys
This commit is contained in:
1 parent
a38d2615fd
commit
ad8d9528be
36 files changed
+949
-667
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Download, Eye, Pencil, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Eye, Pencil, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -12,200 +12,197 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ColumnMeta } from '@/components/dataTableToolbar'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
import {
|
||||
useCardBalances,
|
||||
useDeleteCardBalance,
|
||||
useDownloadCardBalance,
|
||||
} from '@/features/cardBalance/hooks/useCardBalance'
|
||||
import { type CardBalance } from '@/features/cardBalance/api/cardBalanceApi'
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
import { useCardBalances, useDeleteCardBalance, useDownloadCardBalance } from "@/features/cardBalance/hooks/useCardBalance";
|
||||
import { type CardBalance } from "@/features/cardBalance/api/cardBalanceApi";
|
||||
|
||||
const PER_PAGE = 25
|
||||
const PER_PAGE = 25;
|
||||
|
||||
export default function CardBalancesPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
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 [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 } = useCardBalances({ page, per_page: perPage, search })
|
||||
const deleteMutation = useDeleteCardBalance()
|
||||
const downloadMutation = useDownloadCardBalance()
|
||||
const { data, isLoading } = useCardBalances({ page, per_page: perPage, search });
|
||||
const deleteMutation = useDeleteCardBalance();
|
||||
const downloadMutation = useDownloadCardBalance();
|
||||
|
||||
// ── Columns ───────────────────────────────────────────────────────────────
|
||||
|
||||
const columns: ColumnDef<CardBalance>[] = [
|
||||
{
|
||||
id: 'id',
|
||||
accessorKey: 'id',
|
||||
header: t('ID', 'ID'),
|
||||
id: "id",
|
||||
accessorKey: "id",
|
||||
header: t("ID", "ID"),
|
||||
cell: ({ row }) => (
|
||||
<button
|
||||
className="text-primary font-medium hover:underline"
|
||||
onClick={() => navigate(`/card-balances/${row.original.id}`)}
|
||||
>
|
||||
<button className="text-primary font-medium hover:underline" onClick={() => navigate(`/card-balances/${row.original.id}`)}>
|
||||
{row.original.id}
|
||||
</button>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'passport_series',
|
||||
accessorKey: 'passport_series',
|
||||
header: t('Passport series', 'PASPORT SERIYASY'),
|
||||
id: "passport_series",
|
||||
accessorKey: "passport_series",
|
||||
header: t("Passport series", "PASPORT SERIYASY"),
|
||||
cell: ({ row }) => <span>{row.original.passport_series}</span>,
|
||||
},
|
||||
{
|
||||
id: 'passport_number',
|
||||
accessorKey: 'passport_number',
|
||||
header: t('Passport number', 'PASPORT BELGISI'),
|
||||
id: "passport_number",
|
||||
accessorKey: "passport_number",
|
||||
header: t("Passport number", "PASPORT BELGISI"),
|
||||
cell: ({ row }) => <span>{row.original.passport_number}</span>,
|
||||
},
|
||||
{
|
||||
id: 'card_number',
|
||||
accessorKey: 'card_number',
|
||||
header: t('Card number', 'KART BELGISI'),
|
||||
id: "card_number",
|
||||
accessorKey: "card_number",
|
||||
header: t("Card number", "KART BELGISI"),
|
||||
cell: ({ row }) => <span className="font-mono">{row.original.card_number}</span>,
|
||||
},
|
||||
{
|
||||
id: 'card_expiry_month',
|
||||
accessorKey: 'card_expiry_month',
|
||||
header: t('Expiry month', 'KART MÖHLETI (AÝ)'),
|
||||
id: "card_expiry_month",
|
||||
accessorKey: "card_expiry_month",
|
||||
header: t("Expiry month", "KART MÖHLETI (AÝ)"),
|
||||
cell: ({ row }) => <span>{row.original.card_expiry_month}</span>,
|
||||
},
|
||||
{
|
||||
id: 'card_expiry_year',
|
||||
accessorKey: 'card_expiry_year',
|
||||
header: t('Expiry year', 'KART MÖHLETI (ÝYL)'),
|
||||
id: "card_expiry_year",
|
||||
accessorKey: "card_expiry_year",
|
||||
header: t("Expiry year", "KART MÖHLETI (ÝYL)"),
|
||||
cell: ({ row }) => <span>{row.original.card_expiry_year}</span>,
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
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"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => downloadMutation.mutate(row.original.id)}
|
||||
title={t('Download', 'Ýükle')}
|
||||
title={t("Download", "Ýükle")}
|
||||
>
|
||||
<Download size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost" size="icon" className="h-7 w-7"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => navigate(`/card-balances/${row.original.id}`)}
|
||||
title={t('View', 'Görmek')}
|
||||
title={t("View", "Görmek")}
|
||||
>
|
||||
<Eye size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost" size="icon" className="h-7 w-7"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => navigate(`/card-balances/${row.original.id}/edit`)}
|
||||
title={t('Edit', 'Üýtgetmek')}
|
||||
title={t("Edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost" size="icon"
|
||||
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('Delete', 'Öçürmek')}
|
||||
title={t("Delete", "Öçürmek")}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
const columnMeta: ColumnMeta[] = columns
|
||||
.filter((c) => c.id !== 'actions')
|
||||
.filter((c) => c.id !== "actions")
|
||||
.map((c) => ({
|
||||
id: c.id!,
|
||||
label: typeof c.header === 'string' ? c.header : c.id!,
|
||||
}))
|
||||
label: typeof c.header === "string" ? c.header : c.id!,
|
||||
}));
|
||||
|
||||
const total = data?.total ?? 0
|
||||
const totalPages = Math.ceil(total / perPage)
|
||||
const total = data?.total ?? 0;
|
||||
const totalPages = Math.ceil(total / perPage);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (deleteId === null) return
|
||||
await deleteMutation.mutateAsync(deleteId)
|
||||
setDeleteId(null)
|
||||
}
|
||||
if (deleteId === null) return;
|
||||
await deleteMutation.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">
|
||||
{t('Card balances', 'Kart galyndylary')}
|
||||
</h1>
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("Card balances", "Kart galyndylary")}</h1>
|
||||
</div>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<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}
|
||||
actionLabel={t("Create card balance", "Kart galyndysy dörediň")}
|
||||
onAction={() => navigate("/card-balances/create")}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
/>
|
||||
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => { setSearch(v); setPage(1) }}
|
||||
searchPlaceholder={t('Search', 'Gözlemek')}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
actionLabel={t('Create card balance', 'Kart galyndysy dörediň')}
|
||||
onAction={() => navigate('/card-balances/create')}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||
/>
|
||||
|
||||
<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>
|
||||
<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('Are you sure?', 'Eminsiňizmi?')}</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t("Are you sure?", "Eminsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'This action cannot be undone.',
|
||||
'Bu amal yzyna gaýtarylmaz. Kart galyndysy hemişelik öçüriler.',
|
||||
)}
|
||||
{t("This action cannot be undone.", "Bu amal yzyna gaýtarylmaz. Kart galyndysy 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')}
|
||||
<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>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Trash2, Pencil, ChevronDown } from "lucide-react";
|
||||
import { Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
@@ -19,7 +19,9 @@ import {
|
||||
useDeleteCardBalance,
|
||||
useDownloadCardBalance,
|
||||
} from "@/features/cardBalance/hooks/useCardBalance";
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
import { InfoRow, CollapsibleSection, StatusBadge, EmptyState } from "@/components/viewPageComponents";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
|
||||
// ─── Types for operations table ───────────────────────────────────────────────
|
||||
|
||||
@@ -32,25 +34,6 @@ interface Operation {
|
||||
date: string;
|
||||
}
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_STYLES: Record<string, string> = {
|
||||
FINISHED: "bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",
|
||||
PENDING: "bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",
|
||||
FAILED: "bg-red-500/20 text-red-400 border border-red-500/30",
|
||||
};
|
||||
|
||||
function OpStatusBadge({ status }: { status: string }) {
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold ${STATUS_STYLES[status] ?? STATUS_STYLES.PENDING}`}
|
||||
>
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-current" />
|
||||
{status}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardBalanceViewPage() {
|
||||
@@ -59,8 +42,7 @@ export default function CardBalanceViewPage() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
const [opsExpanded, setOpsExpanded] = useState(true);
|
||||
const [opsPage, setOpsPage] = useState(1);
|
||||
const [opsSearch, setOpsSearch] = useState("");
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useCardBalance(numericId);
|
||||
@@ -69,7 +51,58 @@ export default function CardBalanceViewPage() {
|
||||
|
||||
// Placeholder operations — in real app fetch from API using numericId
|
||||
const operations: Operation[] = [];
|
||||
const opsTotal = operations.length;
|
||||
|
||||
const filteredOperations = operations.filter(
|
||||
(op) =>
|
||||
op.action_name.toLowerCase().includes(opsSearch.toLowerCase()) ||
|
||||
op.target.toLowerCase().includes(opsSearch.toLowerCase()),
|
||||
);
|
||||
|
||||
// ── Operations columns ──────────────────────────────────────────────────
|
||||
|
||||
const operationColumns: ColumnDef<Operation>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("ID", "ID"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-semibold text-sm">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
accessorKey: "action_name",
|
||||
header: t("Action name", "AMALYŇ ADY"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.action_name}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "performed_by",
|
||||
header: t("Performed by", "KIM TARAPYNDAN"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.performed_by}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "target",
|
||||
header: t("Target", "AMALYŇ NYŞANY (TARGEDI)"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.target}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("Status", "AMALYŇ STATUSY"),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
accessorKey: "date",
|
||||
header: t("Date", "SENE"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-muted-foreground whitespace-nowrap">
|
||||
{row.original.date}
|
||||
</span>
|
||||
),
|
||||
size: 160,
|
||||
},
|
||||
];
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(numericId);
|
||||
@@ -158,100 +191,33 @@ export default function CardBalanceViewPage() {
|
||||
</div>
|
||||
|
||||
{/* Ammallar (Operations) collapsible section */}
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
{/* Section toggle header */}
|
||||
<button
|
||||
className="w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-muted/20 transition-colors"
|
||||
onClick={() => setOpsExpanded((v) => !v)}
|
||||
>
|
||||
<span className="font-semibold text-foreground text-sm">
|
||||
{t("Operations", "Ammallar")}
|
||||
</span>
|
||||
<ChevronDown
|
||||
size={15}
|
||||
className={`text-muted-foreground transition-transform duration-200 ${opsExpanded ? "rotate-180" : ""}`}
|
||||
<CollapsibleSection title={t("Operations", "Ammallar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={opsSearch}
|
||||
onSearchChange={setOpsSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
/>
|
||||
{filteredOperations.length === 0 ? (
|
||||
<EmptyState
|
||||
label={t(
|
||||
"No operations found",
|
||||
"Berlen kriterýalara Amal gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<DataTable
|
||||
columns={operationColumns}
|
||||
data={filteredOperations}
|
||||
getRowId={(r) => String(r.id)}
|
||||
enableRowSelection
|
||||
/>
|
||||
</button>
|
||||
|
||||
{opsExpanded && (
|
||||
<>
|
||||
<div className="overflow-x-auto border-t border-border">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="bg-muted/30 border-b border-border">
|
||||
{[
|
||||
t("ID", "ID"),
|
||||
t("Action name", "AMALYŇ ADY"),
|
||||
t("Performed by", "KIM TARAPYNDAN"),
|
||||
t("Target", "AMALYŇ NYŞANY (TARGEDI)"),
|
||||
t("Status", "AMALYŇ STATUSY"),
|
||||
t("Date", "SENE"),
|
||||
].map((h) => (
|
||||
<th
|
||||
key={h}
|
||||
className="text-left px-4 py-2.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide whitespace-nowrap"
|
||||
>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{operations.length === 0 ? (
|
||||
<tr>
|
||||
<td
|
||||
colSpan={6}
|
||||
className="text-center py-10 text-muted-foreground text-sm"
|
||||
>
|
||||
{t("No operations found", "Amal tapylmady")}
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
operations.map((op) => (
|
||||
<tr
|
||||
key={op.id}
|
||||
className="border-b border-border/50 hover:bg-muted/20 transition-colors"
|
||||
>
|
||||
<td className="px-4 py-3 text-primary font-medium">
|
||||
{op.id}
|
||||
</td>
|
||||
<td className="px-4 py-3">{op.action_name}</td>
|
||||
<td className="px-4 py-3">{op.performed_by}</td>
|
||||
<td className="px-4 py-3">{op.target}</td>
|
||||
<td className="px-4 py-3">
|
||||
<OpStatusBadge status={op.status} />
|
||||
</td>
|
||||
<td className="px-4 py-3 text-muted-foreground">
|
||||
{op.date}
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* Ops pagination */}
|
||||
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-sm text-muted-foreground">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={opsPage <= 1}
|
||||
onClick={() => setOpsPage((p) => p - 1)}
|
||||
>
|
||||
{t("Previous", "Öňki")}
|
||||
</Button>
|
||||
<span>
|
||||
{opsTotal === 0 ? "0" : `1–${opsTotal}`} {t("of", "of")}{" "}
|
||||
{opsTotal}
|
||||
</span>
|
||||
<Button variant="ghost" size="sm" disabled={true}>
|
||||
{t("Next", "Indiki")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
|
||||
@@ -219,7 +219,7 @@ export default function CardPinsPage() {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("cardPin.search", "Gözlemek")}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
|
||||
@@ -233,14 +233,14 @@ export default function CardRequisitesPage() {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("Search", "Gözlemek")}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
actionLabel={t(
|
||||
"Create card requisite order",
|
||||
"cardRequisites.createTitle",
|
||||
"Kart rekwiziti üçin sargyt dörediň",
|
||||
)}
|
||||
onAction={() => navigate("/card-requisites/create")}
|
||||
|
||||
@@ -164,7 +164,7 @@ export default function CardTransactionsPage() {
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => { setSearch(v); setPage(1) }}
|
||||
searchPlaceholder={t('Search', 'Gözlemek')}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
|
||||
@@ -19,27 +19,15 @@ import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
PENDING: {
|
||||
label: 'Garaşylýar',
|
||||
variant: 'warning' as StatusBadgeVariant,
|
||||
icon: AlertCircle,
|
||||
},
|
||||
APPROVED: {
|
||||
label: 'Tassyklandy',
|
||||
variant: 'success' as StatusBadgeVariant,
|
||||
icon: CheckCircle2,
|
||||
},
|
||||
REJECTED: {
|
||||
label: 'Ýatyryldy',
|
||||
variant: 'error' as StatusBadgeVariant,
|
||||
icon: XCircle,
|
||||
},
|
||||
} satisfies Record<CardOrderStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
|
||||
function OrderNewCardStatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const STATUS_CONFIG = {
|
||||
PENDING: { label: t('cardOrder.status.pending', 'Garaşylýar'), variant: 'warning' as StatusBadgeVariant, icon: AlertCircle },
|
||||
APPROVED: { label: t('cardOrder.status.approved', 'Tassyklandy'), variant: 'success' as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
REJECTED: { label: t('cardOrder.status.rejected', 'Ýatyryldy'), variant: 'error' as StatusBadgeVariant, icon: XCircle },
|
||||
}
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
}
|
||||
|
||||
@@ -55,26 +43,11 @@ function HighlightText({ value, variant }: { value: string; variant: 'teal' | 'c
|
||||
return <span className={cls}>{value}</span>
|
||||
}
|
||||
|
||||
// ─── Column meta (toolbar toggle) ────────────────────────────────────────────
|
||||
|
||||
const COLUMN_META = [
|
||||
{ id: 'id', label: 'ID' },
|
||||
{ id: 'issuanceReasonName', label: 'Sebäp' },
|
||||
{ id: 'createdAt', label: 'Döredilen wagty' },
|
||||
{ id: 'cardTypeName', label: 'Görnüşi' },
|
||||
{ id: 'provinceName', label: 'Welaýat' },
|
||||
{ id: 'branchName', label: 'Şahamça' },
|
||||
{ id: 'fullName', label: 'Ady' },
|
||||
{ id: 'status', label: 'Status' },
|
||||
]
|
||||
|
||||
const SPECIAL_BRANCHES = [
|
||||
'Köpetdag', 'Türkmenabat', 'Türkmenbaşy',
|
||||
'Seýdi', 'Çandybil', 'Balkan', 'Baş bank',
|
||||
]
|
||||
|
||||
const DEFAULT_ORDER = COLUMN_META.map((c) => c.id)
|
||||
|
||||
// ─── CardOrdersPage ───────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardOrdersPage() {
|
||||
@@ -83,6 +56,22 @@ export default function CardOrdersPage() {
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
// ── Column meta (toolbar toggle) ──────────────────────────────────────────
|
||||
const COLUMN_META = useMemo(
|
||||
() => [
|
||||
{ id: 'id', label: t('cardOrder.col.id', 'ID') },
|
||||
{ id: 'issuanceReasonName', label: t('cardOrder.col.reason', 'Sebäp') },
|
||||
{ id: 'createdAt', label: t('cardOrder.col.createdAt', 'Döredilen wagty') },
|
||||
{ id: 'cardTypeName', label: t('cardOrder.col.cardType', 'Görnüşi') },
|
||||
{ id: 'provinceName', label: t('cardOrder.col.province', 'Welaýat') },
|
||||
{ id: 'branchName', label: t('cardOrder.col.branch', 'Şahamça') },
|
||||
{ id: 'fullName', label: t('cardOrder.col.name', 'Ady') },
|
||||
{ id: 'status', label: t('cardOrder.col.status', 'Status') },
|
||||
],
|
||||
[t]
|
||||
)
|
||||
const DEFAULT_ORDER = useMemo(() => COLUMN_META.map((c) => c.id), [COLUMN_META])
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
const [page, setPage] = useState(1)
|
||||
|
||||
Reference in new issue
Block a user