refactored some page, created new shared components
This commit is contained in:
1 parent
c6462b9956
commit
2340817330
11 files changed
+1222
-1121
No files matched your search
@@ -1,9 +1,9 @@
|
||||
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 { Button } from '@/components/ui/button'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
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 { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -13,93 +13,83 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
useCardBalance,
|
||||
useDeleteCardBalance,
|
||||
useDownloadCardBalance,
|
||||
} from '@/features/cardBalance/hooks/useCardBalance'
|
||||
} from "@/features/cardBalance/hooks/useCardBalance";
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Types for operations table ───────────────────────────────────────────────
|
||||
|
||||
interface Operation {
|
||||
id: number
|
||||
action_name: string
|
||||
performed_by: string
|
||||
target: string
|
||||
status: 'FINISHED' | 'PENDING' | 'FAILED'
|
||||
date: string
|
||||
id: number;
|
||||
action_name: string;
|
||||
performed_by: string;
|
||||
target: string;
|
||||
status: "FINISHED" | "PENDING" | "FAILED";
|
||||
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',
|
||||
}
|
||||
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={`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>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Detail row ───────────────────────────────────────────────────────────────
|
||||
|
||||
function DetailRow({ label, value }: { label: string; value: string | number }) {
|
||||
return (
|
||||
<div className="grid grid-cols-[220px_1fr] border-b border-border/50 last:border-0">
|
||||
<div className="px-4 py-3 text-sm text-muted-foreground font-medium bg-muted/10">
|
||||
{label}
|
||||
</div>
|
||||
<div className="px-4 py-3 text-sm text-foreground">{value}</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardBalanceViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [opsExpanded, setOpsExpanded] = useState(true)
|
||||
const [opsPage, setOpsPage] = useState(1)
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
const [opsExpanded, setOpsExpanded] = useState(true);
|
||||
const [opsPage, setOpsPage] = useState(1);
|
||||
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading } = useCardBalance(numericId)
|
||||
const deleteMutation = useDeleteCardBalance()
|
||||
const downloadMutation = useDownloadCardBalance()
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useCardBalance(numericId);
|
||||
const deleteMutation = useDeleteCardBalance();
|
||||
const downloadMutation = useDownloadCardBalance();
|
||||
|
||||
// Placeholder operations — in real app fetch from API using numericId
|
||||
const operations: Operation[] = []
|
||||
const opsTotal = operations.length
|
||||
const operations: Operation[] = [];
|
||||
const opsTotal = operations.length;
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(numericId)
|
||||
navigate('/card-balances')
|
||||
}
|
||||
await deleteMutation.mutateAsync(numericId);
|
||||
navigate("/card-balances");
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-24 text-muted-foreground">
|
||||
{t('Not found', 'Tapylmady')}
|
||||
{t("Not found", "Tapylmady")}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -107,18 +97,20 @@ export default function CardBalanceViewPage() {
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Card balance detail', 'Kart galyndysy giňişleýin')}:
|
||||
{t("Card balance detail", "Kart galyndysy giňişleýin")}:
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline" size="sm"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => downloadMutation.mutate(numericId)}
|
||||
disabled={downloadMutation.isPending}
|
||||
>
|
||||
<Download size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline" size="sm"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
@@ -134,12 +126,27 @@ export default function CardBalanceViewPage() {
|
||||
|
||||
{/* Detail card */}
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('ID', 'ID')} value={data.id} />
|
||||
<DetailRow label={t('Passport series', 'Pasport seriýasy')} value={data.passport_series} />
|
||||
<DetailRow label={t('Passport number', 'Pasport belgisi')} value={data.passport_number} />
|
||||
<DetailRow label={t('Card number', 'Kart belgisi')} value={data.card_number} />
|
||||
<DetailRow label={t('Card expiry month', 'Kart Möhleti (aý)')} value={data.card_expiry_month} />
|
||||
<DetailRow label={t('Card expiry year', 'Kart Möhleti (ýyl)')} value={data.card_expiry_year} />
|
||||
<InfoRow label={t("ID", "ID")} value={data.id} />
|
||||
<InfoRow
|
||||
label={t("Passport series", "Pasport seriýasy")}
|
||||
value={data.passport_series}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Passport number", "Pasport belgisi")}
|
||||
value={data.passport_number}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Card number", "Kart belgisi")}
|
||||
value={data.card_number}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Card expiry month", "Kart Möhleti (aý)")}
|
||||
value={data.card_expiry_month}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Card expiry year", "Kart Möhleti (ýyl)")}
|
||||
value={data.card_expiry_year}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Ammallar (Operations) collapsible section */}
|
||||
@@ -150,11 +157,11 @@ export default function CardBalanceViewPage() {
|
||||
onClick={() => setOpsExpanded((v) => !v)}
|
||||
>
|
||||
<span className="font-semibold text-foreground text-sm">
|
||||
{t('Operations', 'Ammallar')}
|
||||
{t("Operations", "Ammallar")}
|
||||
</span>
|
||||
<ChevronDown
|
||||
size={15}
|
||||
className={`text-muted-foreground transition-transform duration-200 ${opsExpanded ? 'rotate-180' : ''}`}
|
||||
className={`text-muted-foreground transition-transform duration-200 ${opsExpanded ? "rotate-180" : ""}`}
|
||||
/>
|
||||
</button>
|
||||
|
||||
@@ -165,12 +172,12 @@ export default function CardBalanceViewPage() {
|
||||
<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'),
|
||||
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}
|
||||
@@ -184,19 +191,31 @@ export default function CardBalanceViewPage() {
|
||||
<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
|
||||
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>
|
||||
<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>
|
||||
<td className="px-4 py-3">
|
||||
<OpStatusBadge status={op.status} />
|
||||
</td>
|
||||
<td className="px-4 py-3 text-muted-foreground">
|
||||
{op.date}
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
@@ -206,14 +225,20 @@ export default function CardBalanceViewPage() {
|
||||
|
||||
{/* 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
|
||||
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}
|
||||
{opsTotal === 0 ? "0" : `1–${opsTotal}`} {t("of", "of")}{" "}
|
||||
{opsTotal}
|
||||
</span>
|
||||
<Button variant="ghost" size="sm" disabled={true}>
|
||||
{t('Next', 'Indiki')}
|
||||
{t("Next", "Indiki")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
@@ -224,25 +249,29 @@ export default function CardBalanceViewPage() {
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<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.',
|
||||
"This action cannot be undone.",
|
||||
"Bu amal yzyna gaýtarylmaz. Kart galyndysy 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>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useCardPin, useDeleteCardPin } from '@/features/cardPins/hooks/useCardPins'
|
||||
import type { CardPinStatus } from '@/features/cardPins/api/cardPinApi'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Pencil, Trash2, Download } from 'lucide-react'
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
useCardPin,
|
||||
useDeleteCardPin,
|
||||
} from "@/features/cardPins/hooks/useCardPins";
|
||||
import type { CardPinStatus } from "@/features/cardPins/api/cardPinApi";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -15,99 +18,71 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
// ─── 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 CardPinStatusBadge({ 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} />
|
||||
}
|
||||
|
||||
// ─── Field row ────────────────────────────────────────────────────────────────
|
||||
|
||||
function FieldRow({ label, children }: { label: string; children: React.ReactNode }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg)
|
||||
return (
|
||||
<span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
);
|
||||
return (
|
||||
<div className="grid grid-cols-[200px_1fr] items-start py-3 border-b border-border last:border-0 gap-4">
|
||||
<span className="text-sm text-muted-foreground">{label}</span>
|
||||
<span className="text-sm text-foreground">{children}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Passport image ───────────────────────────────────────────────────────────
|
||||
|
||||
function PassportImage({ label, url }: { label: string; url: string | null }) {
|
||||
if (!url) return null
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<p className="text-sm text-muted-foreground">{label}</p>
|
||||
<div className="border border-border rounded-lg overflow-hidden inline-block">
|
||||
<img
|
||||
src={url}
|
||||
alt={label}
|
||||
className="max-w-[200px] max-h-[160px] object-cover block"
|
||||
/>
|
||||
<div className="px-3 py-2 bg-muted/40 border-t border-border">
|
||||
<a
|
||||
href={url}
|
||||
download
|
||||
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<Download size={12} />
|
||||
Göçürip al
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── 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) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||
{t('common.notFound', 'Maglumat tapylmady')}
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -115,32 +90,43 @@ export default function CardPinViewPage() {
|
||||
{/* 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}
|
||||
{t("cardPin.viewTitle", "Kart pin bukja giňişleýin")}: {data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('cardPin.deleteTitle', 'Pozmak isleýärsiňizmi?')}</AlertDialogTitle>
|
||||
<AlertDialogTitle>
|
||||
{t("cardPin.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('cardPin.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} {data.id}
|
||||
{t("cardPin.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")}{" "}
|
||||
{data.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
{t("common.cancel", "Ýatyr")}
|
||||
</AlertDialogCancel>
|
||||
<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')}
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
@@ -159,96 +145,108 @@ export default function CardPinViewPage() {
|
||||
|
||||
{/* Main Info */}
|
||||
<section className="bg-card border border-border rounded-lg px-6">
|
||||
<FieldRow label="ID">
|
||||
<InfoRow label="ID">
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.createdAt', 'Döredilen wagty')}>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")}>
|
||||
{data.created_at}
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.status', 'Status')}>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.status", "Status")}>
|
||||
<CardPinStatusBadge status={data.status} />
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.note', 'Bellik')}>
|
||||
{data.note || '—'}
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.createdBy', 'Sargyt eden')}>
|
||||
<span className="text-primary font-medium">{data.created_by_label}</span>
|
||||
</FieldRow>
|
||||
</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>
|
||||
|
||||
{/* 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')}
|
||||
{t("cardPin.cardSection", "Kart")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border">
|
||||
<FieldRow label={t('cardPin.cardNumber', 'Kart belgisi')}>
|
||||
<InfoRow label={t("cardPin.cardNumber", "Kart belgisi")}>
|
||||
<span className="font-mono tracking-wider">{data.card_number}</span>
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.cardExpireMonth', 'Kart Möhleti (aý)')}>—</FieldRow>
|
||||
<FieldRow label={t('cardPin.cardExpireYear', 'Kart Möhleti (ýyl)')}>—</FieldRow>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.cardExpireMonth", "Kart Möhleti (aý)")}>
|
||||
—
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.cardExpireYear", "Kart Möhleti (ýyl)")}>
|
||||
—
|
||||
</InfoRow>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 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')}
|
||||
{t("cardPin.locationSection", "Lokasiýa")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border">
|
||||
<FieldRow label={t('cardPin.province', 'Welaýat')}>{data.province_label}</FieldRow>
|
||||
<FieldRow label={t('cardPin.branch', 'Şahamça')}>
|
||||
<span className="text-primary font-medium">{data.branch_label}</span>
|
||||
</FieldRow>
|
||||
<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>
|
||||
</InfoRow>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Ş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')}
|
||||
{t("cardPin.personalSection", "Şahsy maglumatlar")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border">
|
||||
<FieldRow label={t('cardPin.fullName', 'Doly ady')}>
|
||||
<InfoRow label={t("cardPin.fullName", "Doly ady")}>
|
||||
{`${data.last_name} ${data.first_name} ${data.father_name}`}
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.birthDate', 'Doglan güni')}>{data.birth_date}</FieldRow>
|
||||
<FieldRow label={t('cardPin.phone', 'Telefon')}>+{data.phone}</FieldRow>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.birthDate", "Doglan güni")}>
|
||||
{data.birth_date}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.phone", "Telefon")}>+{data.phone}</InfoRow>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 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')}
|
||||
{t("cardPin.passportSection", "Pasport")}
|
||||
</h2>
|
||||
<div className="divide-y divide-border mb-4">
|
||||
<FieldRow label={t('cardPin.passportSeries', 'Pasport seriýasy')}>
|
||||
<InfoRow label={t("cardPin.passportSeries", "Pasport seriýasy")}>
|
||||
{data.passport_series}
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.passportNumber', 'Pasport belgisi')}>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.passportNumber", "Pasport belgisi")}>
|
||||
{data.passport_number}
|
||||
</FieldRow>
|
||||
</InfoRow>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
||||
<PassportImage
|
||||
label={t('cardPin.passportFile1', 'Pasport (sahypa 1)')}
|
||||
label={t("cardPin.passportFile1", "Pasport (sahypa 1)")}
|
||||
url={data.passport_file_1}
|
||||
/>
|
||||
<PassportImage
|
||||
label={t('cardPin.passportFile2', 'Pasport (2-3-nji sahypa)')}
|
||||
label={t("cardPin.passportFile2", "Pasport (2-3-nji sahypa)")}
|
||||
url={data.passport_file_2}
|
||||
/>
|
||||
<PassportImage
|
||||
label={t('cardPin.passportFile3', 'Pasport (8-9 sahypa)')}
|
||||
label={t("cardPin.passportFile3", "Pasport (8-9 sahypa)")}
|
||||
url={data.passport_file_3}
|
||||
/>
|
||||
<PassportImage
|
||||
label={t('cardPin.passportFile4', 'Pasport (32-nji sahypa)')}
|
||||
label={t("cardPin.passportFile4", "Pasport (32-nji sahypa)")}
|
||||
url={data.passport_file_4}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Download, Trash2, Pencil, DownloadCloud } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Trash2, Pencil, DownloadCloud } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -13,47 +13,43 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
useCardRequisite,
|
||||
useDeleteCardRequisite,
|
||||
useDownloadCardRequisite,
|
||||
} from '@/features/cardRequisites/hooks/useCardRequisites'
|
||||
import type { CardRequisiteStatus } from '@/features/cardRequisites/api/cardRequisitesApi'
|
||||
|
||||
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_BADGE: Record<CardRequisiteStatus, { label: string; className: string }> = {
|
||||
pending: { label: 'GARAŞYLÝAR', className: 'bg-yellow-500/20 text-yellow-400 border border-yellow-500/30' },
|
||||
approved: { label: 'TASSYKLANAN', className: 'bg-emerald-500/20 text-emerald-400 border border-emerald-500/30' },
|
||||
rejected: { label: 'RET EDILEN', className: 'bg-red-500/20 text-red-400 border border-red-500/30' },
|
||||
}
|
||||
|
||||
// ─── Detail row ───────────────────────────────────────────────────────────────
|
||||
|
||||
function DetailRow({
|
||||
label,
|
||||
children,
|
||||
}: {
|
||||
label: string
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[220px_1fr] border-b border-border/50 last:border-0">
|
||||
<div className="px-4 py-3 text-sm text-muted-foreground font-medium bg-muted/10">
|
||||
{label}
|
||||
</div>
|
||||
<div className="px-4 py-3 text-sm text-foreground">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const STATUS_BADGE: Record<
|
||||
CardRequisiteStatus,
|
||||
{ label: string; className: string }
|
||||
> = {
|
||||
pending: {
|
||||
label: "GARAŞYLÝAR",
|
||||
className: "bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",
|
||||
},
|
||||
approved: {
|
||||
label: "TASSYKLANAN",
|
||||
className:
|
||||
"bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",
|
||||
},
|
||||
rejected: {
|
||||
label: "RET EDILEN",
|
||||
className: "bg-red-500/20 text-red-400 border border-red-500/30",
|
||||
},
|
||||
};
|
||||
|
||||
// ─── Section header ───────────────────────────────────────────────────────────
|
||||
|
||||
function SectionTitle({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<h2 className="text-base font-semibold text-foreground mt-6 mb-3">{children}</h2>
|
||||
)
|
||||
<h2 className="text-base font-semibold text-foreground mt-6 mb-3">
|
||||
{children}
|
||||
</h2>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Passport image row ───────────────────────────────────────────────────────
|
||||
@@ -78,7 +74,7 @@ function PassportImageRow({ label, url }: { label: string; url?: string }) {
|
||||
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
|
||||
>
|
||||
<DownloadCloud size={13} />
|
||||
{( 'Göçürip al')}
|
||||
{"Göçürip al"}
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
@@ -86,62 +82,64 @@ function PassportImageRow({ label, url }: { label: string; url?: string }) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardRequisiteViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data, isLoading } = useCardRequisite(id ?? '')
|
||||
const deleteMutation = useDeleteCardRequisite()
|
||||
const downloadMutation = useDownloadCardRequisite()
|
||||
const { data, isLoading } = useCardRequisite(id ?? "");
|
||||
const deleteMutation = useDeleteCardRequisite();
|
||||
const downloadMutation = useDownloadCardRequisite();
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(id ?? '')
|
||||
navigate('/card-requisites')
|
||||
}
|
||||
await deleteMutation.mutateAsync(id ?? "");
|
||||
navigate("/card-requisites");
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-24 text-muted-foreground">
|
||||
{t('Not found', 'Tapylmady')}
|
||||
{t("Not found", "Tapylmady")}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const statusCfg = STATUS_BADGE[data.status] ?? STATUS_BADGE.pending
|
||||
const statusCfg = STATUS_BADGE[data.status] ?? STATUS_BADGE.pending;
|
||||
|
||||
return (
|
||||
<div className="space-y-0">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Card requisite detail', 'Kart rekwizit giňişleýin')}: {data.id}
|
||||
{t("Card requisite detail", "Kart rekwizit giňişleýin")}: {data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline" size="sm"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => downloadMutation.mutate(data.id)}
|
||||
disabled={downloadMutation.isPending}
|
||||
>
|
||||
<Download size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline" size="sm"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
@@ -157,71 +155,95 @@ export default function CardRequisiteViewPage() {
|
||||
|
||||
{/* General info */}
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('ID', 'ID')}>{data.id}</DetailRow>
|
||||
<DetailRow label={t('Created at', 'Döredilen wagty')}>{data.created_at}</DetailRow>
|
||||
<DetailRow label={t('Status', 'Status')}>
|
||||
<span className={`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold ${statusCfg.className}`}>
|
||||
<InfoRow label={t("ID", "ID")}>{data.id}</InfoRow>
|
||||
<InfoRow label={t("Created at", "Döredilen wagty")}>
|
||||
{data.created_at}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Status", "Status")}>
|
||||
<span
|
||||
className={`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold ${statusCfg.className}`}
|
||||
>
|
||||
{statusCfg.label}
|
||||
</span>
|
||||
</DetailRow>
|
||||
<DetailRow label={t('Note', 'Bellik')}>
|
||||
{data.note || '—'}
|
||||
</DetailRow>
|
||||
<DetailRow label={t('Requested by', 'Sargyt eden:')}>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Note", "Bellik")}>{data.note || "—"}</InfoRow>
|
||||
<InfoRow label={t("Requested by", "Sargyt eden:")}>
|
||||
{data.first_name && data.last_name ? (
|
||||
<span className="text-primary font-medium">
|
||||
{data.last_name}_{data.first_name} ({data.first_name})
|
||||
</span>
|
||||
) : '—'}
|
||||
</DetailRow>
|
||||
) : (
|
||||
"—"
|
||||
)}
|
||||
</InfoRow>
|
||||
</div>
|
||||
|
||||
{/* Card */}
|
||||
<SectionTitle>{t('Card', 'Kart')}</SectionTitle>
|
||||
<SectionTitle>{t("Card", "Kart")}</SectionTitle>
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('Card number', 'Kart belgisi')}>{data.card_number}</DetailRow>
|
||||
<DetailRow label={t('Card expiry month', 'Kart Möhleti (aý)')}>{data.card_expiry_month}</DetailRow>
|
||||
<DetailRow label={t('Card expiry year', 'Kart Möhleti (ýyl)')}>{data.card_expiry_year}</DetailRow>
|
||||
<InfoRow label={t("Card number", "Kart belgisi")}>
|
||||
{data.card_number}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Card expiry month", "Kart Möhleti (aý)")}>
|
||||
{data.card_expiry_month}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Card expiry year", "Kart Möhleti (ýyl)")}>
|
||||
{data.card_expiry_year}
|
||||
</InfoRow>
|
||||
</div>
|
||||
|
||||
{/* Location */}
|
||||
<SectionTitle>{t('Location', 'Lokasiýa')}</SectionTitle>
|
||||
<SectionTitle>{t("Location", "Lokasiýa")}</SectionTitle>
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('Province', 'Welaýat')}>{data.province_name ?? '—'}</DetailRow>
|
||||
<DetailRow label={t('Branch', 'Şahamça')}>
|
||||
<span className="text-primary font-medium">{data.branch_name ?? '—'}</span>
|
||||
</DetailRow>
|
||||
<InfoRow label={t("Province", "Welaýat")}>
|
||||
{data.province_name ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Branch", "Şahamça")}>
|
||||
<span className="text-primary font-medium">
|
||||
{data.branch_name ?? "—"}
|
||||
</span>
|
||||
</InfoRow>
|
||||
</div>
|
||||
|
||||
{/* Personal */}
|
||||
<SectionTitle>{t('Personal information', 'Şahsy maglumatlar')}</SectionTitle>
|
||||
<SectionTitle>
|
||||
{t("Personal information", "Şahsy maglumatlar")}
|
||||
</SectionTitle>
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('Full name', 'Doly ady')}>
|
||||
{[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(' ')}
|
||||
</DetailRow>
|
||||
<DetailRow label={t('Birth date', 'Doglan güni')}>{data.birth_date}</DetailRow>
|
||||
<DetailRow label={t('Phone', 'Telefon')}>{data.phone}</DetailRow>
|
||||
<InfoRow label={t("Full name", "Doly ady")}>
|
||||
{[data.first_name, data.last_name, data.middle_name]
|
||||
.filter(Boolean)
|
||||
.join(" ")}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Birth date", "Doglan güni")}>
|
||||
{data.birth_date}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Phone", "Telefon")}>{data.phone}</InfoRow>
|
||||
</div>
|
||||
|
||||
{/* Passport */}
|
||||
<SectionTitle>{t('Passport', 'Pasport')}</SectionTitle>
|
||||
<SectionTitle>{t("Passport", "Pasport")}</SectionTitle>
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('Passport series', 'Pasport seriýasy')}>{data.passport_series}</DetailRow>
|
||||
<DetailRow label={t('Passport number', 'Pasport belgisi')}>{data.passport_number}</DetailRow>
|
||||
<InfoRow label={t("Passport series", "Pasport seriýasy")}>
|
||||
{data.passport_series}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Passport number", "Pasport belgisi")}>
|
||||
{data.passport_number}
|
||||
</InfoRow>
|
||||
<PassportImageRow
|
||||
label={t('Passport (page 1)', 'Pasport (sahypa 1)')}
|
||||
label={t("Passport (page 1)", "Pasport (sahypa 1)")}
|
||||
url={data.passport_page1_url}
|
||||
/>
|
||||
<PassportImageRow
|
||||
label={t('Passport (pages 2-3)', 'Pasport (2-3-nji sahypa)')}
|
||||
label={t("Passport (pages 2-3)", "Pasport (2-3-nji sahypa)")}
|
||||
url={data.passport_page2_3_url}
|
||||
/>
|
||||
<PassportImageRow
|
||||
label={t('Passport (pages 8-9)', 'Pasport (8-9 sahypa)')}
|
||||
label={t("Passport (pages 8-9)", "Pasport (8-9 sahypa)")}
|
||||
url={data.passport_page8_9_url}
|
||||
/>
|
||||
<PassportImageRow
|
||||
label={t('Passport (page 32)', 'Pasport (32-nji sahypa)')}
|
||||
label={t("Passport (page 32)", "Pasport (32-nji sahypa)")}
|
||||
url={data.passport_page32_url}
|
||||
/>
|
||||
</div>
|
||||
@@ -230,25 +252,29 @@ export default function CardRequisiteViewPage() {
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<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>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Download, Trash2, Pencil } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -13,59 +13,47 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
useCardTransaction,
|
||||
useDeleteCardTransaction,
|
||||
useDownloadCardTransaction,
|
||||
} from '@/features/cardTransactions/hooks/useCardTransactions'
|
||||
|
||||
// ─── Detail row ───────────────────────────────────────────────────────────────
|
||||
|
||||
function DetailRow({ label, value }: { label: string; value: string | number }) {
|
||||
return (
|
||||
<div className="grid grid-cols-[220px_1fr] border-b border-border/50 last:border-0">
|
||||
<div className="px-4 py-3 text-sm text-muted-foreground font-medium bg-muted/10">
|
||||
{label}
|
||||
</div>
|
||||
<div className="px-4 py-3 text-sm text-foreground">{value}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
} from "@/features/cardTransactions/hooks/useCardTransactions";
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardTransactionViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading } = useCardTransaction(numericId)
|
||||
const deleteMutation = useDeleteCardTransaction()
|
||||
const downloadMutation = useDownloadCardTransaction()
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useCardTransaction(numericId);
|
||||
const deleteMutation = useDeleteCardTransaction();
|
||||
const downloadMutation = useDownloadCardTransaction();
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(numericId)
|
||||
navigate('/card-transactions')
|
||||
}
|
||||
await deleteMutation.mutateAsync(numericId);
|
||||
navigate("/card-transactions");
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-24 text-muted-foreground">
|
||||
{t('Not found', 'Tapylmady')}
|
||||
{t("Not found", "Tapylmady")}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -73,7 +61,7 @@ export default function CardTransactionViewPage() {
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Card transaction detail', 'Kart herekedi giňişleýin')}:
|
||||
{t("Card transaction detail", "Kart herekedi giňişleýin")}:
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
@@ -93,12 +81,7 @@ export default function CardTransactionViewPage() {
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1.5"
|
||||
asChild
|
||||
>
|
||||
<Button variant="outline" size="sm" className="gap-1.5" asChild>
|
||||
<Link to={`/card-transactions/${numericId}/edit`}>
|
||||
<Pencil size={14} />
|
||||
</Link>
|
||||
@@ -108,39 +91,56 @@ export default function CardTransactionViewPage() {
|
||||
|
||||
{/* Detail card */}
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
<DetailRow label={t('ID', 'ID')} value={data.id} />
|
||||
<DetailRow label={t('Passport series', 'Pasport seriýasy')} value={data.passport_series} />
|
||||
<DetailRow label={t('Passport number', 'Pasport belgisi')} value={data.passport_number} />
|
||||
<DetailRow label={t('Card number', 'Kart belgisi')} value={data.card_number} />
|
||||
<DetailRow label={t('Card expiry month', 'Kart Möhleti (aý)')} value={data.card_expiry_month} />
|
||||
<DetailRow label={t('Card expiry year', 'Kart Möhleti (ýyl)')} value={data.card_expiry_year} />
|
||||
<InfoRow label={t("ID", "ID")} value={data.id} />
|
||||
<InfoRow
|
||||
label={t("Passport series", "Pasport seriýasy")}
|
||||
value={data.passport_series}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Passport number", "Pasport belgisi")}
|
||||
value={data.passport_number}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Card number", "Kart belgisi")}
|
||||
value={data.card_number}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Card expiry month", "Kart Möhleti (aý)")}
|
||||
value={data.card_expiry_month}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("Card expiry year", "Kart Möhleti (ýyl)")}
|
||||
value={data.card_expiry_year}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<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. This will permanently delete the card transaction.',
|
||||
'Bu amal yzyna gaýtarylmaz. Kart herekedi hemişelik öçüriler.',
|
||||
"This action cannot be undone. This will permanently delete the card transaction.",
|
||||
"Bu amal yzyna gaýtarylmaz. Kart herekedi 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')}
|
||||
? t("Deleting...", "Öçürilýär...")
|
||||
: t("Delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Printer, Download, Trash2, Pencil } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Printer, Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -12,97 +12,52 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { useCardOrderById, useDeleteCardOrder } from '@/features/orderNewCard/hooks/useOrderNewCard'
|
||||
import type { CardOrderStatus } from '@/features/orderNewCard/api/orderNewCardApi'
|
||||
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
useCardOrderById,
|
||||
useDeleteCardOrder,
|
||||
} from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import {
|
||||
InfoRow,
|
||||
Section,
|
||||
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>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Info row ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function InfoRow({
|
||||
label,
|
||||
children,
|
||||
}: {
|
||||
label: string
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[200px_1fr] gap-4 py-2.5 px-4 border-b border-border/60 last:border-0 items-start">
|
||||
<span className="text-sm text-muted-foreground">{label}</span>
|
||||
<span className="text-sm text-foreground">{children}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Section ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="mb-6">
|
||||
<h3 className="text-base font-semibold text-foreground mb-3">{title}</h3>
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Passport file card ───────────────────────────────────────────────────────
|
||||
|
||||
function PassportFileCard({ label, url }: { label: string; url: string | null }) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-[200px_1fr] gap-4 py-3 px-4 border-b border-border/60 last:border-0 items-start">
|
||||
<span className="text-sm text-muted-foreground">{label}</span>
|
||||
<div className="flex flex-col gap-2">
|
||||
{url ? (
|
||||
<>
|
||||
<div className="w-20 h-14 rounded-lg overflow-hidden bg-muted border border-border">
|
||||
<img
|
||||
src={url}
|
||||
alt={label}
|
||||
className="w-full h-full object-cover"
|
||||
onError={(e) => {
|
||||
;(e.currentTarget as HTMLImageElement).style.display = 'none'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<a
|
||||
href={url}
|
||||
download
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1.5 text-xs text-primary hover:text-primary/80 transition-colors w-fit"
|
||||
>
|
||||
<Download size={12} />
|
||||
{t('common.download', 'Göçürip al')}
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">—</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Loading skeleton ─────────────────────────────────────────────────────────
|
||||
@@ -117,69 +72,74 @@ function DetailSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── CardOrderDetailPage ──────────────────────────────────────────────────────
|
||||
|
||||
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 (!order) return (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t('common.notFound', 'Tapylmady')}
|
||||
</p>
|
||||
)
|
||||
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')}:{' '}
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}:{" "}
|
||||
<span className="text-primary font-mono">{order.id}</span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<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
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-destructive hover:text-destructive hover:bg-destructive/10 border-destructive/20"
|
||||
title={t('common.delete', 'Pozmak')}
|
||||
title={t("common.delete", "Pozmak")}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
asChild
|
||||
>
|
||||
<Button size="sm" asChild>
|
||||
<Link to={`/order-new-card/${order.id}/edit`}>
|
||||
<Pencil size={14} className="mr-1.5" />
|
||||
{t('common.edit', 'Düzetmek')}
|
||||
{t("common.edit", "Düzetmek")}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
@@ -188,94 +148,119 @@ export default function CardOrderDetailPage() {
|
||||
{/* Main info */}
|
||||
<Section title="">
|
||||
<InfoRow label="ID">{order.id}</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.createdAt', 'Döredilen wagty')}>
|
||||
<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'
|
||||
<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 ? '✓' : '✕'}
|
||||
{order.isPaid ? "✓" : "✕"}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.status', 'Status')}>
|
||||
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||
<StatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.note', 'Bellik')}>
|
||||
{order.note ?? '—'}
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")}>
|
||||
{order.note ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.createdBy', 'Sargyt eden')}>
|
||||
<InfoRow label={t("cardOrder.field.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{order.createdBy}</span>
|
||||
</InfoRow>
|
||||
</Section>
|
||||
|
||||
{/* 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>
|
||||
<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 label={t("cardOrder.field.cardType", "Kart görnüşi")}>
|
||||
<span className="text-cyan-400 font-medium">
|
||||
{order.cardTypeName}
|
||||
</span>
|
||||
</InfoRow>
|
||||
</Section>
|
||||
|
||||
{/* Lokasiýa */}
|
||||
<Section title={t('cardOrder.section.location', 'Lokasiýa')}>
|
||||
<InfoRow label={t('cardOrder.field.province', 'Welaýat')}>
|
||||
<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')}>
|
||||
<InfoRow label={t("cardOrder.field.branch", "Şahamça")}>
|
||||
<span className="text-cyan-400 font-medium">{order.branchName}</span>
|
||||
</InfoRow>
|
||||
</Section>
|
||||
|
||||
{/* Ş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(' ')}
|
||||
<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')}>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>
|
||||
{order.birthDate}
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.phone', 'Telefon')}>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>
|
||||
{order.phone}
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.phoneExtra', 'Telefon goşmaça')}>
|
||||
{order.phoneExtra ?? '—'}
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>
|
||||
{order.phoneExtra ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.citizenship', 'Raýatlyk')}>
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>
|
||||
{order.citizenship}
|
||||
</InfoRow>
|
||||
<InfoRow label={t('cardOrder.field.registeredAddress', 'Ýazgy edilen salgyňyz')}>
|
||||
<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')}>
|
||||
<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')}>
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.workplace", "Işleýän ýeriňiz we wezipäňiz")}
|
||||
>
|
||||
{order.workplace}
|
||||
</InfoRow>
|
||||
</Section>
|
||||
|
||||
{/* Pasport faýýlar */}
|
||||
<Section title={t('cardOrder.section.passportFiles', 'Pasport faýýlar')}>
|
||||
<PassportFileCard
|
||||
label={t('cardOrder.field.passportPage1', 'Pasport (sahypa 1)')}
|
||||
<Section title={t("cardOrder.section.passportFiles", "Pasport faýýlar")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")}
|
||||
url={order.passportFiles.page1}
|
||||
/>
|
||||
<PassportFileCard
|
||||
label={t('cardOrder.field.passportPage23', 'Pasport (2-3-nji sahypa)')}
|
||||
<PassportImage
|
||||
label={t(
|
||||
"cardOrder.field.passportPage23",
|
||||
"Pasport (2-3-nji sahypa)",
|
||||
)}
|
||||
url={order.passportFiles.page23}
|
||||
/>
|
||||
<PassportFileCard
|
||||
label={t('cardOrder.field.passportPage89', 'Pasport (8-9 sahypa)')}
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")}
|
||||
url={order.passportFiles.page89}
|
||||
/>
|
||||
<PassportFileCard
|
||||
label={t('cardOrder.field.passportPage32', 'Pasport (32-nji sahypa)')}
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
url={order.passportFiles.page32}
|
||||
/>
|
||||
</Section>
|
||||
@@ -285,30 +270,28 @@ export default function CardOrderDetailPage() {
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t('cardOrder.deleteTitle', 'Pozmak isleýärsiňizmi?')}
|
||||
{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.',
|
||||
"cardOrder.deleteDescription",
|
||||
"Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.",
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDelete}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending
|
||||
? t('common.deleting', 'Pozulýar...')
|
||||
: t('common.delete', 'Pozmak')}
|
||||
? t("common.deleting", "Pozulýar...")
|
||||
: t("common.delete", "Pozmak")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user