refactored some page, created new shared components
This commit is contained in:
1 parent
c6462b9956
commit
2340817330
11 files changed
+1216
-1115
No files matched your search
@@ -0,0 +1,221 @@
|
|||||||
|
import { Download, Eye, ChevronRight } from "lucide-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
// ─── InfoRow ──────────────────────────────────────────────────────────────────
|
||||||
|
// Supports both:
|
||||||
|
// <InfoRow label="ID" value={data.id} />
|
||||||
|
// <InfoRow label="ID">{data.id}</InfoRow>
|
||||||
|
|
||||||
|
export interface InfoRowProps {
|
||||||
|
label: string;
|
||||||
|
/** Plain string/number value — use this or children, not both */
|
||||||
|
value?: string | number | null;
|
||||||
|
/** Arbitrary JSX — status badges, links, custom formatting, etc. */
|
||||||
|
children?: React.ReactNode;
|
||||||
|
isLink?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function InfoRow({ label, value, children, isLink }: InfoRowProps) {
|
||||||
|
const content = children ?? (value != null ? String(value) : null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||||
|
<span className="text-sm text-muted-foreground">{label}</span>
|
||||||
|
{content != null && content !== "" ? (
|
||||||
|
typeof content === "string" ? (
|
||||||
|
<span
|
||||||
|
className={`text-sm ${isLink ? "text-primary font-medium" : "text-foreground"}`}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<div className="text-sm">{content}</div>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<span className="text-muted-foreground/40 text-sm">—</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Section ──────────────────────────────────────────────────────────────────
|
||||||
|
// title is optional — omit or pass empty string to skip the heading
|
||||||
|
|
||||||
|
export interface SectionProps {
|
||||||
|
title?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Section({ title, children }: SectionProps) {
|
||||||
|
return (
|
||||||
|
<div className="mb-6">
|
||||||
|
{title ? (
|
||||||
|
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||||
|
{title}
|
||||||
|
</h2>
|
||||||
|
) : null}
|
||||||
|
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── PassportImage ────────────────────────────────────────────────────────────
|
||||||
|
// Accepts both `src` and `url` prop names for compatibility
|
||||||
|
|
||||||
|
export interface PassportImageProps {
|
||||||
|
label: string;
|
||||||
|
src?: string | null;
|
||||||
|
url?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PassportImage({ label, src, url }: PassportImageProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const imageSrc = src ?? url ?? null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-[220px_1fr] items-start py-3 px-4 border-b border-border last:border-0">
|
||||||
|
<span className="text-sm text-muted-foreground pt-1">{label}</span>
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
{imageSrc ? (
|
||||||
|
<img
|
||||||
|
src={imageSrc}
|
||||||
|
alt={label}
|
||||||
|
className="w-28 h-20 object-cover rounded-md border border-border"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="w-28 h-20 bg-muted rounded-md border border-border flex items-center justify-center">
|
||||||
|
<span className="text-xs text-muted-foreground">—</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{imageSrc && (
|
||||||
|
<a
|
||||||
|
href={imageSrc}
|
||||||
|
download
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
|
||||||
|
>
|
||||||
|
<Download size={12} />
|
||||||
|
{t("common.download", "Göçürip al")}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── AuditRow ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface AuditRowProps {
|
||||||
|
id: string;
|
||||||
|
action: string;
|
||||||
|
by: string;
|
||||||
|
target: string;
|
||||||
|
status: string;
|
||||||
|
date: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuditRow({
|
||||||
|
id,
|
||||||
|
action,
|
||||||
|
by,
|
||||||
|
target,
|
||||||
|
status,
|
||||||
|
date,
|
||||||
|
}: AuditRowProps) {
|
||||||
|
return (
|
||||||
|
<tr className="border-b border-border last:border-0 hover:bg-muted/30 transition-colors">
|
||||||
|
<td className="px-4 py-2.5 text-xs font-mono text-primary">{id}</td>
|
||||||
|
<td className="px-4 py-2.5 text-sm text-foreground">{action}</td>
|
||||||
|
<td className="px-4 py-2.5 text-sm text-foreground">{by}</td>
|
||||||
|
<td className="px-4 py-2.5 text-sm text-foreground">{target}</td>
|
||||||
|
<td className="px-4 py-2.5">
|
||||||
|
<span className="inline-flex items-center gap-1.5 text-xs font-medium text-emerald-400 bg-emerald-400/10 border border-emerald-400/30 px-2 py-0.5 rounded-full">
|
||||||
|
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
|
||||||
|
{status}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="px-4 py-2.5 text-xs text-muted-foreground whitespace-nowrap">
|
||||||
|
{date}
|
||||||
|
</td>
|
||||||
|
<td className="px-4 py-2.5">
|
||||||
|
<button className="p-1 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors">
|
||||||
|
<Eye size={13} />
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── AuditLog (full collapsible table) ───────────────────────────────────────
|
||||||
|
|
||||||
|
export interface AuditLogProps {
|
||||||
|
logs: AuditRowProps[];
|
||||||
|
defaultOpen?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuditLog({ logs, defaultOpen = true }: AuditLogProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
"ID",
|
||||||
|
t("audit.columns.action", "AMALYŇ ADY"),
|
||||||
|
t("audit.columns.by", "KIM TARAPYNDAN"),
|
||||||
|
t("audit.columns.target", "AMALYŇ NYŞANY (TARIBESI)"),
|
||||||
|
t("audit.columns.status", "AMALYŇ STATUSY"),
|
||||||
|
t("audit.columns.date", "SENE"),
|
||||||
|
"",
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mb-6">
|
||||||
|
<details open={defaultOpen}>
|
||||||
|
<summary className="text-base font-semibold text-foreground mb-2 cursor-pointer select-none list-none flex items-center gap-1.5 w-fit">
|
||||||
|
{t("loanOrders.sections.audit", "Ammallar")}
|
||||||
|
<ChevronRight size={15} className="text-muted-foreground" />
|
||||||
|
</summary>
|
||||||
|
<div className="bg-card border border-border rounded-xl overflow-hidden mt-2">
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<table className="w-full text-sm">
|
||||||
|
<thead>
|
||||||
|
<tr className="border-b border-border bg-muted/30">
|
||||||
|
{columns.map((col, i) => (
|
||||||
|
<th
|
||||||
|
key={i}
|
||||||
|
className="px-4 py-2.5 text-left text-xs font-medium text-muted-foreground uppercase tracking-wide whitespace-nowrap"
|
||||||
|
>
|
||||||
|
{col}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{logs.length === 0 ? (
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
colSpan={columns.length}
|
||||||
|
className="text-center py-10 text-muted-foreground text-sm"
|
||||||
|
>
|
||||||
|
{t("common.noData", "Maglumat ýok")}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
) : (
|
||||||
|
logs.map((log) => <AuditRow key={log.id} {...log} />)
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-xs text-muted-foreground">
|
||||||
|
<span>{t("common.prev", "Öňki")}</span>
|
||||||
|
<span>
|
||||||
|
1–{logs.length} / {logs.length}
|
||||||
|
</span>
|
||||||
|
<span>{t("common.next", "Soňky")}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from "react";
|
||||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Trash2, Pencil, ChevronDown } from 'lucide-react'
|
import { Download, Trash2, Pencil, ChevronDown } from "lucide-react";
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import { Spinner } from '@/components/ui/spinner'
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -13,93 +13,83 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from "@/components/ui/alert-dialog";
|
||||||
import {
|
import {
|
||||||
useCardBalance,
|
useCardBalance,
|
||||||
useDeleteCardBalance,
|
useDeleteCardBalance,
|
||||||
useDownloadCardBalance,
|
useDownloadCardBalance,
|
||||||
} from '@/features/cardBalance/hooks/useCardBalance'
|
} from "@/features/cardBalance/hooks/useCardBalance";
|
||||||
|
import { InfoRow } from "@/components/viewPageComponents";
|
||||||
|
|
||||||
// ─── Types for operations table ───────────────────────────────────────────────
|
// ─── Types for operations table ───────────────────────────────────────────────
|
||||||
|
|
||||||
interface Operation {
|
interface Operation {
|
||||||
id: number
|
id: number;
|
||||||
action_name: string
|
action_name: string;
|
||||||
performed_by: string
|
performed_by: string;
|
||||||
target: string
|
target: string;
|
||||||
status: 'FINISHED' | 'PENDING' | 'FAILED'
|
status: "FINISHED" | "PENDING" | "FAILED";
|
||||||
date: string
|
date: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_STYLES: Record<string, string> = {
|
const STATUS_STYLES: Record<string, string> = {
|
||||||
FINISHED: 'bg-emerald-500/20 text-emerald-400 border border-emerald-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',
|
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',
|
FAILED: "bg-red-500/20 text-red-400 border border-red-500/30",
|
||||||
}
|
};
|
||||||
|
|
||||||
function OpStatusBadge({ status }: { status: string }) {
|
function OpStatusBadge({ status }: { status: string }) {
|
||||||
return (
|
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" />
|
<span className="w-1.5 h-1.5 rounded-full bg-current" />
|
||||||
{status}
|
{status}
|
||||||
</span>
|
</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 ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function CardBalanceViewPage() {
|
export default function CardBalanceViewPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
const [opsExpanded, setOpsExpanded] = useState(true)
|
const [opsExpanded, setOpsExpanded] = useState(true);
|
||||||
const [opsPage, setOpsPage] = useState(1)
|
const [opsPage, setOpsPage] = useState(1);
|
||||||
|
|
||||||
const numericId = Number(id)
|
const numericId = Number(id);
|
||||||
const { data, isLoading } = useCardBalance(numericId)
|
const { data, isLoading } = useCardBalance(numericId);
|
||||||
const deleteMutation = useDeleteCardBalance()
|
const deleteMutation = useDeleteCardBalance();
|
||||||
const downloadMutation = useDownloadCardBalance()
|
const downloadMutation = useDownloadCardBalance();
|
||||||
|
|
||||||
// Placeholder operations — in real app fetch from API using numericId
|
// Placeholder operations — in real app fetch from API using numericId
|
||||||
const operations: Operation[] = []
|
const operations: Operation[] = [];
|
||||||
const opsTotal = operations.length
|
const opsTotal = operations.length;
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
await deleteMutation.mutateAsync(numericId)
|
await deleteMutation.mutateAsync(numericId);
|
||||||
navigate('/card-balances')
|
navigate("/card-balances");
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-24">
|
<div className="flex items-center justify-center py-24">
|
||||||
<Spinner className="size-7 text-primary" />
|
<Spinner className="size-7 text-primary" />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center py-24 text-muted-foreground">
|
<div className="text-center py-24 text-muted-foreground">
|
||||||
{t('Not found', 'Tapylmady')}
|
{t("Not found", "Tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -107,18 +97,20 @@ export default function CardBalanceViewPage() {
|
|||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<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>
|
</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm"
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
onClick={() => downloadMutation.mutate(numericId)}
|
onClick={() => downloadMutation.mutate(numericId)}
|
||||||
disabled={downloadMutation.isPending}
|
disabled={downloadMutation.isPending}
|
||||||
>
|
>
|
||||||
<Download size={14} />
|
<Download size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm"
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||||
onClick={() => setDeleteOpen(true)}
|
onClick={() => setDeleteOpen(true)}
|
||||||
>
|
>
|
||||||
@@ -134,12 +126,27 @@ export default function CardBalanceViewPage() {
|
|||||||
|
|
||||||
{/* Detail card */}
|
{/* Detail card */}
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('ID', 'ID')} value={data.id} />
|
<InfoRow label={t("ID", "ID")} value={data.id} />
|
||||||
<DetailRow label={t('Passport series', 'Pasport seriýasy')} value={data.passport_series} />
|
<InfoRow
|
||||||
<DetailRow label={t('Passport number', 'Pasport belgisi')} value={data.passport_number} />
|
label={t("Passport series", "Pasport seriýasy")}
|
||||||
<DetailRow label={t('Card number', 'Kart belgisi')} value={data.card_number} />
|
value={data.passport_series}
|
||||||
<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("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>
|
</div>
|
||||||
|
|
||||||
{/* Ammallar (Operations) collapsible section */}
|
{/* Ammallar (Operations) collapsible section */}
|
||||||
@@ -150,11 +157,11 @@ export default function CardBalanceViewPage() {
|
|||||||
onClick={() => setOpsExpanded((v) => !v)}
|
onClick={() => setOpsExpanded((v) => !v)}
|
||||||
>
|
>
|
||||||
<span className="font-semibold text-foreground text-sm">
|
<span className="font-semibold text-foreground text-sm">
|
||||||
{t('Operations', 'Ammallar')}
|
{t("Operations", "Ammallar")}
|
||||||
</span>
|
</span>
|
||||||
<ChevronDown
|
<ChevronDown
|
||||||
size={15}
|
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>
|
</button>
|
||||||
|
|
||||||
@@ -165,12 +172,12 @@ export default function CardBalanceViewPage() {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr className="bg-muted/30 border-b border-border">
|
<tr className="bg-muted/30 border-b border-border">
|
||||||
{[
|
{[
|
||||||
t('ID', 'ID'),
|
t("ID", "ID"),
|
||||||
t('Action name', 'AMALYŇ ADY'),
|
t("Action name", "AMALYŇ ADY"),
|
||||||
t('Performed by', 'KIM TARAPYNDAN'),
|
t("Performed by", "KIM TARAPYNDAN"),
|
||||||
t('Target', 'AMALYŇ NYŞANY (TARGEDI)'),
|
t("Target", "AMALYŇ NYŞANY (TARGEDI)"),
|
||||||
t('Status', 'AMALYŇ STATUSY'),
|
t("Status", "AMALYŇ STATUSY"),
|
||||||
t('Date', 'SENE'),
|
t("Date", "SENE"),
|
||||||
].map((h) => (
|
].map((h) => (
|
||||||
<th
|
<th
|
||||||
key={h}
|
key={h}
|
||||||
@@ -184,19 +191,31 @@ export default function CardBalanceViewPage() {
|
|||||||
<tbody>
|
<tbody>
|
||||||
{operations.length === 0 ? (
|
{operations.length === 0 ? (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={6} className="text-center py-10 text-muted-foreground text-sm">
|
<td
|
||||||
{t('No operations found', 'Amal tapylmady')}
|
colSpan={6}
|
||||||
|
className="text-center py-10 text-muted-foreground text-sm"
|
||||||
|
>
|
||||||
|
{t("No operations found", "Amal tapylmady")}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : (
|
||||||
operations.map((op) => (
|
operations.map((op) => (
|
||||||
<tr key={op.id} className="border-b border-border/50 hover:bg-muted/20 transition-colors">
|
<tr
|
||||||
<td className="px-4 py-3 text-primary font-medium">{op.id}</td>
|
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.action_name}</td>
|
||||||
<td className="px-4 py-3">{op.performed_by}</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">{op.target}</td>
|
||||||
<td className="px-4 py-3"><OpStatusBadge status={op.status} /></td>
|
<td className="px-4 py-3">
|
||||||
<td className="px-4 py-3 text-muted-foreground">{op.date}</td>
|
<OpStatusBadge status={op.status} />
|
||||||
|
</td>
|
||||||
|
<td className="px-4 py-3 text-muted-foreground">
|
||||||
|
{op.date}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
@@ -206,14 +225,20 @@ export default function CardBalanceViewPage() {
|
|||||||
|
|
||||||
{/* Ops pagination */}
|
{/* Ops pagination */}
|
||||||
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-sm text-muted-foreground">
|
<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)}>
|
<Button
|
||||||
{t('Previous', 'Öňki')}
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
disabled={opsPage <= 1}
|
||||||
|
onClick={() => setOpsPage((p) => p - 1)}
|
||||||
|
>
|
||||||
|
{t("Previous", "Öňki")}
|
||||||
</Button>
|
</Button>
|
||||||
<span>
|
<span>
|
||||||
{opsTotal === 0 ? '0' : `1–${opsTotal}`} {t('of', 'of')} {opsTotal}
|
{opsTotal === 0 ? "0" : `1–${opsTotal}`} {t("of", "of")}{" "}
|
||||||
|
{opsTotal}
|
||||||
</span>
|
</span>
|
||||||
<Button variant="ghost" size="sm" disabled={true}>
|
<Button variant="ghost" size="sm" disabled={true}>
|
||||||
{t('Next', 'Indiki')}
|
{t("Next", "Indiki")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -224,25 +249,29 @@ export default function CardBalanceViewPage() {
|
|||||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>{t('Are you sure?', 'Eminsiňizmi?')}</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
|
{t("Are you sure?", "Eminsiňizmi?")}
|
||||||
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{t(
|
{t(
|
||||||
'This action cannot be undone.',
|
"This action cannot be undone.",
|
||||||
'Bu amal yzyna gaýtarylmaz. Kart galyndysy hemişelik öçüriler.',
|
"Bu amal yzyna gaýtarylmaz. Kart galyndysy hemişelik öçüriler.",
|
||||||
)}
|
)}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t('Cancel', 'Ýatyr')}</AlertDialogCancel>
|
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
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>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
import { useParams, useNavigate } from 'react-router-dom'
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { useCardPin, useDeleteCardPin } from '@/features/cardPins/hooks/useCardPins'
|
import {
|
||||||
import type { CardPinStatus } from '@/features/cardPins/api/cardPinApi'
|
useCardPin,
|
||||||
import { Spinner } from '@/components/ui/spinner'
|
useDeleteCardPin,
|
||||||
import { Button } from '@/components/ui/button'
|
} from "@/features/cardPins/hooks/useCardPins";
|
||||||
import { Pencil, Trash2, Download } from 'lucide-react'
|
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 {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -15,99 +18,71 @@ import {
|
|||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
AlertDialogTrigger,
|
AlertDialogTrigger,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from "@/components/ui/alert-dialog";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
import {
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
StatusBadge,
|
||||||
|
type StatusBadgeVariant,
|
||||||
|
} from "@/components/ui/statusBadge";
|
||||||
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
|
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_CONFIG = {
|
const STATUS_CONFIG = {
|
||||||
pending: {
|
pending: {
|
||||||
label: 'Garaşylýar',
|
label: "Garaşylýar",
|
||||||
variant: 'warning' as StatusBadgeVariant,
|
variant: "warning" as StatusBadgeVariant,
|
||||||
icon: AlertCircle,
|
icon: AlertCircle,
|
||||||
},
|
},
|
||||||
approved: {
|
approved: {
|
||||||
label: 'Tassyklandy',
|
label: "Tassyklandy",
|
||||||
variant: 'success' as StatusBadgeVariant,
|
variant: "success" as StatusBadgeVariant,
|
||||||
icon: CheckCircle2,
|
icon: CheckCircle2,
|
||||||
},
|
},
|
||||||
rejected: {
|
rejected: {
|
||||||
label: 'Ýatyryldy',
|
label: "Ýatyryldy",
|
||||||
variant: 'error' as StatusBadgeVariant,
|
variant: "error" as StatusBadgeVariant,
|
||||||
icon: XCircle,
|
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 }) {
|
function CardPinStatusBadge({ status }: { status: CardPinStatus }) {
|
||||||
const cfg = STATUS_CONFIG[status]
|
const cfg = STATUS_CONFIG[status];
|
||||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
if (!cfg)
|
||||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
return (
|
||||||
}
|
<span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||||
|
);
|
||||||
// ─── Field row ────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function FieldRow({ label, children }: { label: string; children: React.ReactNode }) {
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-[200px_1fr] items-start py-3 border-b border-border last:border-0 gap-4">
|
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||||
<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>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function CardPinViewPage() {
|
export default function CardPinViewPage() {
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { data, isLoading, isError } = useCardPin(id!)
|
const { data, isLoading, isError } = useCardPin(id!);
|
||||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin()
|
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin();
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-24">
|
<div className="flex items-center justify-center py-24">
|
||||||
<Spinner className="size-8 text-primary" />
|
<Spinner className="size-8 text-primary" />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isError || !data) {
|
if (isError || !data) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||||
{t('common.notFound', 'Maglumat tapylmady')}
|
{t("common.notFound", "Maglumat tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -115,32 +90,43 @@ export default function CardPinViewPage() {
|
|||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-start justify-between">
|
<div className="flex items-start justify-between">
|
||||||
<h1 className="text-xl font-bold text-foreground">
|
<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>
|
</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
<AlertDialogTrigger asChild>
|
<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} />
|
<Trash2 size={15} />
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogTrigger>
|
</AlertDialogTrigger>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>{t('cardPin.deleteTitle', 'Pozmak isleýärsiňizmi?')}</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
|
{t("cardPin.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||||
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{t('cardPin.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} {data.id}
|
{t("cardPin.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")}{" "}
|
||||||
|
{data.id}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel disabled={isDeleting}>
|
<AlertDialogCancel disabled={isDeleting}>
|
||||||
{t('common.cancel', 'Ýatyr')}
|
{t("common.cancel", "Ýatyr")}
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
disabled={isDeleting}
|
disabled={isDeleting}
|
||||||
className="bg-destructive hover:bg-destructive/90"
|
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>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
@@ -159,96 +145,108 @@ export default function CardPinViewPage() {
|
|||||||
|
|
||||||
{/* Main Info */}
|
{/* Main Info */}
|
||||||
<section className="bg-card border border-border rounded-lg px-6">
|
<section className="bg-card border border-border rounded-lg px-6">
|
||||||
<FieldRow label="ID">
|
<InfoRow label="ID">
|
||||||
<span className="font-mono">{data.id}</span>
|
<span className="font-mono">{data.id}</span>
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.createdAt', 'Döredilen wagty')}>
|
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")}>
|
||||||
{data.created_at}
|
{data.created_at}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.status', 'Status')}>
|
<InfoRow label={t("cardPin.status", "Status")}>
|
||||||
<CardPinStatusBadge status={data.status} />
|
<CardPinStatusBadge status={data.status} />
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.note', 'Bellik')}>
|
<InfoRow label={t("cardPin.note", "Bellik")}>
|
||||||
{data.note || '—'}
|
{data.note || "—"}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.createdBy', 'Sargyt eden')}>
|
<InfoRow label={t("cardPin.createdBy", "Sargyt eden")}>
|
||||||
<span className="text-primary font-medium">{data.created_by_label}</span>
|
<span className="text-primary font-medium">
|
||||||
</FieldRow>
|
{data.created_by_label}
|
||||||
|
</span>
|
||||||
|
</InfoRow>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Kart */}
|
{/* Kart */}
|
||||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||||
{t('cardPin.cardSection', 'Kart')}
|
{t("cardPin.cardSection", "Kart")}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="divide-y divide-border">
|
<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>
|
<span className="font-mono tracking-wider">{data.card_number}</span>
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.cardExpireMonth', 'Kart Möhleti (aý)')}>—</FieldRow>
|
<InfoRow label={t("cardPin.cardExpireMonth", "Kart Möhleti (aý)")}>
|
||||||
<FieldRow label={t('cardPin.cardExpireYear', 'Kart Möhleti (ýyl)')}>—</FieldRow>
|
—
|
||||||
|
</InfoRow>
|
||||||
|
<InfoRow label={t("cardPin.cardExpireYear", "Kart Möhleti (ýyl)")}>
|
||||||
|
—
|
||||||
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Lokasiýa */}
|
{/* Lokasiýa */}
|
||||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||||
{t('cardPin.locationSection', 'Lokasiýa')}
|
{t("cardPin.locationSection", "Lokasiýa")}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="divide-y divide-border">
|
<div className="divide-y divide-border">
|
||||||
<FieldRow label={t('cardPin.province', 'Welaýat')}>{data.province_label}</FieldRow>
|
<InfoRow label={t("cardPin.province", "Welaýat")}>
|
||||||
<FieldRow label={t('cardPin.branch', 'Şahamça')}>
|
{data.province_label}
|
||||||
<span className="text-primary font-medium">{data.branch_label}</span>
|
</InfoRow>
|
||||||
</FieldRow>
|
<InfoRow label={t("cardPin.branch", "Şahamça")}>
|
||||||
|
<span className="text-primary font-medium">
|
||||||
|
{data.branch_label}
|
||||||
|
</span>
|
||||||
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Şahsy maglumatlar */}
|
{/* Şahsy maglumatlar */}
|
||||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||||
{t('cardPin.personalSection', 'Şahsy maglumatlar')}
|
{t("cardPin.personalSection", "Şahsy maglumatlar")}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="divide-y divide-border">
|
<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}`}
|
{`${data.last_name} ${data.first_name} ${data.father_name}`}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.birthDate', 'Doglan güni')}>{data.birth_date}</FieldRow>
|
<InfoRow label={t("cardPin.birthDate", "Doglan güni")}>
|
||||||
<FieldRow label={t('cardPin.phone', 'Telefon')}>+{data.phone}</FieldRow>
|
{data.birth_date}
|
||||||
|
</InfoRow>
|
||||||
|
<InfoRow label={t("cardPin.phone", "Telefon")}>+{data.phone}</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Pasport */}
|
{/* Pasport */}
|
||||||
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
<section className="bg-card border border-border rounded-lg px-6 py-4">
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||||
{t('cardPin.passportSection', 'Pasport')}
|
{t("cardPin.passportSection", "Pasport")}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="divide-y divide-border mb-4">
|
<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}
|
{data.passport_series}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('cardPin.passportNumber', 'Pasport belgisi')}>
|
<InfoRow label={t("cardPin.passportNumber", "Pasport belgisi")}>
|
||||||
{data.passport_number}
|
{data.passport_number}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('cardPin.passportFile1', 'Pasport (sahypa 1)')}
|
label={t("cardPin.passportFile1", "Pasport (sahypa 1)")}
|
||||||
url={data.passport_file_1}
|
url={data.passport_file_1}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('cardPin.passportFile2', 'Pasport (2-3-nji sahypa)')}
|
label={t("cardPin.passportFile2", "Pasport (2-3-nji sahypa)")}
|
||||||
url={data.passport_file_2}
|
url={data.passport_file_2}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('cardPin.passportFile3', 'Pasport (8-9 sahypa)')}
|
label={t("cardPin.passportFile3", "Pasport (8-9 sahypa)")}
|
||||||
url={data.passport_file_3}
|
url={data.passport_file_3}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('cardPin.passportFile4', 'Pasport (32-nji sahypa)')}
|
label={t("cardPin.passportFile4", "Pasport (32-nji sahypa)")}
|
||||||
url={data.passport_file_4}
|
url={data.passport_file_4}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from "react";
|
||||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Trash2, Pencil, DownloadCloud } from 'lucide-react'
|
import { Download, Trash2, Pencil, DownloadCloud } from "lucide-react";
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import { Spinner } from '@/components/ui/spinner'
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -13,47 +13,43 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from "@/components/ui/alert-dialog";
|
||||||
import {
|
import {
|
||||||
useCardRequisite,
|
useCardRequisite,
|
||||||
useDeleteCardRequisite,
|
useDeleteCardRequisite,
|
||||||
useDownloadCardRequisite,
|
useDownloadCardRequisite,
|
||||||
} from '@/features/cardRequisites/hooks/useCardRequisites'
|
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||||
import type { CardRequisiteStatus } from '@/features/cardRequisites/api/cardRequisitesApi'
|
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||||
|
import { InfoRow } from "@/components/viewPageComponents";
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_BADGE: Record<CardRequisiteStatus, { label: string; className: string }> = {
|
const STATUS_BADGE: Record<
|
||||||
pending: { label: 'GARAŞYLÝAR', className: 'bg-yellow-500/20 text-yellow-400 border border-yellow-500/30' },
|
CardRequisiteStatus,
|
||||||
approved: { label: 'TASSYKLANAN', className: 'bg-emerald-500/20 text-emerald-400 border border-emerald-500/30' },
|
{ label: string; className: string }
|
||||||
rejected: { label: 'RET EDILEN', className: 'bg-red-500/20 text-red-400 border border-red-500/30' },
|
> = {
|
||||||
}
|
pending: {
|
||||||
|
label: "GARAŞYLÝAR",
|
||||||
// ─── Detail row ───────────────────────────────────────────────────────────────
|
className: "bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",
|
||||||
|
},
|
||||||
function DetailRow({
|
approved: {
|
||||||
label,
|
label: "TASSYKLANAN",
|
||||||
children,
|
className:
|
||||||
}: {
|
"bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",
|
||||||
label: string
|
},
|
||||||
children: React.ReactNode
|
rejected: {
|
||||||
}) {
|
label: "RET EDILEN",
|
||||||
return (
|
className: "bg-red-500/20 text-red-400 border border-red-500/30",
|
||||||
<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>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Section header ───────────────────────────────────────────────────────────
|
// ─── Section header ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function SectionTitle({ children }: { children: React.ReactNode }) {
|
function SectionTitle({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
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 ───────────────────────────────────────────────────────
|
// ─── 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"
|
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
|
||||||
>
|
>
|
||||||
<DownloadCloud size={13} />
|
<DownloadCloud size={13} />
|
||||||
{( 'Göçürip al')}
|
{"Göçürip al"}
|
||||||
</a>
|
</a>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@@ -86,62 +82,64 @@ function PassportImageRow({ label, url }: { label: string; url?: string }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function CardRequisiteViewPage() {
|
export default function CardRequisiteViewPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
const { data, isLoading } = useCardRequisite(id ?? '')
|
const { data, isLoading } = useCardRequisite(id ?? "");
|
||||||
const deleteMutation = useDeleteCardRequisite()
|
const deleteMutation = useDeleteCardRequisite();
|
||||||
const downloadMutation = useDownloadCardRequisite()
|
const downloadMutation = useDownloadCardRequisite();
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
await deleteMutation.mutateAsync(id ?? '')
|
await deleteMutation.mutateAsync(id ?? "");
|
||||||
navigate('/card-requisites')
|
navigate("/card-requisites");
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-24">
|
<div className="flex items-center justify-center py-24">
|
||||||
<Spinner className="size-7 text-primary" />
|
<Spinner className="size-7 text-primary" />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center py-24 text-muted-foreground">
|
<div className="text-center py-24 text-muted-foreground">
|
||||||
{t('Not found', 'Tapylmady')}
|
{t("Not found", "Tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusCfg = STATUS_BADGE[data.status] ?? STATUS_BADGE.pending
|
const statusCfg = STATUS_BADGE[data.status] ?? STATUS_BADGE.pending;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-0">
|
<div className="space-y-0">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between mb-4">
|
<div className="flex items-center justify-between mb-4">
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<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>
|
</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm"
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
onClick={() => downloadMutation.mutate(data.id)}
|
onClick={() => downloadMutation.mutate(data.id)}
|
||||||
disabled={downloadMutation.isPending}
|
disabled={downloadMutation.isPending}
|
||||||
>
|
>
|
||||||
<Download size={14} />
|
<Download size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="outline" size="sm"
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||||
onClick={() => setDeleteOpen(true)}
|
onClick={() => setDeleteOpen(true)}
|
||||||
>
|
>
|
||||||
@@ -157,71 +155,95 @@ export default function CardRequisiteViewPage() {
|
|||||||
|
|
||||||
{/* General info */}
|
{/* General info */}
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('ID', 'ID')}>{data.id}</DetailRow>
|
<InfoRow label={t("ID", "ID")}>{data.id}</InfoRow>
|
||||||
<DetailRow label={t('Created at', 'Döredilen wagty')}>{data.created_at}</DetailRow>
|
<InfoRow label={t("Created at", "Döredilen wagty")}>
|
||||||
<DetailRow label={t('Status', 'Status')}>
|
{data.created_at}
|
||||||
<span className={`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold ${statusCfg.className}`}>
|
</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}
|
{statusCfg.label}
|
||||||
</span>
|
</span>
|
||||||
</DetailRow>
|
</InfoRow>
|
||||||
<DetailRow label={t('Note', 'Bellik')}>
|
<InfoRow label={t("Note", "Bellik")}>{data.note || "—"}</InfoRow>
|
||||||
{data.note || '—'}
|
<InfoRow label={t("Requested by", "Sargyt eden:")}>
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('Requested by', 'Sargyt eden:')}>
|
|
||||||
{data.first_name && data.last_name ? (
|
{data.first_name && data.last_name ? (
|
||||||
<span className="text-primary font-medium">
|
<span className="text-primary font-medium">
|
||||||
{data.last_name}_{data.first_name} ({data.first_name})
|
{data.last_name}_{data.first_name} ({data.first_name})
|
||||||
</span>
|
</span>
|
||||||
) : '—'}
|
) : (
|
||||||
</DetailRow>
|
"—"
|
||||||
|
)}
|
||||||
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Card */}
|
{/* Card */}
|
||||||
<SectionTitle>{t('Card', 'Kart')}</SectionTitle>
|
<SectionTitle>{t("Card", "Kart")}</SectionTitle>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('Card number', 'Kart belgisi')}>{data.card_number}</DetailRow>
|
<InfoRow label={t("Card number", "Kart belgisi")}>
|
||||||
<DetailRow label={t('Card expiry month', 'Kart Möhleti (aý)')}>{data.card_expiry_month}</DetailRow>
|
{data.card_number}
|
||||||
<DetailRow label={t('Card expiry year', 'Kart Möhleti (ýyl)')}>{data.card_expiry_year}</DetailRow>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* Location */}
|
{/* Location */}
|
||||||
<SectionTitle>{t('Location', 'Lokasiýa')}</SectionTitle>
|
<SectionTitle>{t("Location", "Lokasiýa")}</SectionTitle>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('Province', 'Welaýat')}>{data.province_name ?? '—'}</DetailRow>
|
<InfoRow label={t("Province", "Welaýat")}>
|
||||||
<DetailRow label={t('Branch', 'Şahamça')}>
|
{data.province_name ?? "—"}
|
||||||
<span className="text-primary font-medium">{data.branch_name ?? '—'}</span>
|
</InfoRow>
|
||||||
</DetailRow>
|
<InfoRow label={t("Branch", "Şahamça")}>
|
||||||
|
<span className="text-primary font-medium">
|
||||||
|
{data.branch_name ?? "—"}
|
||||||
|
</span>
|
||||||
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Personal */}
|
{/* 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">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('Full name', 'Doly ady')}>
|
<InfoRow label={t("Full name", "Doly ady")}>
|
||||||
{[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(' ')}
|
{[data.first_name, data.last_name, data.middle_name]
|
||||||
</DetailRow>
|
.filter(Boolean)
|
||||||
<DetailRow label={t('Birth date', 'Doglan güni')}>{data.birth_date}</DetailRow>
|
.join(" ")}
|
||||||
<DetailRow label={t('Phone', 'Telefon')}>{data.phone}</DetailRow>
|
</InfoRow>
|
||||||
|
<InfoRow label={t("Birth date", "Doglan güni")}>
|
||||||
|
{data.birth_date}
|
||||||
|
</InfoRow>
|
||||||
|
<InfoRow label={t("Phone", "Telefon")}>{data.phone}</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Passport */}
|
{/* Passport */}
|
||||||
<SectionTitle>{t('Passport', 'Pasport')}</SectionTitle>
|
<SectionTitle>{t("Passport", "Pasport")}</SectionTitle>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('Passport series', 'Pasport seriýasy')}>{data.passport_series}</DetailRow>
|
<InfoRow label={t("Passport series", "Pasport seriýasy")}>
|
||||||
<DetailRow label={t('Passport number', 'Pasport belgisi')}>{data.passport_number}</DetailRow>
|
{data.passport_series}
|
||||||
|
</InfoRow>
|
||||||
|
<InfoRow label={t("Passport number", "Pasport belgisi")}>
|
||||||
|
{data.passport_number}
|
||||||
|
</InfoRow>
|
||||||
<PassportImageRow
|
<PassportImageRow
|
||||||
label={t('Passport (page 1)', 'Pasport (sahypa 1)')}
|
label={t("Passport (page 1)", "Pasport (sahypa 1)")}
|
||||||
url={data.passport_page1_url}
|
url={data.passport_page1_url}
|
||||||
/>
|
/>
|
||||||
<PassportImageRow
|
<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}
|
url={data.passport_page2_3_url}
|
||||||
/>
|
/>
|
||||||
<PassportImageRow
|
<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}
|
url={data.passport_page8_9_url}
|
||||||
/>
|
/>
|
||||||
<PassportImageRow
|
<PassportImageRow
|
||||||
label={t('Passport (page 32)', 'Pasport (32-nji sahypa)')}
|
label={t("Passport (page 32)", "Pasport (32-nji sahypa)")}
|
||||||
url={data.passport_page32_url}
|
url={data.passport_page32_url}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -230,25 +252,29 @@ export default function CardRequisiteViewPage() {
|
|||||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>{t('Are you sure?', 'Eminsiňizmi?')}</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
|
{t("Are you sure?", "Eminsiňizmi?")}
|
||||||
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{t(
|
{t(
|
||||||
'This action cannot be undone.',
|
"This action cannot be undone.",
|
||||||
'Bu amal yzyna gaýtarylmaz. Kart rekwiziti hemişelik öçüriler.',
|
"Bu amal yzyna gaýtarylmaz. Kart rekwiziti hemişelik öçüriler.",
|
||||||
)}
|
)}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t('Cancel', 'Ýatyr')}</AlertDialogCancel>
|
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
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>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from "react";
|
||||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Trash2, Pencil } from 'lucide-react'
|
import { Download, Trash2, Pencil } from "lucide-react";
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import { Spinner } from '@/components/ui/spinner'
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -13,59 +13,47 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from "@/components/ui/alert-dialog";
|
||||||
import {
|
import {
|
||||||
useCardTransaction,
|
useCardTransaction,
|
||||||
useDeleteCardTransaction,
|
useDeleteCardTransaction,
|
||||||
useDownloadCardTransaction,
|
useDownloadCardTransaction,
|
||||||
} from '@/features/cardTransactions/hooks/useCardTransactions'
|
} from "@/features/cardTransactions/hooks/useCardTransactions";
|
||||||
|
import { InfoRow } from "@/components/viewPageComponents";
|
||||||
// ─── 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 ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function CardTransactionViewPage() {
|
export default function CardTransactionViewPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
const numericId = Number(id)
|
const numericId = Number(id);
|
||||||
const { data, isLoading } = useCardTransaction(numericId)
|
const { data, isLoading } = useCardTransaction(numericId);
|
||||||
const deleteMutation = useDeleteCardTransaction()
|
const deleteMutation = useDeleteCardTransaction();
|
||||||
const downloadMutation = useDownloadCardTransaction()
|
const downloadMutation = useDownloadCardTransaction();
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
await deleteMutation.mutateAsync(numericId)
|
await deleteMutation.mutateAsync(numericId);
|
||||||
navigate('/card-transactions')
|
navigate("/card-transactions");
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-24">
|
<div className="flex items-center justify-center py-24">
|
||||||
<Spinner className="size-7 text-primary" />
|
<Spinner className="size-7 text-primary" />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center py-24 text-muted-foreground">
|
<div className="text-center py-24 text-muted-foreground">
|
||||||
{t('Not found', 'Tapylmady')}
|
{t("Not found", "Tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -73,7 +61,7 @@ export default function CardTransactionViewPage() {
|
|||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<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>
|
</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
@@ -93,12 +81,7 @@ export default function CardTransactionViewPage() {
|
|||||||
>
|
>
|
||||||
<Trash2 size={14} />
|
<Trash2 size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button variant="outline" size="sm" className="gap-1.5" asChild>
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
className="gap-1.5"
|
|
||||||
asChild
|
|
||||||
>
|
|
||||||
<Link to={`/card-transactions/${numericId}/edit`}>
|
<Link to={`/card-transactions/${numericId}/edit`}>
|
||||||
<Pencil size={14} />
|
<Pencil size={14} />
|
||||||
</Link>
|
</Link>
|
||||||
@@ -108,39 +91,56 @@ export default function CardTransactionViewPage() {
|
|||||||
|
|
||||||
{/* Detail card */}
|
{/* Detail card */}
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||||
<DetailRow label={t('ID', 'ID')} value={data.id} />
|
<InfoRow label={t("ID", "ID")} value={data.id} />
|
||||||
<DetailRow label={t('Passport series', 'Pasport seriýasy')} value={data.passport_series} />
|
<InfoRow
|
||||||
<DetailRow label={t('Passport number', 'Pasport belgisi')} value={data.passport_number} />
|
label={t("Passport series", "Pasport seriýasy")}
|
||||||
<DetailRow label={t('Card number', 'Kart belgisi')} value={data.card_number} />
|
value={data.passport_series}
|
||||||
<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("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>
|
</div>
|
||||||
|
|
||||||
{/* Delete dialog */}
|
{/* Delete dialog */}
|
||||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>{t('Are you sure?', 'Eminsiňizmi?')}</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
|
{t("Are you sure?", "Eminsiňizmi?")}
|
||||||
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{t(
|
{t(
|
||||||
'This action cannot be undone. This will permanently delete the card transaction.',
|
"This action cannot be undone. This will permanently delete the card transaction.",
|
||||||
'Bu amal yzyna gaýtarylmaz. Kart herekedi hemişelik öçüriler.',
|
"Bu amal yzyna gaýtarylmaz. Kart herekedi hemişelik öçüriler.",
|
||||||
)}
|
)}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t('Cancel', 'Ýatyr')}</AlertDialogCancel>
|
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||||
>
|
>
|
||||||
{deleteMutation.isPending
|
{deleteMutation.isPending
|
||||||
? t('Deleting...', 'Öçürilýär...')
|
? t("Deleting...", "Öçürilýär...")
|
||||||
: t('Delete', 'Öçür')}
|
: t("Delete", "Öçür")}
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from "react";
|
||||||
import { useParams, useNavigate, Link } from 'react-router-dom'
|
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Printer, Download, Trash2, Pencil } from 'lucide-react'
|
import { Printer, Download, Trash2, Pencil } from "lucide-react";
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -12,97 +12,52 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from "@/components/ui/alert-dialog";
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { useCardOrderById, useDeleteCardOrder } from '@/features/orderNewCard/hooks/useOrderNewCard'
|
import {
|
||||||
import type { CardOrderStatus } from '@/features/orderNewCard/api/orderNewCardApi'
|
useCardOrderById,
|
||||||
|
useDeleteCardOrder,
|
||||||
|
} from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||||
|
import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||||
|
import {
|
||||||
|
InfoRow,
|
||||||
|
Section,
|
||||||
|
PassportImage,
|
||||||
|
} from "@/components/viewPageComponents";
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_CFG: Record<CardOrderStatus, { label: string; className: string; icon: string }> = {
|
const STATUS_CFG: Record<
|
||||||
PENDING: { label: 'Garaşylýar', icon: '⏳', className: 'bg-amber-500/10 text-amber-400 border border-amber-500/20' },
|
CardOrderStatus,
|
||||||
APPROVED: { label: 'Tassyklandy', icon: '✓', className: 'bg-emerald-500/10 text-emerald-400 border border-emerald-500/20' },
|
{ label: string; className: string; icon: string }
|
||||||
REJECTED: { label: 'Ýatyryldy', icon: '✕', className: 'bg-red-500/10 text-red-400 border border-red-500/20' },
|
> = {
|
||||||
}
|
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 }) {
|
function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||||
const cfg = STATUS_CFG[status]
|
const cfg = STATUS_CFG[status];
|
||||||
return (
|
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>
|
<span className="text-[10px]">{cfg.icon}</span>
|
||||||
{cfg.label}
|
{cfg.label}
|
||||||
</span>
|
</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 ─────────────────────────────────────────────────────────
|
// ─── Loading skeleton ─────────────────────────────────────────────────────────
|
||||||
@@ -117,69 +72,74 @@ function DetailSkeleton() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── CardOrderDetailPage ──────────────────────────────────────────────────────
|
// ─── CardOrderDetailPage ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function CardOrderDetailPage() {
|
export default function CardOrderDetailPage() {
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
const { data: order, isLoading } = useCardOrderById(id ?? '')
|
const { data: order, isLoading } = useCardOrderById(id ?? "");
|
||||||
const deleteMutation = useDeleteCardOrder()
|
const deleteMutation = useDeleteCardOrder();
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
if (!id) return
|
if (!id) return;
|
||||||
await deleteMutation.mutateAsync(id)
|
await deleteMutation.mutateAsync(id);
|
||||||
navigate('/order-new-card')
|
navigate("/order-new-card");
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) return <DetailSkeleton />
|
if (isLoading) return <DetailSkeleton />;
|
||||||
if (!order) return (
|
if (!order)
|
||||||
<p className="text-muted-foreground text-sm">
|
return (
|
||||||
{t('common.notFound', 'Tapylmady')}
|
<p className="text-muted-foreground text-sm">
|
||||||
</p>
|
{t("common.notFound", "Tapylmady")}
|
||||||
)
|
</p>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-start justify-between mb-6 gap-4">
|
<div className="flex items-start justify-between mb-6 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<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>
|
<span className="text-primary font-mono">{order.id}</span>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-2 shrink-0">
|
<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} />
|
<Printer size={15} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" size="icon" title={t('common.export', 'Eksport')}>
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
title={t("common.export", "Eksport")}
|
||||||
|
>
|
||||||
<Download size={15} />
|
<Download size={15} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="text-destructive hover:text-destructive hover:bg-destructive/10 border-destructive/20"
|
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)}
|
onClick={() => setDeleteOpen(true)}
|
||||||
>
|
>
|
||||||
<Trash2 size={15} />
|
<Trash2 size={15} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button size="sm" asChild>
|
||||||
size="sm"
|
|
||||||
asChild
|
|
||||||
>
|
|
||||||
<Link to={`/order-new-card/${order.id}/edit`}>
|
<Link to={`/order-new-card/${order.id}/edit`}>
|
||||||
<Pencil size={14} className="mr-1.5" />
|
<Pencil size={14} className="mr-1.5" />
|
||||||
{t('common.edit', 'Düzetmek')}
|
{t("common.edit", "Düzetmek")}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -188,94 +148,119 @@ export default function CardOrderDetailPage() {
|
|||||||
{/* Main info */}
|
{/* Main info */}
|
||||||
<Section title="">
|
<Section title="">
|
||||||
<InfoRow label="ID">{order.id}</InfoRow>
|
<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}
|
{order.createdAt}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.isPaid', 'Tölenen')}>
|
<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
|
<span
|
||||||
${order.isPaid
|
className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold
|
||||||
? 'bg-emerald-500/15 text-emerald-400'
|
${
|
||||||
: 'bg-red-500/15 text-red-400'
|
order.isPaid
|
||||||
|
? "bg-emerald-500/15 text-emerald-400"
|
||||||
|
: "bg-red-500/15 text-red-400"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{order.isPaid ? '✓' : '✕'}
|
{order.isPaid ? "✓" : "✕"}
|
||||||
</span>
|
</span>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.status', 'Status')}>
|
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||||
<StatusBadge status={order.status} />
|
<StatusBadge status={order.status} />
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.note', 'Bellik')}>
|
<InfoRow label={t("cardOrder.field.note", "Bellik")}>
|
||||||
{order.note ?? '—'}
|
{order.note ?? "—"}
|
||||||
</InfoRow>
|
</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>
|
<span className="text-primary font-medium">{order.createdBy}</span>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Kart */}
|
{/* Kart */}
|
||||||
<Section title={t('cardOrder.section.card', 'Kart')}>
|
<Section title={t("cardOrder.section.card", "Kart")}>
|
||||||
<InfoRow label={t('cardOrder.field.issuanceReason', 'Kartyň çykarylmagynyň sebäbi')}>
|
<InfoRow
|
||||||
<span className="text-primary font-medium">{order.issuanceReasonName}</span>
|
label={t(
|
||||||
|
"cardOrder.field.issuanceReason",
|
||||||
|
"Kartyň çykarylmagynyň sebäbi",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="text-primary font-medium">
|
||||||
|
{order.issuanceReasonName}
|
||||||
|
</span>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.cardType', 'Kart görnüşi')}>
|
<InfoRow label={t("cardOrder.field.cardType", "Kart görnüşi")}>
|
||||||
<span className="text-cyan-400 font-medium">{order.cardTypeName}</span>
|
<span className="text-cyan-400 font-medium">
|
||||||
|
{order.cardTypeName}
|
||||||
|
</span>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Lokasiýa */}
|
{/* Lokasiýa */}
|
||||||
<Section title={t('cardOrder.section.location', 'Lokasiýa')}>
|
<Section title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||||
<InfoRow label={t('cardOrder.field.province', 'Welaýat')}>
|
<InfoRow label={t("cardOrder.field.province", "Welaýat")}>
|
||||||
{order.provinceName}
|
{order.provinceName}
|
||||||
</InfoRow>
|
</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>
|
<span className="text-cyan-400 font-medium">{order.branchName}</span>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Şahsy maglumatlar */}
|
{/* Şahsy maglumatlar */}
|
||||||
<Section title={t('cardOrder.section.personal', 'Şahsy maglumatlar')}>
|
<Section title={t("cardOrder.section.personal", "Şahsy maglumatlar")}>
|
||||||
<InfoRow label={t('cardOrder.field.fullName', 'Doly ady')}>
|
<InfoRow label={t("cardOrder.field.fullName", "Doly ady")}>
|
||||||
{[order.lastName, order.firstName, order.middleName].filter(Boolean).join(' ')}
|
{[order.lastName, order.firstName, order.middleName]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ")}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.birthDate', 'Doglan güni')}>
|
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>
|
||||||
{order.birthDate}
|
{order.birthDate}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.phone', 'Telefon')}>
|
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>
|
||||||
{order.phone}
|
{order.phone}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.phoneExtra', 'Telefon goşmaça')}>
|
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>
|
||||||
{order.phoneExtra ?? '—'}
|
{order.phoneExtra ?? "—"}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.citizenship', 'Raýatlyk')}>
|
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>
|
||||||
{order.citizenship}
|
{order.citizenship}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t('cardOrder.field.registeredAddress', 'Ýazgy edilen salgyňyz')}>
|
<InfoRow
|
||||||
|
label={t(
|
||||||
|
"cardOrder.field.registeredAddress",
|
||||||
|
"Ýazgy edilen salgyňyz",
|
||||||
|
)}
|
||||||
|
>
|
||||||
{order.registeredAddress}
|
{order.registeredAddress}
|
||||||
</InfoRow>
|
</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}
|
{order.currentAddress}
|
||||||
</InfoRow>
|
</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}
|
{order.workplace}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Pasport faýýlar */}
|
{/* Pasport faýýlar */}
|
||||||
<Section title={t('cardOrder.section.passportFiles', 'Pasport faýýlar')}>
|
<Section title={t("cardOrder.section.passportFiles", "Pasport faýýlar")}>
|
||||||
<PassportFileCard
|
<PassportImage
|
||||||
label={t('cardOrder.field.passportPage1', 'Pasport (sahypa 1)')}
|
label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")}
|
||||||
url={order.passportFiles.page1}
|
url={order.passportFiles.page1}
|
||||||
/>
|
/>
|
||||||
<PassportFileCard
|
<PassportImage
|
||||||
label={t('cardOrder.field.passportPage23', 'Pasport (2-3-nji sahypa)')}
|
label={t(
|
||||||
|
"cardOrder.field.passportPage23",
|
||||||
|
"Pasport (2-3-nji sahypa)",
|
||||||
|
)}
|
||||||
url={order.passportFiles.page23}
|
url={order.passportFiles.page23}
|
||||||
/>
|
/>
|
||||||
<PassportFileCard
|
<PassportImage
|
||||||
label={t('cardOrder.field.passportPage89', 'Pasport (8-9 sahypa)')}
|
label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")}
|
||||||
url={order.passportFiles.page89}
|
url={order.passportFiles.page89}
|
||||||
/>
|
/>
|
||||||
<PassportFileCard
|
<PassportImage
|
||||||
label={t('cardOrder.field.passportPage32', 'Pasport (32-nji sahypa)')}
|
label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")}
|
||||||
url={order.passportFiles.page32}
|
url={order.passportFiles.page32}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
@@ -285,30 +270,28 @@ export default function CardOrderDetailPage() {
|
|||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
{t('cardOrder.deleteTitle', 'Pozmak isleýärsiňizmi?')}
|
{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{t(
|
{t(
|
||||||
'cardOrder.deleteDescription',
|
"cardOrder.deleteDescription",
|
||||||
'Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.',
|
"Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.",
|
||||||
)}
|
)}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>
|
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||||
{t('common.cancel', 'Ýatyr')}
|
|
||||||
</AlertDialogCancel>
|
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||||
>
|
>
|
||||||
{deleteMutation.isPending
|
{deleteMutation.isPending
|
||||||
? t('common.deleting', 'Pozulýar...')
|
? t("common.deleting", "Pozulýar...")
|
||||||
: t('common.delete', 'Pozmak')}
|
: t("common.delete", "Pozmak")}
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
StatusBadge,
|
StatusBadge,
|
||||||
type StatusBadgeVariant,
|
type StatusBadgeVariant,
|
||||||
} from "@/components/ui/statusBadge";
|
} from "@/components/ui/statusBadge";
|
||||||
|
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||||
|
|
||||||
const STATUS_CONFIG = {
|
const STATUS_CONFIG = {
|
||||||
GARASYLYYAR: {
|
GARASYLYYAR: {
|
||||||
@@ -87,50 +88,7 @@ function PaymentStatusBadge({ status }: { status: PaymentStatus }) {
|
|||||||
}
|
}
|
||||||
// ─── Info Row Component ───────────────────────────────────────────────────────
|
// ─── Info Row Component ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
function InfoRow({
|
|
||||||
label,
|
|
||||||
value,
|
|
||||||
highlight = false,
|
|
||||||
}: {
|
|
||||||
label: string;
|
|
||||||
value: React.ReactNode;
|
|
||||||
highlight?: boolean;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-start py-2.5 border-b border-border last:border-b-0">
|
|
||||||
<span className="w-64 shrink-0 text-sm text-muted-foreground">
|
|
||||||
{label}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
"flex-1 text-sm",
|
|
||||||
highlight ? "text-primary font-medium" : "text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{value || "—"}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Section Component ────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function Section({
|
|
||||||
title,
|
|
||||||
children,
|
|
||||||
className,
|
|
||||||
}: {
|
|
||||||
title: string;
|
|
||||||
children: React.ReactNode;
|
|
||||||
className?: string;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div className={cn("space-y-1", className)}>
|
|
||||||
<h2 className="text-base font-semibold text-foreground mb-3">{title}</h2>
|
|
||||||
<div className="bg-card rounded-lg border border-border">{children}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Document Item Component ──────────────────────────────────────────────────
|
// ─── Document Item Component ──────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -234,14 +192,12 @@ export default function SberPaymentViewPage() {
|
|||||||
<Section title="Status">
|
<Section title="Status">
|
||||||
<div className="px-4">
|
<div className="px-4">
|
||||||
<InfoRow label="ID" value={order.id} />
|
<InfoRow label="ID" value={order.id} />
|
||||||
<InfoRow
|
<InfoRow label="Status">
|
||||||
label="Status"
|
<PaymentStatusBadge status={order.status} />
|
||||||
value={<PaymentStatusBadge status={order.status} />}
|
</InfoRow>
|
||||||
/>
|
<InfoRow label="Tolenen (Sul ay)">
|
||||||
<InfoRow
|
<PaymentPaidStatusBadge status={order.paidStatus} />
|
||||||
label="Tolenen (Sul ay)"
|
</InfoRow>
|
||||||
value={<PaymentPaidStatusBadge status={order.paidStatus} />}
|
|
||||||
/>
|
|
||||||
<InfoRow label="Bellik" value={order.bellik} />
|
<InfoRow label="Bellik" value={order.bellik} />
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
@@ -250,7 +206,7 @@ export default function SberPaymentViewPage() {
|
|||||||
<Section title="Lokasiya">
|
<Section title="Lokasiya">
|
||||||
<div className="px-4">
|
<div className="px-4">
|
||||||
<InfoRow label="Welayat" value={order.welayat} />
|
<InfoRow label="Welayat" value={order.welayat} />
|
||||||
<InfoRow label="Sahamca" value={order.sahamca} highlight />
|
<InfoRow label="Sahamca" value={order.sahamca} isLink />
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
} from '@/components/ui/alert-dialog'
|
} from '@/components/ui/alert-dialog'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||||
|
import { InfoRow, Section } from '@/components/viewPageComponents'
|
||||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_MAP: Record<IntlPaymentStatus, { label: string; variant: StatusBadgeVariant }> = {
|
const STATUS_MAP: Record<IntlPaymentStatus, { label: string; variant: StatusBadgeVariant }> = {
|
||||||
@@ -34,27 +34,8 @@ function PaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── FieldRow ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function FieldRow({ label, children }: { label: string; children: React.ReactNode }) {
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-[240px_1fr] items-start py-3 border-b border-border last:border-0 gap-4">
|
|
||||||
<span className="text-sm text-muted-foreground shrink-0">{label}</span>
|
|
||||||
<span className="text-sm text-foreground">{children ?? '—'}</span>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Section ──────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
|
||||||
return (
|
|
||||||
<section className="bg-card border border-border rounded-lg">
|
|
||||||
<h2 className="text-base font-semibold text-foreground px-6 pt-5 pb-3">{title}</h2>
|
|
||||||
<div className="px-6 pb-4">{children}</div>
|
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── DocFile row ─────────────────────────────────────────────────────────────
|
// ─── DocFile row ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -183,63 +164,63 @@ export default function IntlPaymentViewPage() {
|
|||||||
{/* Status */}
|
{/* Status */}
|
||||||
<Section title={t('intlPayment.statusSection', 'Status')}>
|
<Section title={t('intlPayment.statusSection', 'Status')}>
|
||||||
<div className="divide-y divide-border">
|
<div className="divide-y divide-border">
|
||||||
<FieldRow label={t('intlPayment.client', 'Ulanyjy')}>
|
<InfoRow label={t('intlPayment.client', 'Ulanyjy')}>
|
||||||
<span className="text-primary font-medium">{data.client_label}</span>
|
<span className="text-primary font-medium">{data.client_label}</span>
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label="ID">
|
<InfoRow label="ID">
|
||||||
<span className="font-mono">{data.id}</span>
|
<span className="font-mono">{data.id}</span>
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.status', 'Status')}>
|
<InfoRow label={t('intlPayment.status', 'Status')}>
|
||||||
<PaymentStatusBadge status={data.status} />
|
<PaymentStatusBadge status={data.status} />
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.tilowanMonth', 'Tölewan (Aý/aý)')}>
|
<InfoRow label={t('intlPayment.tilowanMonth', 'Tölewan (Aý/aý)')}>
|
||||||
{data.created_at}
|
{data.created_at}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.note', 'Bellik')}>
|
<InfoRow label={t('intlPayment.note', 'Bellik')}>
|
||||||
{data.note}
|
{data.note}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Ýüztumanyň görnüşi */}
|
{/* Ýüztumanyň görnüşi */}
|
||||||
<Section title={t('intlPayment.currencySection', 'Ýüztumanyň görnüşi')}>
|
<Section title={t('intlPayment.currencySection', 'Ýüztumanyň görnüşi')}>
|
||||||
<div className="divide-y divide-border">
|
<div className="divide-y divide-border">
|
||||||
<FieldRow label={t('intlPayment.currencyType', 'Ýüztumanyň görnüşi')}>
|
<InfoRow label={t('intlPayment.currencyType', 'Ýüztumanyň görnüşi')}>
|
||||||
{data.currency_type_label}
|
{data.currency_type_label}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Lokasiýa */}
|
{/* Lokasiýa */}
|
||||||
<Section title={t('intlPayment.locationSection', 'Lokasiýa')}>
|
<Section title={t('intlPayment.locationSection', 'Lokasiýa')}>
|
||||||
<div className="divide-y divide-border">
|
<div className="divide-y divide-border">
|
||||||
<FieldRow label={t('intlPayment.province', 'Welaýat')}>{data.province_label}</FieldRow>
|
<InfoRow label={t('intlPayment.province', 'Welaýat')}>{data.province_label}</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.branch', 'Şahamça')}>
|
<InfoRow label={t('intlPayment.branch', 'Şahamça')}>
|
||||||
<span className="text-primary font-medium">{data.branch_label}</span>
|
<span className="text-primary font-medium">{data.branch_label}</span>
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Şahsy maglumatlar */}
|
{/* Şahsy maglumatlar */}
|
||||||
<Section title={t('intlPayment.personalSection', 'Şahsy maglumatlar')}>
|
<Section title={t('intlPayment.personalSection', 'Şahsy maglumatlar')}>
|
||||||
<div className="divide-y divide-border">
|
<div className="divide-y divide-border">
|
||||||
<FieldRow label={t('intlPayment.passportFirstName', 'Pasportdaky ady')}>{data.passport_first_name}</FieldRow>
|
<InfoRow label={t('intlPayment.passportFirstName', 'Pasportdaky ady')}>{data.passport_first_name}</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.passportLastName', 'Pasportdaky familiýa')}>{data.passport_last_name}</FieldRow>
|
<InfoRow label={t('intlPayment.passportLastName', 'Pasportdaky familiýa')}>{data.passport_last_name}</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.phone', 'Telefon')}>+{data.phone}</FieldRow>
|
<InfoRow label={t('intlPayment.phone', 'Telefon')}>+{data.phone}</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.email', 'E-poçta')}>{data.email}</FieldRow>
|
<InfoRow label={t('intlPayment.email', 'E-poçta')}>{data.email}</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.homeAddress', 'Häzirki ýaşyş ýeri')}>{data.home_address}</FieldRow>
|
<InfoRow label={t('intlPayment.homeAddress', 'Häzirki ýaşyş ýeri')}>{data.home_address}</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* Töleg */}
|
{/* Töleg */}
|
||||||
<Section title={t('intlPayment.paymentSection', 'Töleg')}>
|
<Section title={t('intlPayment.paymentSection', 'Töleg')}>
|
||||||
<div className="divide-y divide-border mb-4">
|
<div className="divide-y divide-border mb-4">
|
||||||
<FieldRow label={t('intlPayment.payerFullName', 'Töleg upgradyjynyň maglumatlary')}>
|
<InfoRow label={t('intlPayment.payerFullName', 'Töleg upgradyjynyň maglumatlary')}>
|
||||||
{data.payer_full_name}
|
{data.payer_full_name}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
<FieldRow label={t('intlPayment.payerAccount', 'Töleg upgradyjynyň goşun hasaby')}>
|
<InfoRow label={t('intlPayment.payerAccount', 'Töleg upgradyjynyň goşun hasaby')}>
|
||||||
{data.payer_account_number}
|
{data.payer_account_number}
|
||||||
</FieldRow>
|
</InfoRow>
|
||||||
</div>
|
</div>
|
||||||
{/* Receiver table */}
|
{/* Receiver table */}
|
||||||
<div className="border border-border rounded-lg overflow-hidden">
|
<div className="border border-border rounded-lg overflow-hidden">
|
||||||
|
|||||||
@@ -1,152 +1,71 @@
|
|||||||
import { useNavigate, useParams } from 'react-router-dom'
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Trash2, Pencil, Download, ChevronRight, Eye } from 'lucide-react'
|
import { Trash2, Pencil, Download, ChevronRight, Eye } from "lucide-react";
|
||||||
import { useLoanOrderMobileById, useDeleteLoanOrderMobile } from '@/features/loanOrderMobiles/hooks/useLoanOrderMobiles'
|
import {
|
||||||
import { CreditCardVisual } from '@/components/creditCardVisual'
|
useLoanOrderMobileById,
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
useDeleteLoanOrderMobile,
|
||||||
import { toast } from 'sonner'
|
} from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||||
import type { LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
import { toast } from "sonner";
|
||||||
|
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||||
|
import {
|
||||||
|
StatusBadge,
|
||||||
|
type StatusBadgeVariant,
|
||||||
|
} from "@/components/ui/statusBadge";
|
||||||
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
|
|
||||||
|
import {
|
||||||
|
InfoRow,
|
||||||
|
Section,
|
||||||
|
PassportImage,
|
||||||
|
} from "@/components/viewPageComponents";
|
||||||
|
import { AuditRow, type AuditRowProps } from "@/components/viewPageComponents";
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_CONFIG = {
|
const STATUS_CONFIG = {
|
||||||
GARAŞYLÝAR: {
|
GARAŞYLÝAR: {
|
||||||
label: 'Garaşylýar',
|
label: "Garaşylýar",
|
||||||
variant: 'warning' as StatusBadgeVariant,
|
variant: "warning" as StatusBadgeVariant,
|
||||||
icon: AlertCircle,
|
icon: AlertCircle,
|
||||||
},
|
},
|
||||||
KANAGATLANDYRYLAN: {
|
KANAGATLANDYRYLAN: {
|
||||||
label: 'Tassyklandy',
|
label: "Tassyklandy",
|
||||||
variant: 'success' as StatusBadgeVariant,
|
variant: "success" as StatusBadgeVariant,
|
||||||
icon: CheckCircle2,
|
icon: CheckCircle2,
|
||||||
},
|
},
|
||||||
RED_EDILDI: {
|
RED_EDILDI: {
|
||||||
label: 'Ýatyryldy',
|
label: "Ýatyryldy",
|
||||||
variant: 'error' as StatusBadgeVariant,
|
variant: "error" as StatusBadgeVariant,
|
||||||
icon: XCircle,
|
icon: XCircle,
|
||||||
},
|
},
|
||||||
IŞLENÝÄR: {
|
IŞLENÝÄR: {
|
||||||
label: 'Işlenýär',
|
label: "Işlenýär",
|
||||||
variant: 'warning' as StatusBadgeVariant,
|
variant: "warning" as StatusBadgeVariant,
|
||||||
icon: AlertCircle,
|
icon: AlertCircle,
|
||||||
},
|
},
|
||||||
} satisfies Record<LoanOrderMobileStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
} satisfies Record<
|
||||||
|
LoanOrderMobileStatus,
|
||||||
|
{ label: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||||
|
>;
|
||||||
|
|
||||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
function LoanOrderMobileStatusBadge({
|
||||||
const cfg = STATUS_CONFIG[status]
|
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} />
|
status: LoanOrderMobileStatus;
|
||||||
}
|
}) {
|
||||||
|
const cfg = STATUS_CONFIG[status];
|
||||||
// ─── Sub-component Types ──────────────────────────────────────────────────────
|
if (!cfg)
|
||||||
|
return (
|
||||||
interface InfoRowProps {
|
<span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||||
label: string
|
);
|
||||||
value?: string | null
|
return (
|
||||||
isLink?: boolean
|
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||||
}
|
);
|
||||||
|
|
||||||
interface SectionProps {
|
|
||||||
title: string
|
|
||||||
children: React.ReactNode
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PassportImageProps {
|
|
||||||
label: string
|
|
||||||
src?: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AuditRowProps {
|
|
||||||
id: string
|
|
||||||
action: string
|
|
||||||
by: string
|
|
||||||
target: string
|
|
||||||
status: string
|
|
||||||
date: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── InfoRow ─────────────────────────────────────────────────────────────────
|
// ─── InfoRow ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function InfoRow({ label, value, isLink }: InfoRowProps) {
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
|
||||||
<span className="text-sm text-muted-foreground">{label}</span>
|
|
||||||
{value ? (
|
|
||||||
<span className={`text-sm ${isLink ? 'text-primary font-medium' : 'text-foreground'}`}>
|
|
||||||
{value}
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="text-muted-foreground/40 text-sm">—</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Section ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function Section({ title, children }: SectionProps) {
|
|
||||||
return (
|
|
||||||
<div className="mb-6">
|
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">{title}</h2>
|
|
||||||
<div className="bg-card border border-border rounded-xl overflow-hidden">{children}</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── PassportImage ────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function PassportImage({ label, src }: PassportImageProps) {
|
|
||||||
const { t } = useTranslation()
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-[220px_1fr] items-start py-3 px-4 border-b border-border last:border-0">
|
|
||||||
<span className="text-sm text-muted-foreground pt-1">{label}</span>
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
{src ? (
|
|
||||||
<img
|
|
||||||
src={src}
|
|
||||||
alt={label}
|
|
||||||
className="w-28 h-20 object-cover rounded-md border border-border"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="w-28 h-20 bg-muted rounded-md border border-border flex items-center justify-center">
|
|
||||||
<span className="text-xs text-muted-foreground">—</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<button className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit">
|
|
||||||
<Download size={12} />
|
|
||||||
{t('common.download', 'Göçürip al')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── AuditRow ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function AuditRow({ id, action, by, target, status, date }: AuditRowProps) {
|
|
||||||
return (
|
|
||||||
<tr className="border-b border-border last:border-0 hover:bg-muted/30 transition-colors">
|
|
||||||
<td className="px-4 py-2.5 text-xs font-mono text-primary">{id}</td>
|
|
||||||
<td className="px-4 py-2.5 text-sm text-foreground">{action}</td>
|
|
||||||
<td className="px-4 py-2.5 text-sm text-foreground">{by}</td>
|
|
||||||
<td className="px-4 py-2.5 text-sm text-foreground">{target}</td>
|
|
||||||
<td className="px-4 py-2.5">
|
|
||||||
<span className="inline-flex items-center gap-1.5 text-xs font-medium text-emerald-400 bg-emerald-400/10 border border-emerald-400/30 px-2 py-0.5 rounded-full">
|
|
||||||
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
|
|
||||||
{status}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="px-4 py-2.5 text-xs text-muted-foreground whitespace-nowrap">{date}</td>
|
|
||||||
<td className="px-4 py-2.5">
|
|
||||||
<button className="p-1 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors">
|
|
||||||
<Eye size={13} />
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function LoanOrderMobilesViewSkeleton() {
|
function LoanOrderMobilesViewSkeleton() {
|
||||||
@@ -154,7 +73,10 @@ function LoanOrderMobilesViewSkeleton() {
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Skeleton className="h-7 w-64" />
|
<Skeleton className="h-7 w-64" />
|
||||||
{[...Array(5)].map((_, i) => (
|
{[...Array(5)].map((_, i) => (
|
||||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
<div
|
||||||
|
key={i}
|
||||||
|
className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3"
|
||||||
|
>
|
||||||
<Skeleton className="h-4 w-32 mb-1" />
|
<Skeleton className="h-4 w-32 mb-1" />
|
||||||
{[...Array(3)].map((_, j) => (
|
{[...Array(3)].map((_, j) => (
|
||||||
<Skeleton key={j} className="h-4 w-full" />
|
<Skeleton key={j} className="h-4 w-full" />
|
||||||
@@ -162,74 +84,81 @@ function LoanOrderMobilesViewSkeleton() {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function LoanOrderMobilesViewPage() {
|
export default function LoanOrderMobilesViewPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const deleteMutation = useDeleteLoanOrderMobile()
|
const deleteMutation = useDeleteLoanOrderMobile();
|
||||||
|
|
||||||
const { data: order, isLoading } = useLoanOrderMobileById(id!)
|
const { data: order, isLoading } = useLoanOrderMobileById(id!);
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
if (!window.confirm(t('loanOrderMobiles.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
if (
|
||||||
|
!window.confirm(
|
||||||
|
t("loanOrderMobiles.deleteConfirm", "Bu sargyt pozulsynmy?"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return;
|
||||||
deleteMutation.mutate(id!, {
|
deleteMutation.mutate(id!, {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(t('loanOrderMobiles.deleteSuccess', 'Sargyt pozuldy'))
|
toast.success(t("loanOrderMobiles.deleteSuccess", "Sargyt pozuldy"));
|
||||||
navigate('/loan-order-mobiles')
|
navigate("/loan-order-mobiles");
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t('loanOrderMobiles.deleteError', 'Pozma wagty ýalňyşlyk ýüze çykdy'))
|
toast.error(
|
||||||
|
t("loanOrderMobiles.deleteError", "Pozma wagty ýalňyşlyk ýüze çykdy"),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) return <LoanOrderMobilesViewSkeleton />
|
if (isLoading) return <LoanOrderMobilesViewSkeleton />;
|
||||||
|
|
||||||
if (!order) {
|
if (!order) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||||
{t('common.notFound', 'Tapylmady')}
|
{t("common.notFound", "Tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace with real audit data from API when available
|
// Replace with real audit data from API when available
|
||||||
const auditLogs: AuditRowProps[] = [
|
const auditLogs: AuditRowProps[] = [
|
||||||
{
|
{
|
||||||
id: '44548',
|
id: "44548",
|
||||||
action: t('audit.actions.view', 'Görmek'),
|
action: t("audit.actions.view", "Görmek"),
|
||||||
by: order.createdBy ?? '',
|
by: order.createdBy ?? "",
|
||||||
target: `${t('loanOrderMobiles.title', 'Karz sargyt')}: ${order.id}`,
|
target: `${t("loanOrderMobiles.title", "Karz sargyt")}: ${order.id}`,
|
||||||
status: 'FINISHED',
|
status: "FINISHED",
|
||||||
date: order.createdAt ?? '',
|
date: order.createdAt ?? "",
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{/* Page Header */}
|
{/* Page Header */}
|
||||||
<div className="flex items-center justify-between mb-5">
|
<div className="flex items-center justify-between mb-5">
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<h1 className="text-xl font-semibold text-foreground">
|
||||||
{t('loanOrderMobiles.view.title', 'Karz sargyt giriş')}: {order.id}
|
{t("loanOrderMobiles.view.title", "Karz sargyt giriş")}: {order.id}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<button
|
<button
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
disabled={deleteMutation.isPending}
|
disabled={deleteMutation.isPending}
|
||||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||||
title={t('common.delete', 'Poz')}
|
title={t("common.delete", "Poz")}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(`/loan-order-mobiles/${order.id}/edit`)}
|
onClick={() => navigate(`/loan-order-mobiles/${order.id}/edit`)}
|
||||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||||
title={t('common.edit', 'Redaktirle')}
|
title={t("common.edit", "Redaktirle")}
|
||||||
>
|
>
|
||||||
<Pencil size={16} />
|
<Pencil size={16} />
|
||||||
</button>
|
</button>
|
||||||
@@ -242,182 +171,231 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
{/* Status row — special render */}
|
{/* Status row — special render */}
|
||||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
|
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
{t('loanOrders.columns.status', 'Status')}
|
{t("loanOrders.columns.status", "Status")}
|
||||||
</span>
|
</span>
|
||||||
<LoanOrderMobileStatusBadge status={order.status} />
|
<LoanOrderMobileStatusBadge status={order.status} />
|
||||||
</div>
|
</div>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.columns.createdAt', 'Döredilen wagty')}
|
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||||
value={order.createdAt}
|
value={order.createdAt}
|
||||||
/>
|
/>
|
||||||
<InfoRow label={t('loanOrders.columns.branch', 'Şahamça')} value={order.branch} isLink />
|
<InfoRow
|
||||||
<InfoRow label={t('loanOrders.fields.note', 'Bellik')} value={order.note || '-'} />
|
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||||
|
value={order.branch}
|
||||||
|
isLink
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.note", "Bellik")}
|
||||||
|
value={order.note || "-"}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ── Card ───────────────────────────────────────────────────────────── */}
|
{/* ── Card ───────────────────────────────────────────────────────────── */}
|
||||||
{(order.cardNumber || order.cardName) && (
|
{(order.cardNumber || order.cardName) && (
|
||||||
<Section title={t('loanOrders.sections.card', 'Kart')}>
|
<Section title={t("loanOrders.sections.card", "Kart")}>
|
||||||
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-b border-border flex items-center justify-center">
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-b border-border flex items-center justify-center">
|
||||||
<CreditCardVisual
|
<CreditCardVisual
|
||||||
cardNumber={order.cardNumber}
|
cardNumber={order.cardNumber}
|
||||||
cardName={order.cardName}
|
cardName={order.cardName}
|
||||||
expMonth={order.cardExpMonth}
|
expMonth={order.cardExpMonth}
|
||||||
expYear={order.cardExpYear}
|
expYear={order.cardExpYear}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<InfoRow label={t('loanOrders.fields.cardNumber', 'Kart belgisi')} value={order.cardNumber} />
|
<InfoRow
|
||||||
<InfoRow label={t('loanOrders.fields.cardName', 'Kartdaky ady')} value={order.cardName} />
|
label={t("loanOrders.fields.cardNumber", "Kart belgisi")}
|
||||||
|
value={order.cardNumber}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.cardName", "Kartdaky ady")}
|
||||||
|
value={order.cardName}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ── Loan ───────────────────────────────────────────────────────────── */}
|
{/* ── Loan ───────────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.loan', 'Karz')}>
|
<Section title={t("loanOrders.sections.loan", "Karz")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.columns.loanType', 'Karz görnüşi')}
|
label={t("loanOrders.columns.loanType", "Karz görnüşi")}
|
||||||
value={order.loanType}
|
value={order.loanType}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.loanAmount', 'Karz möçberi')}
|
label={t("loanOrders.fields.loanAmount", "Karz möçberi")}
|
||||||
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Location ───────────────────────────────────────────────────────── */}
|
{/* ── Location ───────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.location', 'Lokasiýa')}>
|
<Section title={t("loanOrders.sections.location", "Lokasiýa")}>
|
||||||
<InfoRow label={t('loanOrders.columns.region', 'Welaýat')} value={order.region} />
|
<InfoRow
|
||||||
|
label={t("loanOrders.columns.region", "Welaýat")}
|
||||||
|
value={order.region}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Personal Info ──────────────────────────────────────────────────── */}
|
{/* ── Personal Info ──────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.personal', 'Şahsy maglumatlar')}>
|
<Section title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.fullName', 'Doly ady')}
|
label={t("loanOrders.fields.fullName", "Doly ady")}
|
||||||
value={`${order.firstName} ${order.lastName} ${order.patronicName || ''}`.trim()}
|
value={`${order.firstName} ${order.lastName} ${order.patronicName || ""}`.trim()}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.education', 'Bilimi')}
|
label={t("loanOrders.fields.education", "Bilimi")}
|
||||||
value={order.education ?? undefined}
|
value={order.education ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.maritalStatus', 'Maşgala ýagdaýy')}
|
label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")}
|
||||||
value={order.marriageStatus ?? undefined}
|
value={order.marriageStatus ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.birthDate', 'Doglan güni')}
|
label={t("loanOrders.fields.birthDate", "Doglan güni")}
|
||||||
value={order.dateOfBirth ?? undefined}
|
value={order.dateOfBirth ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.registeredAddress', 'Ýazgy edilen salgyňyz')}
|
label={t(
|
||||||
|
"loanOrders.fields.registeredAddress",
|
||||||
|
"Ýazgy edilen salgyňyz",
|
||||||
|
)}
|
||||||
value={order.residence ?? undefined}
|
value={order.residence ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.currentAddress', 'Häzirki ýaşaýyş ýeri')}
|
label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")}
|
||||||
value={order.currentResidence ?? undefined}
|
value={order.currentResidence ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.loanHistory', 'Karz taryhy')}
|
label={t("loanOrders.fields.loanHistory", "Karz taryhy")}
|
||||||
value={order.loanHistory ?? undefined}
|
value={order.loanHistory ?? undefined}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Contacts ───────────────────────────────────────────────────────── */}
|
{/* ── Contacts ───────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.contacts', 'Habarlaşmak üçin maglumatlar')}>
|
<Section
|
||||||
|
title={t(
|
||||||
|
"loanOrders.sections.contacts",
|
||||||
|
"Habarlaşmak üçin maglumatlar",
|
||||||
|
)}
|
||||||
|
>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.email', 'E-poçta')}
|
label={t("loanOrders.fields.email", "E-poçta")}
|
||||||
value={order.email ?? undefined}
|
value={order.email ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow label={t('loanOrders.columns.phone', 'Telefon')} value={order.phone} />
|
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.phoneAlt', 'Telefon goşmaça')}
|
label={t("loanOrders.columns.phone", "Telefon")}
|
||||||
|
value={order.phone}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")}
|
||||||
value={order.phoneAdditional ?? undefined}
|
value={order.phoneAdditional ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.homePhone', 'Öý telefony')}
|
label={t("loanOrders.fields.homePhone", "Öý telefony")}
|
||||||
value={order.homePhone ?? undefined}
|
value={order.homePhone ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Employment ─────────────────────────────────────────────────────── */}
|
{/* ── Employment ─────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.employment', 'Iş')}>
|
<Section title={t("loanOrders.sections.employment", "Iş")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.employer', 'Işleýän edaranyň/kärhananyn ady')}
|
label={t(
|
||||||
|
"loanOrders.fields.employer",
|
||||||
|
"Işleýän edaranyň/kärhananyn ady",
|
||||||
|
)}
|
||||||
value={order.workCompany ?? undefined}
|
value={order.workCompany ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.deptPhone', 'Işgärler bölüminiň iş belgisi')}
|
label={t(
|
||||||
|
"loanOrders.fields.deptPhone",
|
||||||
|
"Işgärler bölüminiň iş belgisi",
|
||||||
|
)}
|
||||||
value={order.workHrPhone ?? undefined}
|
value={order.workHrPhone ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.workRegion', 'Işleýän welaýatyňyz')}
|
label={t("loanOrders.fields.workRegion", "Işleýän welaýatyňyz")}
|
||||||
value={order.workRegion ?? undefined}
|
value={order.workRegion ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.workCity', 'Işleýän etrabyňyz')}
|
label={t("loanOrders.fields.workCity", "Işleýän etrabyňyz")}
|
||||||
value={order.workProvince ?? undefined}
|
value={order.workProvince ?? undefined}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.position', 'Wezipe')}
|
label={t("loanOrders.fields.position", "Wezipe")}
|
||||||
value={order.position ?? undefined}
|
value={order.position ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.salary', 'Zähmet haky')}
|
label={t("loanOrders.fields.salary", "Zähmet haky")}
|
||||||
value={order.salary ? String(order.salary) : undefined}
|
value={order.salary ? String(order.salary) : undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.employedSince', 'Işe başlan wagtyňyz')}
|
label={t("loanOrders.fields.employedSince", "Işe başlan wagtyňyz")}
|
||||||
value={order.workStartedAt ?? undefined}
|
value={order.workStartedAt ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Passport ───────────────────────────────────────────────────────── */}
|
{/* ── Passport ───────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.passport', 'Pasport')}>
|
<Section title={t("loanOrders.sections.passport", "Pasport")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.passportNumber', 'Pasport')}
|
label={t("loanOrders.fields.passportNumber", "Pasport")}
|
||||||
value={order.passportNumber ?? undefined}
|
value={order.passportNumber ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.passportIssuedBy', 'Kim tarapyndan berildi')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportIssuedBy",
|
||||||
|
"Kim tarapyndan berildi",
|
||||||
|
)}
|
||||||
value={order.passportGivenBy ?? undefined}
|
value={order.passportGivenBy ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.passportBirthPlace', 'Doglan ýeri (pasport)')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportBirthPlace",
|
||||||
|
"Doglan ýeri (pasport)",
|
||||||
|
)}
|
||||||
value={order.bornPlace ?? undefined}
|
value={order.bornPlace ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage1', 'Pasport (sahypa 1)')}
|
label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")}
|
||||||
src={order.passportPage1Url ?? undefined}
|
src={order.passportPage1Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage23', 'Pasport (2-3-nji sahypa)')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportPage23",
|
||||||
|
"Pasport (2-3-nji sahypa)",
|
||||||
|
)}
|
||||||
src={order.passportPage23Url ?? undefined}
|
src={order.passportPage23Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage89', 'Pasport (8-9 sahypa)')}
|
label={t("loanOrders.fields.passportPage89", "Pasport (8-9 sahypa)")}
|
||||||
src={order.passportPage89Url ?? undefined}
|
src={order.passportPage89Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage32', 'Pasport (32-nji sahypa)')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportPage32",
|
||||||
|
"Pasport (32-nji sahypa)",
|
||||||
|
)}
|
||||||
src={order.passportPage32Url ?? undefined}
|
src={order.passportPage32Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Guarantor ──────────────────────────────────────────────────────── */}
|
{/* ── Guarantor ──────────────────────────────────────────────────────── */}
|
||||||
{(order.guarantor1Name || order.guarantor1CardNumber) && (
|
{(order.guarantor1Name || order.guarantor1CardNumber) && (
|
||||||
<Section title={t('loanOrders.sections.guarantor', '1. Zamun')}>
|
<Section title={t("loanOrders.sections.guarantor", "1. Zamun")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.guarantorName', 'Zamunyň doly ady')}
|
label={t("loanOrders.fields.guarantorName", "Zamunyň doly ady")}
|
||||||
value={`${order.guarantor1Name || ''} ${order.guarantor1Surname || ''} ${order.guarantor1Patronic || ''}`.trim()}
|
value={`${order.guarantor1Name || ""} ${order.guarantor1Surname || ""} ${order.guarantor1Patronic || ""}`.trim()}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.guarantorPassport', 'Pasport')}
|
label={t("loanOrders.fields.guarantorPassport", "Pasport")}
|
||||||
value={`${order.guarantor1PassportSerie || ''} ${order.guarantor1PassportNumber || ''}`.trim()}
|
value={`${order.guarantor1PassportSerie || ""} ${order.guarantor1PassportNumber || ""}`.trim()}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.guarantorSalary', 'Ortaca zähmet haky')}
|
label={t("loanOrders.fields.guarantorSalary", "Ortaca zähmet haky")}
|
||||||
value={order.guarantor1Salary ? String(order.guarantor1Salary) : undefined}
|
value={
|
||||||
|
order.guarantor1Salary
|
||||||
|
? String(order.guarantor1Salary)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
{order.guarantor1CardNumber && (
|
{order.guarantor1CardNumber && (
|
||||||
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
||||||
@@ -437,7 +415,7 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<details open>
|
<details open>
|
||||||
<summary className="text-base font-semibold text-foreground mb-2 cursor-pointer select-none list-none flex items-center gap-1.5 w-fit">
|
<summary className="text-base font-semibold text-foreground mb-2 cursor-pointer select-none list-none flex items-center gap-1.5 w-fit">
|
||||||
{t('loanOrders.sections.audit', 'Ammallar')}
|
{t("loanOrders.sections.audit", "Ammallar")}
|
||||||
<ChevronRight size={15} className="text-muted-foreground" />
|
<ChevronRight size={15} className="text-muted-foreground" />
|
||||||
</summary>
|
</summary>
|
||||||
<div className="bg-card border border-border rounded-xl overflow-hidden mt-2">
|
<div className="bg-card border border-border rounded-xl overflow-hidden mt-2">
|
||||||
@@ -446,13 +424,13 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr className="border-b border-border bg-muted/30">
|
<tr className="border-b border-border bg-muted/30">
|
||||||
{[
|
{[
|
||||||
'ID',
|
"ID",
|
||||||
t('audit.columns.action', 'AMALYŇ ADY'),
|
t("audit.columns.action", "AMALYŇ ADY"),
|
||||||
t('audit.columns.by', 'KIM TARAPYNDAN'),
|
t("audit.columns.by", "KIM TARAPYNDAN"),
|
||||||
t('audit.columns.target', 'AMALYŇ NYŞANY (TARIBESI)'),
|
t("audit.columns.target", "AMALYŇ NYŞANY (TARIBESI)"),
|
||||||
t('audit.columns.status', 'AMALYŇ STATUSY'),
|
t("audit.columns.status", "AMALYŇ STATUSY"),
|
||||||
t('audit.columns.date', 'SENE'),
|
t("audit.columns.date", "SENE"),
|
||||||
'',
|
"",
|
||||||
].map((col, i) => (
|
].map((col, i) => (
|
||||||
<th
|
<th
|
||||||
key={i}
|
key={i}
|
||||||
@@ -471,14 +449,15 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-xs text-muted-foreground">
|
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-xs text-muted-foreground">
|
||||||
<span>{t('common.prev', 'Öňki')}</span>
|
<span>{t("common.prev", "Öňki")}</span>
|
||||||
<span>1–{auditLogs.length} / {auditLogs.length}</span>
|
<span>
|
||||||
<span>{t('common.next', 'Soňky')}</span>
|
1–{auditLogs.length} / {auditLogs.length}
|
||||||
|
</span>
|
||||||
|
<span>{t("common.next", "Soňky")}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,150 +1,64 @@
|
|||||||
import { useNavigate, useParams } from 'react-router-dom'
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Trash2, Pencil, Download, ChevronRight, Eye } from 'lucide-react'
|
import { Trash2, Pencil, ChevronRight } from "lucide-react";
|
||||||
import { useLoanOrderById, useDeleteLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
|
import {
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
useLoanOrderById,
|
||||||
import { toast } from 'sonner'
|
useDeleteLoanOrder,
|
||||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
} from "@/features/loanOrders/hooks/useLoanOrders";
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import type { LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
import { toast } from "sonner";
|
||||||
|
import {
|
||||||
|
StatusBadge,
|
||||||
|
type StatusBadgeVariant,
|
||||||
|
} from "@/components/ui/statusBadge";
|
||||||
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
|
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||||
|
import {
|
||||||
|
InfoRow,
|
||||||
|
Section,
|
||||||
|
PassportImage,
|
||||||
|
} from "@/components/viewPageComponents";
|
||||||
|
import { AuditRow, type AuditRowProps } from "@/components/viewPageComponents";
|
||||||
|
|
||||||
const STATUS_CONFIG = {
|
const STATUS_CONFIG = {
|
||||||
GARAŞYLÝAR: {
|
GARAŞYLÝAR: {
|
||||||
label: 'Garaşylýar',
|
label: "Garaşylýar",
|
||||||
variant: 'warning' as StatusBadgeVariant,
|
variant: "warning" as StatusBadgeVariant,
|
||||||
icon: AlertCircle,
|
icon: AlertCircle,
|
||||||
},
|
},
|
||||||
KANAGATLANDYRYLAN: {
|
KANAGATLANDYRYLAN: {
|
||||||
label: 'Tassyklandy',
|
label: "Tassyklandy",
|
||||||
variant: 'success' as StatusBadgeVariant,
|
variant: "success" as StatusBadgeVariant,
|
||||||
icon: CheckCircle2,
|
icon: CheckCircle2,
|
||||||
},
|
},
|
||||||
RED_EDILDI: {
|
RED_EDILDI: {
|
||||||
label: 'Ýatyryldy',
|
label: "Ýatyryldy",
|
||||||
variant: 'error' as StatusBadgeVariant,
|
variant: "error" as StatusBadgeVariant,
|
||||||
icon: XCircle,
|
icon: XCircle,
|
||||||
},
|
},
|
||||||
IŞLENÝÄR: {
|
IŞLENÝÄR: {
|
||||||
label: 'Işlenýär',
|
label: "Işlenýär",
|
||||||
variant: 'warning' as StatusBadgeVariant,
|
variant: "warning" as StatusBadgeVariant,
|
||||||
icon: AlertCircle,
|
icon: AlertCircle,
|
||||||
},
|
},
|
||||||
} satisfies Record<LoanOrderMobileStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
} satisfies Record<
|
||||||
|
LoanOrderMobileStatus,
|
||||||
|
{ label: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||||
|
>;
|
||||||
|
|
||||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
function LoanOrderMobileStatusBadge({
|
||||||
const cfg = STATUS_CONFIG[status]
|
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} />
|
status: LoanOrderMobileStatus;
|
||||||
}
|
}) {
|
||||||
|
const cfg = STATUS_CONFIG[status];
|
||||||
|
if (!cfg)
|
||||||
// ─── Sub-component Types ──────────────────────────────────────────────────────
|
return (
|
||||||
|
<span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||||
interface InfoRowProps {
|
);
|
||||||
label: string
|
|
||||||
value?: string | null
|
|
||||||
isLink?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SectionProps {
|
|
||||||
title: string
|
|
||||||
children: React.ReactNode
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PassportImageProps {
|
|
||||||
label: string
|
|
||||||
src?: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AuditRowProps {
|
|
||||||
id: string
|
|
||||||
action: string
|
|
||||||
by: string
|
|
||||||
target: string
|
|
||||||
status: string
|
|
||||||
date: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── InfoRow ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function InfoRow({ label, value, isLink }: InfoRowProps) {
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||||
<span className="text-sm text-muted-foreground">{label}</span>
|
);
|
||||||
{value ? (
|
|
||||||
<span className={`text-sm ${isLink ? 'text-primary font-medium' : 'text-foreground'}`}>
|
|
||||||
{value}
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="text-muted-foreground/40 text-sm">—</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Section ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function Section({ title, children }: SectionProps) {
|
|
||||||
return (
|
|
||||||
<div className="mb-6">
|
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">{title}</h2>
|
|
||||||
<div className="bg-card border border-border rounded-xl overflow-hidden">{children}</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── PassportImage ────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function PassportImage({ label, src }: PassportImageProps) {
|
|
||||||
const { t } = useTranslation()
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-[220px_1fr] items-start py-3 px-4 border-b border-border last:border-0">
|
|
||||||
<span className="text-sm text-muted-foreground pt-1">{label}</span>
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
{src ? (
|
|
||||||
<img
|
|
||||||
src={src}
|
|
||||||
alt={label}
|
|
||||||
className="w-28 h-20 object-cover rounded-md border border-border"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="w-28 h-20 bg-muted rounded-md border border-border flex items-center justify-center">
|
|
||||||
<span className="text-xs text-muted-foreground">—</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<button className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit">
|
|
||||||
<Download size={12} />
|
|
||||||
{t('common.download', 'Göçürip al')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── AuditRow ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function AuditRow({ id, action, by, target, status, date }: AuditRowProps) {
|
|
||||||
return (
|
|
||||||
<tr className="border-b border-border last:border-0 hover:bg-muted/30 transition-colors">
|
|
||||||
<td className="px-4 py-2.5 text-xs font-mono text-primary">{id}</td>
|
|
||||||
<td className="px-4 py-2.5 text-sm text-foreground">{action}</td>
|
|
||||||
<td className="px-4 py-2.5 text-sm text-foreground">{by}</td>
|
|
||||||
<td className="px-4 py-2.5 text-sm text-foreground">{target}</td>
|
|
||||||
<td className="px-4 py-2.5">
|
|
||||||
<span className="inline-flex items-center gap-1.5 text-xs font-medium text-emerald-400 bg-emerald-400/10 border border-emerald-400/30 px-2 py-0.5 rounded-full">
|
|
||||||
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
|
|
||||||
{status}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="px-4 py-2.5 text-xs text-muted-foreground whitespace-nowrap">{date}</td>
|
|
||||||
<td className="px-4 py-2.5">
|
|
||||||
<button className="p-1 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors">
|
|
||||||
<Eye size={13} />
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||||
@@ -154,7 +68,10 @@ function LoanOrderViewSkeleton() {
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Skeleton className="h-7 w-64" />
|
<Skeleton className="h-7 w-64" />
|
||||||
{[...Array(5)].map((_, i) => (
|
{[...Array(5)].map((_, i) => (
|
||||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
<div
|
||||||
|
key={i}
|
||||||
|
className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3"
|
||||||
|
>
|
||||||
<Skeleton className="h-4 w-32 mb-1" />
|
<Skeleton className="h-4 w-32 mb-1" />
|
||||||
{[...Array(3)].map((_, j) => (
|
{[...Array(3)].map((_, j) => (
|
||||||
<Skeleton key={j} className="h-4 w-full" />
|
<Skeleton key={j} className="h-4 w-full" />
|
||||||
@@ -162,74 +79,77 @@ function LoanOrderViewSkeleton() {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function LoanOrderViewPage() {
|
export default function LoanOrderViewPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const deleteMutation = useDeleteLoanOrder()
|
const deleteMutation = useDeleteLoanOrder();
|
||||||
|
|
||||||
const { data: order, isLoading } = useLoanOrderById(id!)
|
const { data: order, isLoading } = useLoanOrderById(id!);
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
if (!window.confirm(t('loanOrders.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
if (!window.confirm(t("loanOrders.deleteConfirm", "Bu sargyt pozulsynmy?")))
|
||||||
|
return;
|
||||||
deleteMutation.mutate(id!, {
|
deleteMutation.mutate(id!, {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(t('loanOrders.deleteSuccess', 'Sargyt pozuldy'))
|
toast.success(t("loanOrders.deleteSuccess", "Sargyt pozuldy"));
|
||||||
navigate('/loan-orders')
|
navigate("/loan-orders");
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t('loanOrders.deleteError', 'Pozma wagty ýalňyşlyk ýüze çykdy'))
|
toast.error(
|
||||||
|
t("loanOrders.deleteError", "Pozma wagty ýalňyşlyk ýüze çykdy"),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) return <LoanOrderViewSkeleton />
|
if (isLoading) return <LoanOrderViewSkeleton />;
|
||||||
|
|
||||||
if (!order) {
|
if (!order) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||||
{t('common.notFound', 'Tapylmady')}
|
{t("common.notFound", "Tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace with real audit data from API when available
|
// Replace with real audit data from API when available
|
||||||
const auditLogs: AuditRowProps[] = [
|
const auditLogs: AuditRowProps[] = [
|
||||||
{
|
{
|
||||||
id: '44548',
|
id: "44548",
|
||||||
action: t('audit.actions.view', 'Görmek'),
|
action: t("audit.actions.view", "Görmek"),
|
||||||
by: order.createdBy ?? '',
|
by: order.createdBy ?? "",
|
||||||
target: `${t('loanOrders.title', 'Karz sargyt')}: ${order.id}`,
|
target: `${t("loanOrders.title", "Karz sargyt")}: ${order.id}`,
|
||||||
status: 'FINISHED',
|
status: "FINISHED",
|
||||||
date: order.createdAt ?? '',
|
date: order.createdAt ?? "",
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{/* Page Header */}
|
{/* Page Header */}
|
||||||
<div className="flex items-center justify-between mb-5">
|
<div className="flex items-center justify-between mb-5">
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<h1 className="text-xl font-semibold text-foreground">
|
||||||
{t('loanOrders.view.title', 'Karz sargyt giriş')}: {order.id}
|
{t("loanOrders.view.title", "Karz sargyt giriş")}: {order.id}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<button
|
<button
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
disabled={deleteMutation.isPending}
|
disabled={deleteMutation.isPending}
|
||||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||||
title={t('common.delete', 'Poz')}
|
title={t("common.delete", "Poz")}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(`/loan-orders/${order.id}/edit`)}
|
onClick={() => navigate(`/loan-orders/${order.id}/edit`)}
|
||||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||||
title={t('common.edit', 'Redaktirle')}
|
title={t("common.edit", "Redaktirle")}
|
||||||
>
|
>
|
||||||
<Pencil size={16} />
|
<Pencil size={16} />
|
||||||
</button>
|
</button>
|
||||||
@@ -240,156 +160,188 @@ export default function LoanOrderViewPage() {
|
|||||||
<div className="bg-card border border-border rounded-xl overflow-hidden mb-6">
|
<div className="bg-card border border-border rounded-xl overflow-hidden mb-6">
|
||||||
<InfoRow label="ID" value={order.id} />
|
<InfoRow label="ID" value={order.id} />
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.columns.createdAt', 'Döredilen wagty')}
|
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||||
value={order.createdAt}
|
value={order.createdAt}
|
||||||
/>
|
/>
|
||||||
{/* Status row — special render */}
|
{/* Status row — special render */}
|
||||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
|
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
{t('loanOrders.columns.status', 'Status')}
|
{t("loanOrders.columns.status", "Status")}
|
||||||
</span>
|
</span>
|
||||||
<LoanOrderMobileStatusBadge status={order.status} />
|
<LoanOrderMobileStatusBadge status={order.status} />
|
||||||
</div>
|
</div>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.amount', 'Berlik')}
|
label={t("loanOrders.fields.amount", "Berlik")}
|
||||||
value={order.amount ? String(order.amount) : undefined}
|
value={order.amount ? String(order.amount) : undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.createdBy', 'Sargyt eden')}
|
label={t("loanOrders.fields.createdBy", "Sargyt eden")}
|
||||||
value={order.createdBy ?? undefined}
|
value={order.createdBy ?? undefined}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ── Loan ───────────────────────────────────────────────────────────── */}
|
{/* ── Loan ───────────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.loan', 'Karz')}>
|
<Section title={t("loanOrders.sections.loan", "Karz")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.columns.loanType', 'Karz görnüşi')}
|
label={t("loanOrders.columns.loanType", "Karz görnüşi")}
|
||||||
value={order.loanType}
|
value={order.loanType}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.loanAmount', 'Karz mukdary')}
|
label={t("loanOrders.fields.loanAmount", "Karz mukdary")}
|
||||||
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Location ───────────────────────────────────────────────────────── */}
|
{/* ── Location ───────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.location', 'Lokasiýa')}>
|
<Section title={t("loanOrders.sections.location", "Lokasiýa")}>
|
||||||
<InfoRow label={t('loanOrders.columns.region', 'Welaýat')} value={order.region} />
|
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.columns.branch', 'Şahamça')}
|
label={t("loanOrders.columns.region", "Welaýat")}
|
||||||
|
value={order.region}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||||
value={order.branch}
|
value={order.branch}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Personal Info ──────────────────────────────────────────────────── */}
|
{/* ── Personal Info ──────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.personal', 'Şahsy maglumatlar')}>
|
<Section title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.fullName', 'Doly ady')}
|
label={t("loanOrders.fields.fullName", "Doly ady")}
|
||||||
value={order.fullName ?? `${order.firstName} ${order.lastName}`}
|
value={order.fullName ?? `${order.firstName} ${order.lastName}`}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.education', 'Bilimi')}
|
label={t("loanOrders.fields.education", "Bilimi")}
|
||||||
value={order.education ?? undefined}
|
value={order.education ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.maritalStatus', 'Maşgala ýagdaýy')}
|
label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")}
|
||||||
value={order.maritalStatus ?? undefined}
|
value={order.maritalStatus ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.birthDate', 'Doglan güni')}
|
label={t("loanOrders.fields.birthDate", "Doglan güni")}
|
||||||
value={order.birthDate ?? undefined}
|
value={order.birthDate ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.registeredAddress', 'Ýazgy edilen salgyňyz')}
|
label={t(
|
||||||
|
"loanOrders.fields.registeredAddress",
|
||||||
|
"Ýazgy edilen salgyňyz",
|
||||||
|
)}
|
||||||
value={order.registeredAddress ?? undefined}
|
value={order.registeredAddress ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.currentAddress', 'Häzirki ýaşaýyş ýeri')}
|
label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")}
|
||||||
value={order.currentAddress ?? undefined}
|
value={order.currentAddress ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Contacts ───────────────────────────────────────────────────────── */}
|
{/* ── Contacts ───────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.contacts', 'Habarlaşmak üçin maglumatlar')}>
|
<Section
|
||||||
|
title={t(
|
||||||
|
"loanOrders.sections.contacts",
|
||||||
|
"Habarlaşmak üçin maglumatlar",
|
||||||
|
)}
|
||||||
|
>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.email', 'E-poçta')}
|
label={t("loanOrders.fields.email", "E-poçta")}
|
||||||
value={order.email ?? undefined}
|
value={order.email ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow label={t('loanOrders.columns.phone', 'Telefon')} value={order.phone} />
|
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.phoneAlt', 'Telefon goşmaça')}
|
label={t("loanOrders.columns.phone", "Telefon")}
|
||||||
|
value={order.phone}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")}
|
||||||
value={order.phoneAlt ?? undefined}
|
value={order.phoneAlt ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.homePhone', 'Öý telefony')}
|
label={t("loanOrders.fields.homePhone", "Öý telefony")}
|
||||||
value={order.homePhone ?? undefined}
|
value={order.homePhone ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Employment ─────────────────────────────────────────────────────── */}
|
{/* ── Employment ─────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.employment', 'Iş')}>
|
<Section title={t("loanOrders.sections.employment", "Iş")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.employer', 'Işleýän edaranyň/kärhananyn ady')}
|
label={t(
|
||||||
|
"loanOrders.fields.employer",
|
||||||
|
"Işleýän edaranyň/kärhananyn ady",
|
||||||
|
)}
|
||||||
value={order.employer ?? undefined}
|
value={order.employer ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.deptPhone', 'Işgärler bölüminiň iş belgisi')}
|
label={t(
|
||||||
|
"loanOrders.fields.deptPhone",
|
||||||
|
"Işgärler bölüminiň iş belgisi",
|
||||||
|
)}
|
||||||
value={order.deptPhone ?? undefined}
|
value={order.deptPhone ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.workRegion', 'Işleýän welaýatyňyz')}
|
label={t("loanOrders.fields.workRegion", "Işleýän welaýatyňyz")}
|
||||||
value={order.workRegion ?? undefined}
|
value={order.workRegion ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.workCity', 'Işleýän etrabyňyz')}
|
label={t("loanOrders.fields.workCity", "Işleýän etrabyňyz")}
|
||||||
value={order.workCity ?? undefined}
|
value={order.workCity ?? undefined}
|
||||||
isLink
|
isLink
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.position', 'Wezipe')}
|
label={t("loanOrders.fields.position", "Wezipe")}
|
||||||
value={order.position ?? undefined}
|
value={order.position ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.salary', 'Zähmet haky')}
|
label={t("loanOrders.fields.salary", "Zähmet haky")}
|
||||||
value={order.salary ? String(order.salary) : undefined}
|
value={order.salary ? String(order.salary) : undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.employedSince', 'Işe başlan wagtyňyz')}
|
label={t("loanOrders.fields.employedSince", "Işe başlan wagtyňyz")}
|
||||||
value={order.employedSince ?? undefined}
|
value={order.employedSince ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
{/* ── Passport ───────────────────────────────────────────────────────── */}
|
{/* ── Passport ───────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanOrders.sections.passport', 'Pasport')}>
|
<Section title={t("loanOrders.sections.passport", "Pasport")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.passportNumber', 'Pasport')}
|
label={t("loanOrders.fields.passportNumber", "Pasport")}
|
||||||
value={order.passportNumber ?? undefined}
|
value={order.passportNumber ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.passportIssuedBy', 'Kim tarapyndan berildi')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportIssuedBy",
|
||||||
|
"Kim tarapyndan berildi",
|
||||||
|
)}
|
||||||
value={order.passportIssuedBy ?? undefined}
|
value={order.passportIssuedBy ?? undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanOrders.fields.passportBirthPlace', 'Doglan ýeri (pasport)')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportBirthPlace",
|
||||||
|
"Doglan ýeri (pasport)",
|
||||||
|
)}
|
||||||
value={order.passportBirthPlace ?? undefined}
|
value={order.passportBirthPlace ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage1', 'Pasport (sahypa 1)')}
|
label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")}
|
||||||
src={order.passportPage1Url ?? undefined}
|
src={order.passportPage1Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage23', 'Pasport (2-3-nji sahypa)')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportPage23",
|
||||||
|
"Pasport (2-3-nji sahypa)",
|
||||||
|
)}
|
||||||
src={order.passportPage23Url ?? undefined}
|
src={order.passportPage23Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage89', 'Pasport (8-9 sahypa)')}
|
label={t("loanOrders.fields.passportPage89", "Pasport (8-9 sahypa)")}
|
||||||
src={order.passportPage89Url ?? undefined}
|
src={order.passportPage89Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<PassportImage
|
<PassportImage
|
||||||
label={t('loanOrders.fields.passportPage32', 'Pasport (32-nji sahypa)')}
|
label={t(
|
||||||
|
"loanOrders.fields.passportPage32",
|
||||||
|
"Pasport (32-nji sahypa)",
|
||||||
|
)}
|
||||||
src={order.passportPage32Url ?? undefined}
|
src={order.passportPage32Url ?? undefined}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
@@ -398,7 +350,7 @@ export default function LoanOrderViewPage() {
|
|||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<details open>
|
<details open>
|
||||||
<summary className="text-base font-semibold text-foreground mb-2 cursor-pointer select-none list-none flex items-center gap-1.5 w-fit">
|
<summary className="text-base font-semibold text-foreground mb-2 cursor-pointer select-none list-none flex items-center gap-1.5 w-fit">
|
||||||
{t('loanOrders.sections.audit', 'Ammallar')}
|
{t("loanOrders.sections.audit", "Ammallar")}
|
||||||
<ChevronRight size={15} className="text-muted-foreground" />
|
<ChevronRight size={15} className="text-muted-foreground" />
|
||||||
</summary>
|
</summary>
|
||||||
<div className="bg-card border border-border rounded-xl overflow-hidden mt-2">
|
<div className="bg-card border border-border rounded-xl overflow-hidden mt-2">
|
||||||
@@ -407,13 +359,13 @@ export default function LoanOrderViewPage() {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr className="border-b border-border bg-muted/30">
|
<tr className="border-b border-border bg-muted/30">
|
||||||
{[
|
{[
|
||||||
'ID',
|
"ID",
|
||||||
t('audit.columns.action', 'AMALYŇ ADY'),
|
t("audit.columns.action", "AMALYŇ ADY"),
|
||||||
t('audit.columns.by', 'KIM TARAPYNDAN'),
|
t("audit.columns.by", "KIM TARAPYNDAN"),
|
||||||
t('audit.columns.target', 'AMALYŇ NYŞANY (TARIBESI)'),
|
t("audit.columns.target", "AMALYŇ NYŞANY (TARIBESI)"),
|
||||||
t('audit.columns.status', 'AMALYŇ STATUSY'),
|
t("audit.columns.status", "AMALYŇ STATUSY"),
|
||||||
t('audit.columns.date', 'SENE'),
|
t("audit.columns.date", "SENE"),
|
||||||
'',
|
"",
|
||||||
].map((col, i) => (
|
].map((col, i) => (
|
||||||
<th
|
<th
|
||||||
key={i}
|
key={i}
|
||||||
@@ -432,14 +384,15 @@ export default function LoanOrderViewPage() {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-xs text-muted-foreground">
|
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-xs text-muted-foreground">
|
||||||
<span>{t('common.prev', 'Öňki')}</span>
|
<span>{t("common.prev", "Öňki")}</span>
|
||||||
<span>1–{auditLogs.length} / {auditLogs.length}</span>
|
<span>
|
||||||
<span>{t('common.next', 'Soňky')}</span>
|
1–{auditLogs.length} / {auditLogs.length}
|
||||||
|
</span>
|
||||||
|
<span>{t("common.next", "Soňky")}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,49 +1,13 @@
|
|||||||
import { useNavigate, useParams } from 'react-router-dom'
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Trash2, Pencil } from 'lucide-react'
|
import { Trash2, Pencil } from "lucide-react";
|
||||||
import { useLoanRemainingById, useDeleteLoanRemaining } from '@/features/loanRemaining/hooks/useLoanRemaining'
|
import {
|
||||||
import { Skeleton } from '@/components/ui/skeleton'
|
useLoanRemainingById,
|
||||||
import { toast } from 'sonner'
|
useDeleteLoanRemaining,
|
||||||
|
} from "@/features/loanRemaining/hooks/useLoanRemaining";
|
||||||
// ─── Sub-component Types ──────────────────────────────────────────────────────
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
import { toast } from "sonner";
|
||||||
interface InfoRowProps {
|
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||||
label: string
|
|
||||||
value?: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SectionProps {
|
|
||||||
title: string
|
|
||||||
children: React.ReactNode
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── InfoRow ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function InfoRow({ label, value }: InfoRowProps) {
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
|
||||||
<span className="text-sm text-muted-foreground">{label}</span>
|
|
||||||
{value ? (
|
|
||||||
<span className="text-sm text-foreground">
|
|
||||||
{value}
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="text-muted-foreground/40 text-sm">—</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Section ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function Section({ title, children }: SectionProps) {
|
|
||||||
return (
|
|
||||||
<div className="mb-6">
|
|
||||||
<h2 className="text-base font-semibold text-foreground mb-2">{title}</h2>
|
|
||||||
<div className="bg-card border border-border rounded-xl overflow-hidden">{children}</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -57,40 +21,50 @@ function LoanRemainingViewSkeleton() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function LoanRemainingViewPage() {
|
export default function LoanRemainingViewPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>();
|
||||||
const deleteMutation = useDeleteLoanRemaining()
|
const deleteMutation = useDeleteLoanRemaining();
|
||||||
|
|
||||||
const { data: record, isLoading } = useLoanRemainingById(id!)
|
const { data: record, isLoading } = useLoanRemainingById(id!);
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
if (!window.confirm(t('loanRemaining.deleteConfirm', 'Bu ýazgy pozulsynmy?'))) return
|
if (
|
||||||
|
!window.confirm(t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?"))
|
||||||
|
)
|
||||||
|
return;
|
||||||
deleteMutation.mutate(Number(id!), {
|
deleteMutation.mutate(Number(id!), {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(t('loanRemaining.deleteSuccess', 'Ýazgy üstünlikli pozuldy'))
|
toast.success(
|
||||||
navigate('/loan-remaining')
|
t("loanRemaining.deleteSuccess", "Ýazgy üstünlikli pozuldy"),
|
||||||
|
);
|
||||||
|
navigate("/loan-remaining");
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t('loanRemaining.deleteError', 'Pozmak başartmady, gaýtadan synanyşyň'))
|
toast.error(
|
||||||
|
t(
|
||||||
|
"loanRemaining.deleteError",
|
||||||
|
"Pozmak başartmady, gaýtadan synanyşyň",
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isLoading) return <LoanRemainingViewSkeleton />
|
if (isLoading) return <LoanRemainingViewSkeleton />;
|
||||||
|
|
||||||
if (!record) {
|
if (!record) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||||
{t('common.notFound', 'Tapylmady')}
|
{t("common.notFound", "Tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -98,21 +72,22 @@ export default function LoanRemainingViewPage() {
|
|||||||
{/* Page Header */}
|
{/* Page Header */}
|
||||||
<div className="flex items-center justify-between mb-5">
|
<div className="flex items-center justify-between mb-5">
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<h1 className="text-xl font-semibold text-foreground">
|
||||||
{t('loanRemaining.view.title', 'Karz galyndysy maglumaty')}: {record.id}
|
{t("loanRemaining.view.title", "Karz galyndysy maglumaty")}:{" "}
|
||||||
|
{record.id}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<button
|
<button
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
disabled={deleteMutation.isPending}
|
disabled={deleteMutation.isPending}
|
||||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||||
title={t('common.delete', 'Poz')}
|
title={t("common.delete", "Poz")}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(`/loan-remaining/${record.id}/edit`)}
|
onClick={() => navigate(`/loan-remaining/${record.id}/edit`)}
|
||||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||||
title={t('common.edit', 'Redaktirle')}
|
title={t("common.edit", "Redaktirle")}
|
||||||
>
|
>
|
||||||
<Pencil size={16} />
|
<Pencil size={16} />
|
||||||
</button>
|
</button>
|
||||||
@@ -120,21 +95,21 @@ export default function LoanRemainingViewPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ── Basic Info ─────────────────────────────────────────────────────── */}
|
{/* ── Basic Info ─────────────────────────────────────────────────────── */}
|
||||||
<Section title={t('loanRemaining.sections.info', 'Esasy maglumatlar')}>
|
<Section title={t("loanRemaining.sections.info", "Esasy maglumatlar")}>
|
||||||
<InfoRow label="ID" value={String(record.id)} />
|
<InfoRow label="ID" value={String(record.id)} />
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanRemaining.columns.passportSeries', 'Pasport seriýasy')}
|
label={t("loanRemaining.columns.passportSeries", "Pasport seriýasy")}
|
||||||
value={record.passportSeries}
|
value={record.passportSeries}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanRemaining.columns.passportNumber', 'Pasport belgisi')}
|
label={t("loanRemaining.columns.passportNumber", "Pasport belgisi")}
|
||||||
value={record.passportNumber}
|
value={record.passportNumber}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t('loanRemaining.columns.loanAccount', 'Karz hasaby')}
|
label={t("loanRemaining.columns.loanAccount", "Karz hasaby")}
|
||||||
value={record.loanAccount}
|
value={record.loanAccount}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user