refactored badge
This commit is contained in:
@@ -3,16 +3,11 @@ import { Download, Eye, ChevronDown, Inbox } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
// ─── BentoGrid ────────────────────────────────────────────────────────────────
|
||||
|
||||
export function BentoGrid({
|
||||
cols = 2,
|
||||
children,
|
||||
}: {
|
||||
cols?: 1 | 2 | 3 | 4;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
@@ -31,30 +26,14 @@ interface BentoCardProps {
|
||||
noPadding?: boolean;
|
||||
}
|
||||
|
||||
export function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
noPadding,
|
||||
}: BentoCardProps) {
|
||||
const spanClass =
|
||||
span === "full"
|
||||
? "sm:col-span-full"
|
||||
: span === 2
|
||||
? "sm:col-span-2"
|
||||
: span === 3
|
||||
? "sm:col-span-3"
|
||||
: "";
|
||||
export function BentoCard({ title, span, children, noPadding }: BentoCardProps) {
|
||||
const spanClass = span === "full" ? "sm:col-span-full" : span === 2 ? "sm:col-span-2" : span === 3 ? "sm:col-span-3" : "";
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`bg-card border border-border rounded-xl overflow-hidden min-w-0 ${spanClass}`}
|
||||
>
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden min-w-0 ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide truncate">
|
||||
{title}
|
||||
</p>
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide truncate">{title}</p>
|
||||
</div>
|
||||
)}
|
||||
{noPadding ? <div>{children}</div> : children}
|
||||
@@ -69,23 +48,24 @@ export interface InfoRowProps {
|
||||
value?: string | number | null;
|
||||
children?: React.ReactNode;
|
||||
isLink?: boolean;
|
||||
href?: string;
|
||||
}
|
||||
|
||||
export function InfoRow({ label, value, children, isLink }: InfoRowProps) {
|
||||
export function InfoRow({ label, value, children, isLink, href }: InfoRowProps) {
|
||||
const content = children ?? (value != null ? String(value) : null);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border last:border-0 gap-0.5 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">
|
||||
{label}
|
||||
</span>
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">{label}</span>
|
||||
{content != null && content !== "" ? (
|
||||
typeof content === "string" ? (
|
||||
<span
|
||||
className={`text-sm break-words min-w-0 ${isLink ? "text-primary font-medium" : "text-foreground"}`}
|
||||
>
|
||||
{content}
|
||||
</span>
|
||||
isLink && href ? (
|
||||
<Link to={href} className="text-sm break-words min-w-0 text-[#2bbae6] font-medium cursor-pointer hover:underline">
|
||||
{content}
|
||||
</Link>
|
||||
) : (
|
||||
<span className={`text-sm break-words min-w-0 ${isLink ? "text-primary font-medium" : "text-foreground"}`}>{content}</span>
|
||||
)
|
||||
) : (
|
||||
<div className="text-sm min-w-0">{content}</div>
|
||||
)
|
||||
@@ -116,9 +96,7 @@ export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start py-2.5 px-4 border-b border-border last:border-0 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug pt-1">
|
||||
{label}
|
||||
</span>
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug pt-1">{label}</span>
|
||||
<div className="w-full min-w-0 flex flex-col gap-1.5 py-0.5">
|
||||
{langs.map((l) =>
|
||||
l.val ? (
|
||||
@@ -126,9 +104,7 @@ export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
<span className="inline-flex items-center justify-center border border-border bg-muted/50 text-muted-foreground text-[9px] font-bold px-1.5 py-0.5 rounded min-w-[22px] mt-0.5 select-none">
|
||||
{l.code}
|
||||
</span>
|
||||
<span className="text-sm text-foreground break-words flex-1 min-w-0">
|
||||
{l.val}
|
||||
</span>
|
||||
<span className="text-sm text-foreground break-words flex-1 min-w-0">{l.val}</span>
|
||||
</div>
|
||||
) : null,
|
||||
)}
|
||||
@@ -148,14 +124,8 @@ export interface SectionProps {
|
||||
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>
|
||||
{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>
|
||||
);
|
||||
}
|
||||
@@ -172,21 +142,11 @@ export function CollapsibleSection({ title, children }: CollapsibleSectionProps)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="flex items-center gap-2 mb-2 cursor-pointer select-none w-fit"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-2 cursor-pointer select-none w-fit" onClick={() => setOpen((v) => !v)}>
|
||||
<h2 className="text-base font-semibold text-foreground">{title}</h2>
|
||||
<ChevronDown
|
||||
size={15}
|
||||
className={`text-muted-foreground transition-transform duration-200 ${open ? "" : "-rotate-90"}`}
|
||||
/>
|
||||
<ChevronDown size={15} className={`text-muted-foreground transition-transform duration-200 ${open ? "" : "-rotate-90"}`} />
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
{open && <div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">{children}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -208,11 +168,7 @@ export function PassportImage({ label, src, url }: PassportImageProps) {
|
||||
<span className="text-xs sm:text-sm text-muted-foreground">{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"
|
||||
/>
|
||||
<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>
|
||||
@@ -264,9 +220,7 @@ export function StatusBadge({ status }: { status: string }) {
|
||||
|
||||
// ─── useAuditColumns ──────────────────────────────────────────────────────────
|
||||
|
||||
export function useAuditColumns(
|
||||
onView?: (log: AuditRowProps) => void,
|
||||
): ColumnDef<AuditRowProps>[] {
|
||||
export function useAuditColumns(onView?: (log: AuditRowProps) => void): ColumnDef<AuditRowProps>[] {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo(
|
||||
@@ -274,35 +228,23 @@ export function useAuditColumns(
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("audit.columns.id", "ID"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-xs font-mono text-muted-foreground">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-xs font-mono text-muted-foreground">{row.original.id}</span>,
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
accessorKey: "action",
|
||||
header: t("audit.columns.action", "AMALYŇ ADY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-medium text-primary">
|
||||
{row.original.action}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm font-medium text-primary">{row.original.action}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "by",
|
||||
header: t("audit.columns.by", "KIM TARAPYNDAN"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.by}</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.by}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "target",
|
||||
header: t("audit.columns.target", "AMALYŇ NYŞANY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.target}</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.target}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
@@ -313,11 +255,7 @@ export function useAuditColumns(
|
||||
{
|
||||
accessorKey: "date",
|
||||
header: t("audit.columns.date", "SENE"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground whitespace-nowrap">
|
||||
{row.original.date}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{row.original.date}</span>,
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
@@ -374,15 +312,7 @@ export function EmptyState({ label }: EmptyStateProps) {
|
||||
|
||||
// ─── AuditLog ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export function AuditLog({
|
||||
logs,
|
||||
currentPage,
|
||||
totalPages,
|
||||
totalCount,
|
||||
onPageChange,
|
||||
isLoading,
|
||||
onView,
|
||||
}: AuditLogProps) {
|
||||
export function AuditLog({ logs, currentPage, totalPages, totalCount, onPageChange, isLoading, onView }: AuditLogProps) {
|
||||
const columns = useAuditColumns(onView);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download } from "lucide-react";
|
||||
import { Download, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||
@@ -11,29 +11,20 @@ import { TableActions } from "@/components/tableActions";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
import { useCardRequisites, useDeleteCardRequisite, useDownloadCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisite, CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_BADGE: Record<CardRequisiteStatus, { label: string; className: string }> = {
|
||||
pending: {
|
||||
label: "Garaşylýar",
|
||||
className: "bg-yellow-500/15 text-yellow-500 border-yellow-500/20",
|
||||
},
|
||||
approved: {
|
||||
label: "Tassyklanan",
|
||||
className: "bg-emerald-500/15 text-emerald-500 border-emerald-500/20",
|
||||
},
|
||||
rejected: {
|
||||
label: "Ret edilen",
|
||||
className: "bg-red-500/15 text-red-500 border-red-500/20",
|
||||
},
|
||||
const STATUS_CONFIG: Record<CardRequisiteStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
pending: { label: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
approved: { label: "Tassyklanan", variant: "success", icon: CheckCircle2 },
|
||||
rejected: { label: "Ret edilen", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function StatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const cfg = STATUS_BADGE[status] ?? STATUS_BADGE.pending;
|
||||
return (
|
||||
<span className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${cfg.className}`}>{cfg.label}</span>
|
||||
);
|
||||
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -115,7 +106,7 @@ export default function CardRequisitesPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <CardRequisiteStatusBadge status={row.original.status} />,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Printer, Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Printer, Download, Trash2, Pencil, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
@@ -14,30 +14,24 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
useCardOrderById,
|
||||
useDeleteCardOrder,
|
||||
} from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import { useCardOrderById, useDeleteCardOrder } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_STYLE: Record<CardOrderStatus, { className: string; icon: string }> = {
|
||||
PENDING: { icon: "⏳", className: "bg-amber-500/10 text-amber-400 border border-amber-500/20" },
|
||||
APPROVED: { icon: "✓", className: "bg-emerald-500/10 text-emerald-400 border border-emerald-500/20" },
|
||||
REJECTED: { icon: "✕", className: "bg-red-500/10 text-red-400 border border-red-500/20" },
|
||||
}
|
||||
const STATUS_CONFIG: Record<CardOrderStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
PENDING: { label: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
APPROVED: { label: "Tassyklandy", variant: "success", icon: CheckCircle2 },
|
||||
REJECTED: { label: "Ýatyryldy", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const cfg = STATUS_STYLE[status]
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide ${cfg.className}`}>
|
||||
<span className="text-[10px]">{cfg.icon}</span>
|
||||
{t(`cardOrder.status.${status.toLowerCase()}`)}
|
||||
</span>
|
||||
)
|
||||
function CardOrderStatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`cardOrder.status.${status.toLowerCase()}`)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -57,43 +51,36 @@ function DetailSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardOrderDetailPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? "")
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? "");
|
||||
const deleteMutation = useDeleteCardOrder();
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!id) return
|
||||
await deleteMutation.mutateAsync(id)
|
||||
navigate("/order-new-card")
|
||||
}
|
||||
if (!id) return;
|
||||
await deleteMutation.mutateAsync(id);
|
||||
navigate("/order-new-card");
|
||||
};
|
||||
|
||||
if (isLoading) return <DetailSkeleton />
|
||||
if (!order)
|
||||
return (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</p>
|
||||
)
|
||||
if (isLoading) return <DetailSkeleton />;
|
||||
if (!order) return <p className="text-muted-foreground text-sm">{t("common.notFound", "Tapylmady")}</p>;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}:{" "}
|
||||
<span className="text-primary font-mono">{order.id}</span>
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}: <span className="text-primary font-mono">{order.id}</span>
|
||||
</h1>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
@@ -125,20 +112,18 @@ export default function CardOrderDetailPage() {
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardOrder.section.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")}>{order.id}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")}>
|
||||
{order.createdAt}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")}>{order.createdAt}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||
<StatusBadge status={order.status} />
|
||||
<CardOrderStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.isPaid", "Tölenen")}>
|
||||
<span className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold ${order.isPaid ? "bg-emerald-500/15 text-emerald-400" : "bg-red-500/15 text-red-400"}`}>
|
||||
<span
|
||||
className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold ${order.isPaid ? "bg-emerald-500/15 text-emerald-400" : "bg-red-500/15 text-red-400"}`}
|
||||
>
|
||||
{order.isPaid ? "✓" : "✕"}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")}>
|
||||
{order.note ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")}>{order.note ?? "—"}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{order.createdBy}</span>
|
||||
</InfoRow>
|
||||
@@ -154,9 +139,7 @@ export default function CardOrderDetailPage() {
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardOrder.field.province", "Welaýat")}>
|
||||
{order.provinceName}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.province", "Welaýat")}>{order.provinceName}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.branch", "Şahamça")}>
|
||||
<span className="text-cyan-400 font-medium">{order.branchName}</span>
|
||||
</InfoRow>
|
||||
@@ -169,58 +152,32 @@ export default function CardOrderDetailPage() {
|
||||
<InfoRow label={t("cardOrder.field.fullName", "Doly ady")}>
|
||||
{[order.lastName, order.firstName, order.middleName].filter(Boolean).join(" ")}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>
|
||||
{order.birthDate}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>
|
||||
{order.citizenship}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.registeredAddress", "Ýazgy edilen salgy")}>
|
||||
{order.registeredAddress}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.currentAddress", "Häzirki ýaşaýyş ýeri")}>
|
||||
{order.currentAddress}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.workplace", "Işleýän ýeri we wezipesi")}>
|
||||
{order.workplace}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>{order.birthDate}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>{order.citizenship}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.registeredAddress", "Ýazgy edilen salgy")}>{order.registeredAddress}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.currentAddress", "Häzirki ýaşaýyş ýeri")}>{order.currentAddress}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.workplace", "Işleýän ýeri we wezipesi")}>{order.workplace}</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.contacts", "Kontakt")}>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>
|
||||
{order.phone}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>
|
||||
{order.phoneExtra ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>{order.phone}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>{order.phoneExtra ?? "—"}</InfoRow>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("cardOrder.field.passportPage1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")}
|
||||
url={order.passportFiles.page1}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")} url={order.passportFiles.page1} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage23", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage23", "Pasport (2-3-nji sahypa)")}
|
||||
url={order.passportFiles.page23}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage23", "Pasport (2-3-nji sahypa)")} url={order.passportFiles.page23} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage89", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")}
|
||||
url={order.passportFiles.page89}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")} url={order.passportFiles.page89} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage32", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
url={order.passportFiles.page32}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")} url={order.passportFiles.page32} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
@@ -228,27 +185,19 @@ export default function CardOrderDetailPage() {
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardOrder.deleteDescription", "Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDelete}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending
|
||||
? t("common.deleting", "Pozulýar...")
|
||||
: t("common.delete", "Pozmak")}
|
||||
<AlertDialogAction onClick={handleDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteMutation.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Pozmak")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,36 +7,16 @@ import {
|
||||
Users,
|
||||
DollarSign,
|
||||
Activity,
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
AreaChart,
|
||||
Area,
|
||||
BarChart,
|
||||
Bar,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
PieChart,
|
||||
Pie,
|
||||
Cell,
|
||||
} from "recharts";
|
||||
import {
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
ChartLegend,
|
||||
ChartLegendContent,
|
||||
} from "@/components/ui/chart";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { AreaChart, Area, BarChart, Bar, XAxis, YAxis, CartesianGrid, PieChart, Pie, Cell } from "recharts";
|
||||
import { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent } from "@/components/ui/chart";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Mock data ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -67,17 +47,17 @@ const barData = [
|
||||
|
||||
const pieData = [
|
||||
{ name: "Kanagatlandyrylan", value: 6746, key: "approved" },
|
||||
{ name: "Garaşylýar", value: 208, key: "pending" },
|
||||
{ name: "Işlenilýär", value: 157, key: "processing" },
|
||||
{ name: "Ýatyrylan", value: 245, key: "rejected" },
|
||||
{ name: "Bellige alyndy", value: 450, key: "registered" },
|
||||
{ name: "Garaşylýar", value: 208, key: "pending" },
|
||||
{ name: "Işlenilýär", value: 157, key: "processing" },
|
||||
{ name: "Ýatyrylan", value: 245, key: "rejected" },
|
||||
{ name: "Bellige alyndy", value: 450, key: "registered" },
|
||||
];
|
||||
|
||||
const recentActivity = [
|
||||
{ id: "#KS-2841", name: "Serdar Annagurban", amount: "12 500 TMT", status: "approved", time: "2 min öň" },
|
||||
{ id: "#KS-2840", name: "Aýgül Myradowa", amount: "8 000 TMT", status: "pending", time: "14 min öň" },
|
||||
{ id: "#KS-2839", name: "Kakajan Durdyýew", amount: "25 000 TMT", status: "approved", time: "31 min öň" },
|
||||
{ id: "#KS-2838", name: "Ogulgerek Sähedowa", amount: "5 500 TMT", status: "rejected", time: "1 sa öň" },
|
||||
{ id: "#KS-2841", name: "Serdar Annagurban", amount: "12 500 TMT", status: "approved", time: "2 min öň" },
|
||||
{ id: "#KS-2840", name: "Aýgül Myradowa", amount: "8 000 TMT", status: "pending", time: "14 min öň" },
|
||||
{ id: "#KS-2839", name: "Kakajan Durdyýew", amount: "25 000 TMT", status: "approved", time: "31 min öň" },
|
||||
{ id: "#KS-2838", name: "Ogulgerek Sähedowa", amount: "5 500 TMT", status: "rejected", time: "1 sa öň" },
|
||||
{ id: "#KS-2837", name: "Merdan Hojamyradow", amount: "18 000 TMT", status: "approved", time: "2 sa öň" },
|
||||
];
|
||||
|
||||
@@ -90,27 +70,31 @@ const areaConfig = {
|
||||
|
||||
const barConfig = {
|
||||
approved: { label: "Tassyklanan", color: "var(--chart-1)" },
|
||||
rejected: { label: "Ýatyryldy", color: "var(--chart-5)" },
|
||||
rejected: { label: "Ýatyryldy", color: "var(--chart-5)" },
|
||||
} satisfies Record<string, { label: string; color: string }>;
|
||||
|
||||
const pieConfig = {
|
||||
approved: { label: "Kanagatlandyrylan", color: "var(--chart-2)" },
|
||||
pending: { label: "Garaşylýar", color: "var(--chart-4)" },
|
||||
processing: { label: "Işlenilýär", color: "var(--chart-1)" },
|
||||
rejected: { label: "Ýatyrylan", color: "var(--chart-5)" },
|
||||
registered: { label: "Bellige alyndy", color: "var(--chart-3)" },
|
||||
approved: { label: "Kanagatlandyrylan", color: "var(--chart-2)" },
|
||||
pending: { label: "Garaşylýar", color: "var(--chart-4)" },
|
||||
processing: { label: "Işlenilýär", color: "var(--chart-1)" },
|
||||
rejected: { label: "Ýatyrylan", color: "var(--chart-5)" },
|
||||
registered: { label: "Bellige alyndy", color: "var(--chart-3)" },
|
||||
} satisfies Record<string, { label: string; color: string }>;
|
||||
|
||||
// ─── Stat card ────────────────────────────────────────────────────────────────
|
||||
|
||||
function StatCard({
|
||||
title, value, change, icon: Icon, accent,
|
||||
title,
|
||||
value,
|
||||
change,
|
||||
icon: Icon,
|
||||
accent,
|
||||
}: {
|
||||
title: string
|
||||
value: string
|
||||
change: number
|
||||
icon: React.ElementType
|
||||
accent: string
|
||||
title: string;
|
||||
value: string;
|
||||
change: number;
|
||||
icon: React.ElementType;
|
||||
accent: string;
|
||||
}) {
|
||||
const positive = change >= 0;
|
||||
return (
|
||||
@@ -123,10 +107,12 @@ function StatCard({
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-3xl font-semibold tracking-tight">{value}</p>
|
||||
<p className={cn(
|
||||
"mt-1 flex items-center gap-1 text-xs font-medium",
|
||||
positive ? "text-emerald-600 dark:text-emerald-400" : "text-destructive",
|
||||
)}>
|
||||
<p
|
||||
className={cn(
|
||||
"mt-1 flex items-center gap-1 text-xs font-medium",
|
||||
positive ? "text-emerald-600 dark:text-emerald-400" : "text-destructive",
|
||||
)}
|
||||
>
|
||||
{positive ? <ArrowUpRight size={13} /> : <ArrowDownRight size={13} />}
|
||||
{Math.abs(change)}% geçen aýa garanyňda
|
||||
</p>
|
||||
@@ -152,22 +138,16 @@ function StatCardSkeleton() {
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
function StatusBadge({ status }: { status: string }) {
|
||||
const styles: Record<string, string> = {
|
||||
approved: "bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400 hover:bg-emerald-100",
|
||||
pending: "bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-400 hover:bg-amber-100",
|
||||
rejected: "bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-400 hover:bg-red-100",
|
||||
};
|
||||
const labels: Record<string, string> = {
|
||||
approved: "Tassyklandy",
|
||||
pending: "Garaşylýar",
|
||||
rejected: "Ýatyryldy",
|
||||
};
|
||||
return (
|
||||
<Badge variant="secondary" className={cn("text-[10px] px-1.5 py-0", styles[status])}>
|
||||
{labels[status]}
|
||||
</Badge>
|
||||
);
|
||||
const STATUS_CONFIG: Record<string, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
approved: { label: "Tassyklandy", variant: "success", icon: CheckCircle2 },
|
||||
pending: { label: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
rejected: { label: "Ýatyryldy", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function DashboardStatusBadge({ status }: { status: string }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -185,7 +165,9 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{[...Array(4)].map((_, i) => <StatCardSkeleton key={i} />)}
|
||||
{[...Array(4)].map((_, i) => (
|
||||
<StatCardSkeleton key={i} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
@@ -198,13 +180,17 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardContent>
|
||||
<div className="h-[220px] w-full flex flex-col justify-end relative">
|
||||
<div className="absolute left-0 top-0 h-full flex flex-col justify-between pb-6">
|
||||
{[...Array(5)].map((_, i) => <Skeleton key={i} className="h-2.5 w-6" />)}
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-6" />
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 flex-1 relative overflow-hidden rounded-md">
|
||||
<Skeleton className="absolute inset-0" />
|
||||
</div>
|
||||
<div className="ml-8 mt-2 flex justify-between">
|
||||
{[...Array(12)].map((_, i) => <Skeleton key={i} className="h-2.5 w-6" />)}
|
||||
{[...Array(12)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-6" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
@@ -256,7 +242,9 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardContent>
|
||||
<div className="h-[180px] w-full flex flex-col justify-end relative">
|
||||
<div className="absolute left-0 top-0 h-full flex flex-col justify-between pb-6">
|
||||
{[...Array(4)].map((_, i) => <Skeleton key={i} className="h-2.5 w-6" />)}
|
||||
{[...Array(4)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-6" />
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 flex items-end justify-between gap-1.5 h-[148px]">
|
||||
{[65, 85, 50, 95, 75, 40, 30].map((h, i) => (
|
||||
@@ -267,7 +255,9 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 mt-2 flex justify-between">
|
||||
{[...Array(7)].map((_, i) => <Skeleton key={i} className="h-2.5 w-4" />)}
|
||||
{[...Array(7)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-4" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
@@ -317,20 +307,40 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<div className="w-full space-y-6">
|
||||
{/* Header */}
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">
|
||||
{t("Dashboard", "Baş sahypa")}
|
||||
</h1>
|
||||
<p className="text-sm text-muted-foreground mt-0.5">
|
||||
{t("Overview of all operations", "Ähli amallaryň gysgaça görünüşi")}
|
||||
</p>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">{t("Dashboard", "Baş sahypa")}</h1>
|
||||
<p className="text-sm text-muted-foreground mt-0.5">{t("Overview of all operations", "Ähli amallaryň gysgaça görünüşi")}</p>
|
||||
</div>
|
||||
|
||||
{/* Stat cards */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<StatCard title={t("Loan orders", "Karz sargytlary")} value="2 841" change={12.4} icon={FileText} accent="bg-blue-100 text-blue-600 dark:bg-blue-950 dark:text-blue-400" />
|
||||
<StatCard title={t("Active cards", "Işjeň kartlar")} value="6 968" change={5.1} icon={CreditCard} accent="bg-violet-100 text-violet-600 dark:bg-violet-950 dark:text-violet-400" />
|
||||
<StatCard title={t("Active clients", "Işjeň müşderiler")} value="1 204" change={-3.2} icon={Users} accent="bg-amber-100 text-amber-600 dark:bg-amber-950 dark:text-amber-400" />
|
||||
<StatCard title={t("Online payments", "Onlaýn tölegler")} value="438" change={18.7} icon={DollarSign} accent="bg-emerald-100 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400" />
|
||||
<StatCard
|
||||
title={t("Loan orders", "Karz sargytlary")}
|
||||
value="2 841"
|
||||
change={12.4}
|
||||
icon={FileText}
|
||||
accent="bg-blue-100 text-blue-600 dark:bg-blue-950 dark:text-blue-400"
|
||||
/>
|
||||
<StatCard
|
||||
title={t("Active cards", "Işjeň kartlar")}
|
||||
value="6 968"
|
||||
change={5.1}
|
||||
icon={CreditCard}
|
||||
accent="bg-violet-100 text-violet-600 dark:bg-violet-950 dark:text-violet-400"
|
||||
/>
|
||||
<StatCard
|
||||
title={t("Active clients", "Işjeň müşderiler")}
|
||||
value="1 204"
|
||||
change={-3.2}
|
||||
icon={Users}
|
||||
accent="bg-amber-100 text-amber-600 dark:bg-amber-950 dark:text-amber-400"
|
||||
/>
|
||||
<StatCard
|
||||
title={t("Online payments", "Onlaýn tölegler")}
|
||||
value="438"
|
||||
change={18.7}
|
||||
icon={DollarSign}
|
||||
accent="bg-emerald-100 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Area chart + Pie chart */}
|
||||
@@ -345,11 +355,11 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<AreaChart data={areaData} margin={{ top: 4, right: 4, left: -24, bottom: 0 }}>
|
||||
<defs>
|
||||
<linearGradient id="fillLoans" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="5%" stopColor="var(--color-loans)" stopOpacity={0.2} />
|
||||
<stop offset="5%" stopColor="var(--color-loans)" stopOpacity={0.2} />
|
||||
<stop offset="95%" stopColor="var(--color-loans)" stopOpacity={0} />
|
||||
</linearGradient>
|
||||
<linearGradient id="fillCards" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="5%" stopColor="var(--color-cards)" stopOpacity={0.2} />
|
||||
<stop offset="5%" stopColor="var(--color-cards)" stopOpacity={0.2} />
|
||||
<stop offset="95%" stopColor="var(--color-cards)" stopOpacity={0} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
@@ -373,7 +383,17 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardContent>
|
||||
<ChartContainer config={pieConfig} className="h-[160px] w-full">
|
||||
<PieChart>
|
||||
<Pie data={pieData} cx="50%" cy="50%" innerRadius={48} outerRadius={72} paddingAngle={2} dataKey="value" nameKey="name" strokeWidth={0}>
|
||||
<Pie
|
||||
data={pieData}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
innerRadius={48}
|
||||
outerRadius={72}
|
||||
paddingAngle={2}
|
||||
dataKey="value"
|
||||
nameKey="name"
|
||||
strokeWidth={0}
|
||||
>
|
||||
{pieData.map((entry, i) => (
|
||||
<Cell key={i} fill={`var(--color-${entry.key})`} />
|
||||
))}
|
||||
@@ -388,9 +408,7 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<span className="h-1.5 w-1.5 rounded-full flex-shrink-0" style={{ background: `var(--color-${d.key})` }} />
|
||||
{d.name}
|
||||
</span>
|
||||
<span className="font-medium tabular-nums">
|
||||
{((d.value / total) * 100).toFixed(0)}%
|
||||
</span>
|
||||
<span className="font-medium tabular-nums">{((d.value / total) * 100).toFixed(0)}%</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -413,7 +431,7 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<YAxis tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: "var(--muted-foreground)" }} />
|
||||
<ChartTooltip content={<ChartTooltipContent />} />
|
||||
<Bar dataKey="approved" fill="var(--color-approved)" radius={[4, 4, 0, 0]} maxBarSize={20} />
|
||||
<Bar dataKey="rejected" fill="var(--color-rejected)" radius={[4, 4, 0, 0]} maxBarSize={20} />
|
||||
<Bar dataKey="rejected" fill="var(--color-rejected)" radius={[4, 4, 0, 0]} maxBarSize={20} />
|
||||
<ChartLegend content={<ChartLegendContent />} />
|
||||
</BarChart>
|
||||
</ChartContainer>
|
||||
@@ -424,9 +442,7 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-3">
|
||||
<div>
|
||||
<CardTitle>{t("Recent activity", "Soňky hereketler")}</CardTitle>
|
||||
<CardDescription className="mt-0.5">
|
||||
{t("Latest loan orders", "Iň soňky karz sargytlary")}
|
||||
</CardDescription>
|
||||
<CardDescription className="mt-0.5">{t("Latest loan orders", "Iň soňky karz sargytlary")}</CardDescription>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 text-xs text-muted-foreground">
|
||||
<Activity size={12} />
|
||||
@@ -442,11 +458,13 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium truncate">{item.name}</p>
|
||||
<p className="text-xs text-muted-foreground">{item.id} · {item.time}</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{item.id} · {item.time}
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-right shrink-0 space-y-0.5">
|
||||
<p className="text-sm font-medium tabular-nums">{item.amount}</p>
|
||||
<StatusBadge status={item.status} />
|
||||
<DashboardStatusBadge status={item.status} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -456,4 +474,4 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,60 +2,36 @@ import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import {
|
||||
useLoanOrderById,
|
||||
useDeleteLoanOrder,
|
||||
} from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { useLoanOrderById, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import {
|
||||
BentoGrid,
|
||||
BentoCard,
|
||||
InfoRow,
|
||||
PassportImage,
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
const STATUS_VARIANT: Record<LoanOrderStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
const STATUS_ICON: Record<LoanOrderStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({
|
||||
status,
|
||||
}: {
|
||||
status: LoanOrderMobileStatus;
|
||||
}) {
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant)
|
||||
return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return (
|
||||
<StatusBadge
|
||||
label={t(`loanOrderStatus.${status}`)}
|
||||
variant={variant}
|
||||
icon={Icon}
|
||||
/>
|
||||
);
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -66,10 +42,7 @@ function LoanOrderViewSkeleton() {
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{[...Array(6)].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-3 w-24 mb-1" />
|
||||
{[...Array(3)].map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
@@ -105,11 +78,7 @@ export default function LoanOrderViewPage() {
|
||||
if (isLoading) return <LoanOrderViewSkeleton />;
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</div>
|
||||
);
|
||||
return <div className="flex items-center justify-center h-64 text-muted-foreground text-sm">{t("common.notFound", "Tapylmady")}</div>;
|
||||
}
|
||||
|
||||
const auditLogs: AuditRowProps[] = [
|
||||
@@ -154,31 +123,17 @@ export default function LoanOrderViewPage() {
|
||||
{/* Meta */}
|
||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||
value={order.createdAt}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={order.createdAt} />
|
||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.amount", "Berlik")}
|
||||
value={order.amount ? String(order.amount) : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.createdBy", "Sargyt eden")}
|
||||
value={order.createdBy ?? undefined}
|
||||
isLink
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.amount", "Berlik")} value={order.amount ? String(order.amount) : undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.createdBy", "Sargyt eden")} value={order.createdBy ?? undefined} isLink />
|
||||
</BentoCard>
|
||||
|
||||
{/* Loan */}
|
||||
<BentoCard title={t("loanOrders.sections.loan", "Karz")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.loanType", "Karz görnüşi")}
|
||||
value={order.loanType}
|
||||
isLink
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.columns.loanType", "Karz görnüşi")} value={order.loanType} isLink />
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.loanAmount", "Karz mukdary")}
|
||||
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
||||
@@ -187,74 +142,29 @@ export default function LoanOrderViewPage() {
|
||||
|
||||
{/* Location */}
|
||||
<BentoCard title={t("loanOrders.sections.location", "Lokasiýa")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.region", "Welaýat")}
|
||||
value={order.region}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||
value={order.branch}
|
||||
isLink
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.columns.region", "Welaýat")} value={order.region} />
|
||||
<InfoRow label={t("loanOrders.columns.branch", "Şahamça")} value={order.branch} isLink />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Personal + Contacts ──────────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
{/* Personal */}
|
||||
<BentoCard
|
||||
title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}
|
||||
>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.fullName", "Doly ady")}
|
||||
value={order.fullName ?? `${order.firstName} ${order.lastName}`}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.education", "Bilimi")}
|
||||
value={order.education ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")}
|
||||
value={order.maritalStatus ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.birthDate", "Doglan güni")}
|
||||
value={order.birthDate ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.registeredAddress",
|
||||
"Ýazgy edilen salgy",
|
||||
)}
|
||||
value={order.registeredAddress ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.currentAddress",
|
||||
"Häzirki ýaşaýyş ýeri",
|
||||
)}
|
||||
value={order.currentAddress ?? undefined}
|
||||
/>
|
||||
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("loanOrders.fields.fullName", "Doly ady")} value={order.fullName ?? `${order.firstName} ${order.lastName}`} />
|
||||
<InfoRow label={t("loanOrders.fields.education", "Bilimi")} value={order.education ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")} value={order.maritalStatus ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.birthDate", "Doglan güni")} value={order.birthDate ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")} value={order.registeredAddress ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")} value={order.currentAddress ?? undefined} />
|
||||
</BentoCard>
|
||||
|
||||
{/* Contacts */}
|
||||
<BentoCard title={t("loanOrders.sections.contacts", "Habarlaşmak")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.email", "E-poçta")}
|
||||
value={order.email ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.phone", "Telefon")}
|
||||
value={order.phone}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")}
|
||||
value={order.phoneAlt ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.homePhone", "Öý telefony")}
|
||||
value={order.homePhone ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.email", "E-poçta")} value={order.email ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.columns.phone", "Telefon")} value={order.phone} />
|
||||
<InfoRow label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")} value={order.phoneAlt ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.homePhone", "Öý telefony")} value={order.homePhone ?? undefined} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
@@ -262,58 +172,21 @@ export default function LoanOrderViewPage() {
|
||||
<BentoGrid cols={2}>
|
||||
{/* Employment */}
|
||||
<BentoCard title={t("loanOrders.sections.employment", "Iş")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.employer", "Kärhananyň ady")}
|
||||
value={order.employer ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.deptPhone",
|
||||
"Işgärler bölüminiň belgisi",
|
||||
)}
|
||||
value={order.deptPhone ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.workRegion", "Işleýän welaýaty")}
|
||||
value={order.workRegion ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.workCity", "Işleýän etraby")}
|
||||
value={order.workCity ?? undefined}
|
||||
isLink
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.position", "Wezipe")}
|
||||
value={order.position ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.salary", "Zähmet haky")}
|
||||
value={order.salary ? String(order.salary) : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.employedSince", "Işe başlan wagty")}
|
||||
value={order.employedSince ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.employer", "Kärhananyň ady")} value={order.employer ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.deptPhone", "Işgärler bölüminiň belgisi")} value={order.deptPhone ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.workRegion", "Işleýän welaýaty")} value={order.workRegion ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.workCity", "Işleýän etraby")} value={order.workCity ?? undefined} isLink />
|
||||
<InfoRow label={t("loanOrders.fields.position", "Wezipe")} value={order.position ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.salary", "Zähmet haky")} value={order.salary ? String(order.salary) : undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.employedSince", "Işe başlan wagty")} value={order.employedSince ?? undefined} />
|
||||
</BentoCard>
|
||||
|
||||
{/* Passport info */}
|
||||
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
||||
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport")} value={order.passportNumber ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportIssuedBy ?? undefined} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.passportNumber", "Pasport")}
|
||||
value={order.passportNumber ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.passportIssuedBy",
|
||||
"Kim tarapyndan berildi",
|
||||
)}
|
||||
value={order.passportIssuedBy ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.passportBirthPlace",
|
||||
"Doglan ýeri (pasport)",
|
||||
)}
|
||||
label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")}
|
||||
value={order.passportBirthPlace ?? undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -322,35 +195,20 @@ export default function LoanOrderViewPage() {
|
||||
{/* ── Row 4: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")}
|
||||
src={order.passportPage1Url ?? undefined}
|
||||
/>
|
||||
<PassportImage label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")} src={order.passportPage1Url ?? undefined} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage23", "Sahypa 2-3")}>
|
||||
<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}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage89", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t(
|
||||
"loanOrders.fields.passportPage89",
|
||||
"Pasport (8-9 sahypa)",
|
||||
)}
|
||||
src={order.passportPage89Url ?? undefined}
|
||||
/>
|
||||
<PassportImage label={t("loanOrders.fields.passportPage89", "Pasport (8-9 sahypa)")} src={order.passportPage89Url ?? undefined} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage32", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t(
|
||||
"loanOrders.fields.passportPage32",
|
||||
"Pasport (32-nji sahypa)",
|
||||
)}
|
||||
label={t("loanOrders.fields.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
src={order.passportPage32Url ?? undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
Reference in New Issue
Block a user