fixed some ui
This commit is contained in:
1 parent
d46c951b7d
commit
a6981e2775
30 files changed
+3093
-3006
No files matched your search
@@ -149,6 +149,7 @@ export default function CardBalancesPage() {
|
||||
{t('Card balances', 'Kart galyndylary')}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
@@ -181,6 +182,7 @@ export default function CardBalancesPage() {
|
||||
totalCount={total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialog open={deleteId !== null} onOpenChange={(open) => !open && setDeleteId(null)}>
|
||||
<AlertDialogContent>
|
||||
|
||||
@@ -11,7 +11,14 @@ import type {
|
||||
CardPinStatus,
|
||||
} from "@/features/cardPins/api/cardPinApi";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
Eye,
|
||||
Pencil,
|
||||
Trash2,
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -25,33 +32,43 @@ import {
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
pending: {
|
||||
label: 'Garaşylýar',
|
||||
variant: 'warning' as StatusBadgeVariant,
|
||||
icon: AlertCircle,
|
||||
label: "Garaşylýar",
|
||||
variant: "warning" as StatusBadgeVariant,
|
||||
icon: AlertCircle,
|
||||
},
|
||||
approved: {
|
||||
label: 'Tassyklandy',
|
||||
variant: 'success' as StatusBadgeVariant,
|
||||
icon: CheckCircle2,
|
||||
label: "Tassyklandy",
|
||||
variant: "success" as StatusBadgeVariant,
|
||||
icon: CheckCircle2,
|
||||
},
|
||||
rejected: {
|
||||
label: 'Ýatyryldy',
|
||||
variant: 'error' as StatusBadgeVariant,
|
||||
icon: XCircle,
|
||||
label: "Ýatyryldy",
|
||||
variant: "error" as StatusBadgeVariant,
|
||||
icon: XCircle,
|
||||
},
|
||||
} satisfies Record<CardPinStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
} satisfies Record<
|
||||
CardPinStatus,
|
||||
{ label: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||
>;
|
||||
|
||||
function CardPinStatusStatusBadge({ status }: { status: CardPinStatus }) {
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg)
|
||||
return (
|
||||
<span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
);
|
||||
return (
|
||||
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -137,7 +154,9 @@ export default function CardPinsPage() {
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("cardPin.status", "Status"),
|
||||
cell: ({ row }) => <CardPinStatusStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => (
|
||||
<CardPinStatusStatusBadge status={row.original.status} />
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
@@ -193,62 +212,64 @@ export default function CardPinsPage() {
|
||||
{t("Card pins", "Kart pin bukjalary")}
|
||||
</h1>
|
||||
</div>
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("cardPin.search", "Gözlemek")}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={[
|
||||
{
|
||||
id: "status",
|
||||
label: t("cardPin.status", "Status"),
|
||||
options: [
|
||||
{ value: "pending", label: "Garaşylýar" },
|
||||
{ value: "approved", label: "Tassyklandy" },
|
||||
{ value: "rejected", label: "Ret edildi" },
|
||||
],
|
||||
},
|
||||
]}
|
||||
activeFilters={[{ fieldId: "status", value: statusFilter }]}
|
||||
onFilterChange={(fieldId, value) => {
|
||||
if (fieldId === "status")
|
||||
setStatusFilter(value as CardPinStatus | "");
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterReset={() => {
|
||||
setStatusFilter("");
|
||||
setPage(1);
|
||||
}}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
actionLabel={t("cardPin.createBtn", "Kart pin bukja dörediň")}
|
||||
onAction={() => navigate("/card-pins/create")}
|
||||
/>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("cardPin.search", "Gözlemek")}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={[
|
||||
{
|
||||
id: "status",
|
||||
label: t("cardPin.status", "Status"),
|
||||
options: [
|
||||
{ value: "pending", label: "Garaşylýar" },
|
||||
{ value: "approved", label: "Tassyklandy" },
|
||||
{ value: "rejected", label: "Ret edildi" },
|
||||
],
|
||||
},
|
||||
]}
|
||||
activeFilters={[{ fieldId: "status", value: statusFilter }]}
|
||||
onFilterChange={(fieldId, value) => {
|
||||
if (fieldId === "status")
|
||||
setStatusFilter(value as CardPinStatus | "");
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterReset={() => {
|
||||
setStatusFilter("");
|
||||
setPage(1);
|
||||
}}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
actionLabel={t("cardPin.createBtn", "Kart pin bukja dörediň")}
|
||||
onAction={() => navigate("/card-pins/create")}
|
||||
/>
|
||||
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
currentPage={data?.meta?.current_page ?? 1}
|
||||
totalPages={data?.meta?.last_page ?? 1}
|
||||
totalCount={data?.meta?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
currentPage={data?.meta?.current_page ?? 1}
|
||||
totalPages={data?.meta?.last_page ?? 1}
|
||||
totalCount={data?.meta?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete confirmation */}
|
||||
<AlertDialog
|
||||
|
||||
@@ -25,56 +25,77 @@ import {
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
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<
|
||||
CardPinStatus,
|
||||
{ label: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||
>;
|
||||
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<CardPinStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
|
||||
function CardPinStatusBadge({ status }: { status: CardPinStatus }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg)
|
||||
return (
|
||||
<span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
);
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
}
|
||||
|
||||
// ─── 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" : ""
|
||||
|
||||
return (
|
||||
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
);
|
||||
<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}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardPinViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { data, isLoading, isError } = useCardPin(id!);
|
||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin();
|
||||
const { data, isLoading, isError } = useCardPin(id!)
|
||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin()
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-8 text-primary" />
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
@@ -82,12 +103,13 @@ export default function CardPinViewPage() {
|
||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto space-y-6">
|
||||
{/* Header */}
|
||||
<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("cardPin.viewTitle", "Kart pin bukja giňişleýin")}: {data.id}
|
||||
@@ -120,11 +142,7 @@ export default function CardPinViewPage() {
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() =>
|
||||
deletePin(data.id, {
|
||||
onSuccess: () => navigate("/card-pins"),
|
||||
})
|
||||
}
|
||||
onClick={() => deletePin(data.id, { onSuccess: () => navigate("/card-pins") })}
|
||||
>
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
@@ -143,33 +161,27 @@ export default function CardPinViewPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Info */}
|
||||
<section className="bg-card border border-border rounded-lg px-6">
|
||||
<InfoRow label="ID">
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")}>
|
||||
{data.created_at}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.status", "Status")}>
|
||||
<CardPinStatusBadge status={data.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.note", "Bellik")}>
|
||||
{data.note || "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">
|
||||
{data.created_by_label}
|
||||
</span>
|
||||
</InfoRow>
|
||||
</section>
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardPin.metaSection", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID">
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")}>
|
||||
{data.created_at}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.status", "Status")}>
|
||||
<CardPinStatusBadge status={data.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.note", "Bellik")}>
|
||||
{data.note || "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{data.created_by_label}</span>
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
{/* Kart */}
|
||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||
{t("cardPin.cardSection", "Kart")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border">
|
||||
<BentoCard title={t("cardPin.cardSection", "Kart")}>
|
||||
<InfoRow label={t("cardPin.cardNumber", "Kart belgisi")}>
|
||||
<span className="font-mono tracking-wider">{data.card_number}</span>
|
||||
</InfoRow>
|
||||
@@ -179,74 +191,70 @@ export default function CardPinViewPage() {
|
||||
<InfoRow label={t("cardPin.cardExpireYear", "Kart Möhleti (ýyl)")}>
|
||||
—
|
||||
</InfoRow>
|
||||
</div>
|
||||
</section>
|
||||
</BentoCard>
|
||||
|
||||
{/* Lokasiýa */}
|
||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||
{t("cardPin.locationSection", "Lokasiýa")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border">
|
||||
<BentoCard title={t("cardPin.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardPin.province", "Welaýat")}>
|
||||
{data.province_label}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.branch", "Şahamça")}>
|
||||
<span className="text-primary font-medium">
|
||||
{data.branch_label}
|
||||
</span>
|
||||
<span className="text-primary font-medium">{data.branch_label}</span>
|
||||
</InfoRow>
|
||||
</div>
|
||||
</section>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* Şahsy maglumatlar */}
|
||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||
{t("cardPin.personalSection", "Şahsy maglumatlar")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border">
|
||||
{/* ── Row 2: Şahsy + Pasport maglumatlary ─────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("cardPin.personalSection", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("cardPin.fullName", "Doly ady")}>
|
||||
{`${data.last_name} ${data.first_name} ${data.father_name}`}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.birthDate", "Doglan güni")}>
|
||||
{data.birth_date}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.phone", "Telefon")}>+{data.phone}</InfoRow>
|
||||
</div>
|
||||
</section>
|
||||
<InfoRow label={t("cardPin.phone", "Telefon")}>
|
||||
+{data.phone}
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
{/* Pasport */}
|
||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||
{t("cardPin.passportSection", "Pasport")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border mb-4">
|
||||
<BentoCard title={t("cardPin.passportSection", "Pasport")}>
|
||||
<InfoRow label={t("cardPin.passportSeries", "Pasport seriýasy")}>
|
||||
{data.passport_series}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.passportNumber", "Pasport belgisi")}>
|
||||
{data.passport_number}
|
||||
</InfoRow>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("cardPin.passportFile1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile1", "Pasport (sahypa 1)")}
|
||||
url={data.passport_file_1}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardPin.passportFile2", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile2", "Pasport (2-3-nji sahypa)")}
|
||||
url={data.passport_file_2}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardPin.passportFile3", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile3", "Pasport (8-9 sahypa)")}
|
||||
url={data.passport_file_3}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardPin.passportFile4", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile4", "Pasport (32-nji sahypa)")}
|
||||
url={data.passport_file_4}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -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,60 +12,84 @@ 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'
|
||||
} 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 {
|
||||
useCardRequisites,
|
||||
useDeleteCardRequisite,
|
||||
useDownloadCardRequisite,
|
||||
} from '@/features/cardRequisites/hooks/useCardRequisites'
|
||||
import type { CardRequisite, CardRequisiteStatus } from '@/features/cardRequisites/api/cardRequisitesApi'
|
||||
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type {
|
||||
CardRequisite,
|
||||
CardRequisiteStatus,
|
||||
} from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_BADGE: Record<CardRequisiteStatus, { label: string; className: string }> = {
|
||||
pending: { label: 'Garaşylýar', className: 'bg-yellow-500/15 text-yellow-500 border-yellow-500/20' },
|
||||
approved: { label: 'Tassyklanan', className: 'bg-emerald-500/15 text-emerald-500 border-emerald-500/20' },
|
||||
rejected: { label: 'Ret edilen', className: 'bg-red-500/15 text-red-500 border-red-500/20' },
|
||||
}
|
||||
const STATUS_BADGE: Record<
|
||||
CardRequisiteStatus,
|
||||
{ label: string; className: string }
|
||||
> = {
|
||||
pending: {
|
||||
label: "Garaşylýar",
|
||||
className: "bg-yellow-500/15 text-yellow-500 border-yellow-500/20",
|
||||
},
|
||||
approved: {
|
||||
label: "Tassyklanan",
|
||||
className: "bg-emerald-500/15 text-emerald-500 border-emerald-500/20",
|
||||
},
|
||||
rejected: {
|
||||
label: "Ret edilen",
|
||||
className: "bg-red-500/15 text-red-500 border-red-500/20",
|
||||
},
|
||||
};
|
||||
|
||||
function StatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const cfg = STATUS_BADGE[status] ?? STATUS_BADGE.pending
|
||||
const cfg = STATUS_BADGE[status] ?? STATUS_BADGE.pending;
|
||||
return (
|
||||
<span className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${cfg.className}`}>
|
||||
<span
|
||||
className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${cfg.className}`}
|
||||
>
|
||||
{cfg.label}
|
||||
</span>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
const PER_PAGE = 25
|
||||
const PER_PAGE = 25;
|
||||
|
||||
export default function CardRequisitesPage() {
|
||||
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<string | 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<string | null>(null);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([]);
|
||||
|
||||
const { data, isLoading } = useCardRequisites({ page, per_page: perPage, search })
|
||||
const deleteMutation = useDeleteCardRequisite()
|
||||
const downloadMutation = useDownloadCardRequisite()
|
||||
const { data, isLoading } = useCardRequisites({
|
||||
page,
|
||||
per_page: perPage,
|
||||
search,
|
||||
});
|
||||
const deleteMutation = useDeleteCardRequisite();
|
||||
const downloadMutation = useDownloadCardRequisite();
|
||||
|
||||
// ── Columns ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const columns: ColumnDef<CardRequisite>[] = [
|
||||
{
|
||||
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 text-left"
|
||||
@@ -76,81 +100,94 @@ export default function CardRequisitesPage() {
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'card_type',
|
||||
accessorKey: 'card_type',
|
||||
header: t('Card type', 'GÖRNÜŞI'),
|
||||
id: "card_type",
|
||||
accessorKey: "card_type",
|
||||
header: t("Card type", "GÖRNÜŞI"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-medium">{row.original.card_type}</span>
|
||||
<span className="text-primary font-medium">
|
||||
{row.original.card_type}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'created_at',
|
||||
accessorKey: 'created_at',
|
||||
header: t('Created at', 'DÖREDILEN WAGTY'),
|
||||
id: "created_at",
|
||||
accessorKey: "created_at",
|
||||
header: t("Created at", "DÖREDILEN WAGTY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-foreground">{row.original.created_at}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'province_name',
|
||||
accessorKey: 'province_name',
|
||||
header: t('Province', 'WELAÝAT'),
|
||||
id: "province_name",
|
||||
accessorKey: "province_name",
|
||||
header: t("Province", "WELAÝAT"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-foreground">{row.original.province_name ?? '—'}</span>
|
||||
<span className="text-foreground">
|
||||
{row.original.province_name ?? "—"}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'branch_name',
|
||||
accessorKey: 'branch_name',
|
||||
header: t('Branch', 'ŞAHAMÇA'),
|
||||
id: "branch_name",
|
||||
accessorKey: "branch_name",
|
||||
header: t("Branch", "ŞAHAMÇA"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-medium">{row.original.branch_name ?? '—'}</span>
|
||||
<span className="text-primary font-medium">
|
||||
{row.original.branch_name ?? "—"}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'first_name',
|
||||
accessorKey: 'first_name',
|
||||
header: t('First name', 'ADY'),
|
||||
id: "first_name",
|
||||
accessorKey: "first_name",
|
||||
header: t("First name", "ADY"),
|
||||
cell: ({ row }) => <span>{row.original.first_name}</span>,
|
||||
},
|
||||
{
|
||||
id: 'last_name',
|
||||
accessorKey: 'last_name',
|
||||
header: t('Last name', 'FAMILIÝASY'),
|
||||
id: "last_name",
|
||||
accessorKey: "last_name",
|
||||
header: t("Last name", "FAMILIÝASY"),
|
||||
cell: ({ row }) => <span>{row.original.last_name}</span>,
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
accessorKey: 'status',
|
||||
header: t('Status', 'STATUS'),
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
},
|
||||
{
|
||||
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)}
|
||||
>
|
||||
<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-requisites/${row.original.id}`)}
|
||||
>
|
||||
<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-requisites/${row.original.id}/edit`)}
|
||||
>
|
||||
<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)}
|
||||
>
|
||||
@@ -159,94 +196,109 @@ export default function CardRequisitesPage() {
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
// ── Column meta for toolbar ───────────────────────────────────────────────────
|
||||
|
||||
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!,
|
||||
}));
|
||||
|
||||
// ── Pagination ────────────────────────────────────────────────────────────────
|
||||
|
||||
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) return
|
||||
await deleteMutation.mutateAsync(deleteId)
|
||||
setDeleteId(null)
|
||||
}
|
||||
if (!deleteId) return;
|
||||
await deleteMutation.mutateAsync(deleteId);
|
||||
setDeleteId(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Card requisites', 'Kart rekwizitler')}
|
||||
{t("Card requisites", "Kart rekwizitler")}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<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 requisite order",
|
||||
"Kart rekwiziti üçin sargyt dörediň",
|
||||
)}
|
||||
onAction={() => navigate("/card-requisites/create")}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Toolbar */}
|
||||
<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 requisite order', 'Kart rekwiziti üçin sargyt dörediň')}
|
||||
onAction={() => navigate('/card-requisites/create')}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||
/>
|
||||
|
||||
{/* Table */}
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => row.id}
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
{/* Table */}
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => row.id}
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteId !== null} onOpenChange={(open) => !open && setDeleteId(null)}>
|
||||
<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 rekwiziti hemişelik öçüriler.',
|
||||
"This action cannot be undone.",
|
||||
"Bu amal yzyna gaýtarylmaz. Kart rekwiziti hemişelik öçüriler.",
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('Cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<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')}
|
||||
{deleteMutation.isPending
|
||||
? t("Deleting...", "Öçürilýär...")
|
||||
: t("Delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -157,6 +157,9 @@ export default function CardTransactionsPage() {
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
|
||||
|
||||
{/* Toolbar */}
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
@@ -190,6 +193,7 @@ export default function CardTransactionsPage() {
|
||||
totalCount={total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteId !== null} onOpenChange={(open) => !open && setDeleteId(null)}>
|
||||
|
||||
@@ -19,112 +19,127 @@ import {
|
||||
useDeleteCardOrder,
|
||||
} from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import {
|
||||
InfoRow,
|
||||
Section,
|
||||
PassportImage,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CFG: Record<
|
||||
CardOrderStatus,
|
||||
{ label: string; className: string; icon: string }
|
||||
> = {
|
||||
PENDING: {
|
||||
label: "Garaşylýar",
|
||||
icon: "⏳",
|
||||
className: "bg-amber-500/10 text-amber-400 border border-amber-500/20",
|
||||
},
|
||||
APPROVED: {
|
||||
label: "Tassyklandy",
|
||||
icon: "✓",
|
||||
className:
|
||||
"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",
|
||||
},
|
||||
REJECTED: {
|
||||
label: "Ýatyryldy",
|
||||
icon: "✕",
|
||||
className: "bg-red-500/10 text-red-400 border border-red-500/20",
|
||||
},
|
||||
};
|
||||
const STATUS_CFG: Record<CardOrderStatus, { label: string; className: string; icon: string }> = {
|
||||
PENDING: { label: "Garaşylýar", icon: "⏳", className: "bg-amber-500/10 text-amber-400 border border-amber-500/20" },
|
||||
APPROVED: { label: "Tassyklandy", icon: "✓", className: "bg-emerald-500/10 text-emerald-400 border border-emerald-500/20" },
|
||||
REJECTED: { label: "Ýatyryldy", icon: "✕", className: "bg-red-500/10 text-red-400 border border-red-500/20" },
|
||||
}
|
||||
|
||||
function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const cfg = STATUS_CFG[status];
|
||||
const cfg = STATUS_CFG[status]
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide ${cfg.className}`}
|
||||
>
|
||||
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide ${cfg.className}`}>
|
||||
<span className="text-[10px]">{cfg.icon}</span>
|
||||
{cfg.label}
|
||||
</span>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Loading skeleton ─────────────────────────────────────────────────────────
|
||||
// ─── 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" : ""
|
||||
|
||||
return (
|
||||
<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}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function DetailSkeleton() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-8 w-64" />
|
||||
<div className="space-y-3">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-10 w-full" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
// ─── CardOrderDetailPage ──────────────────────────────────────────────────────
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardOrderDetailPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? "");
|
||||
const deleteMutation = useDeleteCardOrder();
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? "")
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!id) return;
|
||||
await deleteMutation.mutateAsync(id);
|
||||
navigate("/order-new-card");
|
||||
};
|
||||
if (!id) return
|
||||
await deleteMutation.mutateAsync(id)
|
||||
navigate("/order-new-card")
|
||||
}
|
||||
|
||||
if (isLoading) return <DetailSkeleton />;
|
||||
if (isLoading) return <DetailSkeleton />
|
||||
if (!order)
|
||||
return (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</p>
|
||||
);
|
||||
)
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between mb-6 gap-4">
|
||||
<div>
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}:{" "}
|
||||
<span className="text-primary font-mono">{order.id}</span>
|
||||
</h1>
|
||||
</div>
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}:{" "}
|
||||
<span className="text-primary font-mono">{order.id}</span>
|
||||
</h1>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
title={t("common.print", "Çap etmek")}
|
||||
>
|
||||
<Button variant="outline" size="icon" title={t("common.print", "Çap etmek")}>
|
||||
<Printer size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
title={t("common.export", "Eksport")}
|
||||
>
|
||||
<Button variant="outline" size="icon" title={t("common.export", "Eksport")}>
|
||||
<Download size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
@@ -145,127 +160,110 @@ export default function CardOrderDetailPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main info */}
|
||||
<Section title="">
|
||||
<InfoRow label="ID">{order.id}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")}>
|
||||
{order.createdAt}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.isPaid", "Tölenen")}>
|
||||
<span
|
||||
className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold
|
||||
${
|
||||
order.isPaid
|
||||
? "bg-emerald-500/15 text-emerald-400"
|
||||
: "bg-red-500/15 text-red-400"
|
||||
}`}
|
||||
>
|
||||
{order.isPaid ? "✓" : "✕"}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||
<StatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")}>
|
||||
{order.note ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{order.createdBy}</span>
|
||||
</InfoRow>
|
||||
</Section>
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardOrder.section.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID">{order.id}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")}>
|
||||
{order.createdAt}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||
<StatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.isPaid", "Tölenen")}>
|
||||
<span className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold ${order.isPaid ? "bg-emerald-500/15 text-emerald-400" : "bg-red-500/15 text-red-400"}`}>
|
||||
{order.isPaid ? "✓" : "✕"}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")}>
|
||||
{order.note ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{order.createdBy}</span>
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
{/* Kart */}
|
||||
<Section title={t("cardOrder.section.card", "Kart")}>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"cardOrder.field.issuanceReason",
|
||||
"Kartyň çykarylmagynyň sebäbi",
|
||||
)}
|
||||
>
|
||||
<span className="text-primary font-medium">
|
||||
{order.issuanceReasonName}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.cardType", "Kart görnüşi")}>
|
||||
<span className="text-cyan-400 font-medium">
|
||||
{order.cardTypeName}
|
||||
</span>
|
||||
</InfoRow>
|
||||
</Section>
|
||||
<BentoCard title={t("cardOrder.section.card", "Kart")}>
|
||||
<InfoRow label={t("cardOrder.field.issuanceReason", "Kartyň çykarylmagynyň sebäbi")}>
|
||||
<span className="text-primary font-medium">{order.issuanceReasonName}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.cardType", "Kart görnüşi")}>
|
||||
<span className="text-cyan-400 font-medium">{order.cardTypeName}</span>
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
{/* Lokasiýa */}
|
||||
<Section title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardOrder.field.province", "Welaýat")}>
|
||||
{order.provinceName}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.branch", "Şahamça")}>
|
||||
<span className="text-cyan-400 font-medium">{order.branchName}</span>
|
||||
</InfoRow>
|
||||
</Section>
|
||||
<BentoCard title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardOrder.field.province", "Welaýat")}>
|
||||
{order.provinceName}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.branch", "Şahamça")}>
|
||||
<span className="text-cyan-400 font-medium">{order.branchName}</span>
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* Şahsy maglumatlar */}
|
||||
<Section title={t("cardOrder.section.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("cardOrder.field.fullName", "Doly ady")}>
|
||||
{[order.lastName, order.firstName, order.middleName]
|
||||
.filter(Boolean)
|
||||
.join(" ")}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>
|
||||
{order.birthDate}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>
|
||||
{order.phone}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>
|
||||
{order.phoneExtra ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>
|
||||
{order.citizenship}
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"cardOrder.field.registeredAddress",
|
||||
"Ýazgy edilen salgyňyz",
|
||||
)}
|
||||
>
|
||||
{order.registeredAddress}
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.currentAddress", "Häzirki ýaşaýyş ýeri")}
|
||||
>
|
||||
{order.currentAddress}
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.workplace", "Işleýän ýeriňiz we wezipäňiz")}
|
||||
>
|
||||
{order.workplace}
|
||||
</InfoRow>
|
||||
</Section>
|
||||
{/* ── Row 2: Şahsy maglumatlar (full width — many fields) ─────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("cardOrder.section.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("cardOrder.field.fullName", "Doly ady")}>
|
||||
{[order.lastName, order.firstName, order.middleName].filter(Boolean).join(" ")}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>
|
||||
{order.birthDate}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>
|
||||
{order.citizenship}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.registeredAddress", "Ýazgy edilen salgy")}>
|
||||
{order.registeredAddress}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.currentAddress", "Häzirki ýaşaýyş ýeri")}>
|
||||
{order.currentAddress}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.workplace", "Işleýän ýeri we wezipesi")}>
|
||||
{order.workplace}
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
{/* Pasport faýýlar */}
|
||||
<Section title={t("cardOrder.section.passportFiles", "Pasport faýýlar")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")}
|
||||
url={order.passportFiles.page1}
|
||||
/>
|
||||
<PassportImage
|
||||
label={t(
|
||||
"cardOrder.field.passportPage23",
|
||||
"Pasport (2-3-nji sahypa)",
|
||||
)}
|
||||
url={order.passportFiles.page23}
|
||||
/>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")}
|
||||
url={order.passportFiles.page89}
|
||||
/>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
url={order.passportFiles.page32}
|
||||
/>
|
||||
</Section>
|
||||
<BentoCard title={t("cardOrder.section.contacts", "Kontakt")}>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>
|
||||
{order.phone}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>
|
||||
{order.phoneExtra ?? "—"}
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* Delete confirm dialog */}
|
||||
{/* ── Row 3: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("cardOrder.field.passportPage1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")}
|
||||
url={order.passportFiles.page1}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage23", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage23", "Pasport (2-3-nji sahypa)")}
|
||||
url={order.passportFiles.page23}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage89", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")}
|
||||
url={order.passportFiles.page89}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage32", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
url={order.passportFiles.page32}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Delete confirm dialog ─────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
@@ -273,10 +271,7 @@ export default function CardOrderDetailPage() {
|
||||
{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
"cardOrder.deleteDescription",
|
||||
"Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.",
|
||||
)}
|
||||
{t("cardOrder.deleteDescription", "Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
@@ -292,6 +287,7 @@ export default function CardOrderDetailPage() {
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user