refoctored some view pages
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
import { Download, Eye, ChevronRight } from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { Download, Eye, ChevronDown } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
|
||||
// ─── 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",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}[cols];
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>;
|
||||
}
|
||||
|
||||
// ─── BentoCard ────────────────────────────────────────────────────────────────
|
||||
@@ -22,14 +31,25 @@ interface BentoCardProps {
|
||||
noPadding?: boolean;
|
||||
}
|
||||
|
||||
export function BentoCard({ title, span, children, noPadding }: BentoCardProps) {
|
||||
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" : ""
|
||||
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">
|
||||
@@ -39,34 +59,31 @@ export function BentoCard({ title, span, children, noPadding }: BentoCardProps)
|
||||
)}
|
||||
{noPadding ? <div>{children}</div> : children}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── 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;
|
||||
}
|
||||
|
||||
|
||||
// ─── InfoRow ──────────────────────────────────────────────────────────────────
|
||||
export function InfoRow({ label, value, children, isLink }: 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"}`}>
|
||||
<span
|
||||
className={`text-sm break-words min-w-0 ${isLink ? "text-primary font-medium" : "text-foreground"}`}
|
||||
>
|
||||
{content}
|
||||
</span>
|
||||
) : (
|
||||
@@ -87,9 +104,7 @@ export interface MultiLangRowProps {
|
||||
}
|
||||
|
||||
export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
if (!value) {
|
||||
return <InfoRow label={label} value="—" />;
|
||||
}
|
||||
if (!value) return <InfoRow label={label} value="—" />;
|
||||
|
||||
const langs = [
|
||||
{ code: "TK", val: value.tk },
|
||||
@@ -101,7 +116,9 @@ 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 ? (
|
||||
@@ -113,7 +130,7 @@ export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
{l.val}
|
||||
</span>
|
||||
</div>
|
||||
) : null
|
||||
) : null,
|
||||
)}
|
||||
{!hasAny && <span className="text-sm text-muted-foreground/40">—</span>}
|
||||
</div>
|
||||
@@ -122,7 +139,6 @@ export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
}
|
||||
|
||||
// ─── Section ──────────────────────────────────────────────────────────────────
|
||||
// title is optional — omit or pass empty string to skip the heading
|
||||
|
||||
export interface SectionProps {
|
||||
title?: string;
|
||||
@@ -144,8 +160,38 @@ export function Section({ title, children }: SectionProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// ─── CollapsibleSection ────────────────────────────────────────────────────────
|
||||
|
||||
export interface CollapsibleSectionProps {
|
||||
title: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function CollapsibleSection({ title, children }: CollapsibleSectionProps) {
|
||||
const [open, setOpen] = useState(true);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<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"}`}
|
||||
/>
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── PassportImage ────────────────────────────────────────────────────────────
|
||||
// Accepts both `src` and `url` prop names for compatibility
|
||||
|
||||
export interface PassportImageProps {
|
||||
label: string;
|
||||
@@ -153,7 +199,6 @@ export interface PassportImageProps {
|
||||
url?: string | null;
|
||||
}
|
||||
|
||||
// ─── PassportImage ────────────────────────────────────────────────────────────
|
||||
export function PassportImage({ label, src, url }: PassportImageProps) {
|
||||
const { t } = useTranslation();
|
||||
const imageSrc = src ?? url ?? null;
|
||||
@@ -190,7 +235,7 @@ export function PassportImage({ label, src, url }: PassportImageProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// ─── AuditRow ─────────────────────────────────────────────────────────────────
|
||||
// ─── AuditRowProps ────────────────────────────────────────────────────────────
|
||||
|
||||
export interface AuditRowProps {
|
||||
id: string;
|
||||
@@ -201,105 +246,138 @@ export interface AuditRowProps {
|
||||
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>
|
||||
// ─── StatusBadge ──────────────────────────────────────────────────────────────
|
||||
|
||||
export function StatusBadge({ status }: { status: string }) {
|
||||
const normalized = status.toLowerCase();
|
||||
const variant =
|
||||
normalized === "success" || normalized === "completed"
|
||||
? "default"
|
||||
: normalized === "failed" || normalized === "error"
|
||||
? "destructive"
|
||||
: normalized === "pending"
|
||||
? "secondary"
|
||||
: "outline";
|
||||
|
||||
return <Badge variant={variant}>{status}</Badge>;
|
||||
}
|
||||
|
||||
// ─── useAuditColumns ──────────────────────────────────────────────────────────
|
||||
|
||||
export function useAuditColumns(
|
||||
onView?: (log: AuditRowProps) => void,
|
||||
): ColumnDef<AuditRowProps>[] {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "ID",
|
||||
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>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "by",
|
||||
header: t("audit.columns.by", "KIM TARAPYNDAN"),
|
||||
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>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("audit.columns.status", "AMALYŇ STATUSY"),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
accessorKey: "date",
|
||||
header: t("audit.columns.date", "SENE"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground whitespace-nowrap">
|
||||
{row.original.date}
|
||||
</span>
|
||||
),
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
enableHiding: false,
|
||||
size: 60,
|
||||
cell: ({ row }) =>
|
||||
onView ? (
|
||||
<div className="flex items-center justify-end">
|
||||
<button
|
||||
onClick={() => onView(row.original)}
|
||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.view", "Görmek")}
|
||||
>
|
||||
<Eye size={15} />
|
||||
</button>
|
||||
</div>
|
||||
) : null,
|
||||
},
|
||||
],
|
||||
[t, onView],
|
||||
);
|
||||
}
|
||||
|
||||
// ─── AuditLog (full collapsible table) ───────────────────────────────────────
|
||||
// ─── AuditLog ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface AuditLogProps {
|
||||
logs: AuditRowProps[];
|
||||
defaultOpen?: boolean;
|
||||
currentPage?: number;
|
||||
totalPages?: number;
|
||||
totalCount?: number;
|
||||
onPageChange?: (page: number) => void;
|
||||
isLoading?: boolean;
|
||||
onView?: (log: AuditRowProps) => void;
|
||||
}
|
||||
|
||||
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"),
|
||||
"",
|
||||
];
|
||||
export function AuditLog({
|
||||
logs,
|
||||
currentPage,
|
||||
totalPages,
|
||||
totalCount,
|
||||
onPageChange,
|
||||
isLoading,
|
||||
onView,
|
||||
}: AuditLogProps) {
|
||||
const columns = useAuditColumns(onView);
|
||||
|
||||
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 className="bg-card rounded-md">
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={logs}
|
||||
isLoading={isLoading}
|
||||
currentPage={currentPage}
|
||||
totalPages={totalPages}
|
||||
totalCount={totalCount}
|
||||
onPageChange={onPageChange}
|
||||
getRowId={(row) => row.id}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
ArrowUpRight,
|
||||
ArrowDownRight,
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
Users,
|
||||
DollarSign,
|
||||
Activity,
|
||||
} from 'lucide-react'
|
||||
} from "lucide-react";
|
||||
import {
|
||||
AreaChart,
|
||||
Area,
|
||||
@@ -19,80 +19,87 @@ import {
|
||||
PieChart,
|
||||
Pie,
|
||||
Cell,
|
||||
} from 'recharts'
|
||||
} 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 { cn } from '@/lib/utils'
|
||||
} from "@/components/ui/chart";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
// ─── Mock data ────────────────────────────────────────────────────────────────
|
||||
|
||||
const areaData = [
|
||||
{ month: 'Ýan', loans: 420, cards: 240 },
|
||||
{ month: 'Few', loans: 380, cards: 290 },
|
||||
{ month: 'Mar', loans: 510, cards: 310 },
|
||||
{ month: 'Apr', loans: 470, cards: 280 },
|
||||
{ month: 'Maý', loans: 630, cards: 390 },
|
||||
{ month: 'Iýun', loans: 580, cards: 420 },
|
||||
{ month: 'Iýul', loans: 720, cards: 460 },
|
||||
{ month: 'Awg', loans: 690, cards: 500 },
|
||||
{ month: 'Sen', loans: 810, cards: 530 },
|
||||
{ month: 'Okt', loans: 760, cards: 480 },
|
||||
{ month: 'Noý', loans: 890, cards: 560 },
|
||||
{ month: 'Dek', loans: 950, cards: 610 },
|
||||
]
|
||||
{ month: "Ýan", loans: 420, cards: 240 },
|
||||
{ month: "Few", loans: 380, cards: 290 },
|
||||
{ month: "Mar", loans: 510, cards: 310 },
|
||||
{ month: "Apr", loans: 470, cards: 280 },
|
||||
{ month: "Maý", loans: 630, cards: 390 },
|
||||
{ month: "Iýun", loans: 580, cards: 420 },
|
||||
{ month: "Iýul", loans: 720, cards: 460 },
|
||||
{ month: "Awg", loans: 690, cards: 500 },
|
||||
{ month: "Sen", loans: 810, cards: 530 },
|
||||
{ month: "Okt", loans: 760, cards: 480 },
|
||||
{ month: "Noý", loans: 890, cards: 560 },
|
||||
{ month: "Dek", loans: 950, cards: 610 },
|
||||
];
|
||||
|
||||
const barData = [
|
||||
{ day: 'Du', approved: 28, rejected: 4 },
|
||||
{ day: 'Si', approved: 35, rejected: 6 },
|
||||
{ day: 'Ça', approved: 22, rejected: 3 },
|
||||
{ day: 'Pe', approved: 41, rejected: 8 },
|
||||
{ day: 'An', approved: 33, rejected: 5 },
|
||||
{ day: 'Şe', approved: 18, rejected: 2 },
|
||||
{ day: 'Ýe', approved: 12, rejected: 1 },
|
||||
]
|
||||
{ day: "Du", approved: 28, rejected: 4 },
|
||||
{ day: "Si", approved: 35, rejected: 6 },
|
||||
{ day: "Ça", approved: 22, rejected: 3 },
|
||||
{ day: "Pe", approved: 41, rejected: 8 },
|
||||
{ day: "An", approved: 33, rejected: 5 },
|
||||
{ day: "Şe", approved: 18, rejected: 2 },
|
||||
{ day: "Ýe", approved: 12, rejected: 1 },
|
||||
];
|
||||
|
||||
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: "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" },
|
||||
];
|
||||
|
||||
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-2837', name: 'Merdan Hojamyradow', amount: '18 000 TMT', status: 'approved', time: '2 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 öň" },
|
||||
];
|
||||
|
||||
// ─── Chart configs ────────────────────────────────────────────────────────────
|
||||
|
||||
const areaConfig = {
|
||||
loans: { label: 'Karzlar', color: 'var(--chart-1)' },
|
||||
cards: { label: 'Kartlar', color: 'var(--chart-2)' },
|
||||
} satisfies Record<string, { label: string; color: string }>
|
||||
loans: { label: "Karzlar", color: "var(--chart-1)" },
|
||||
cards: { label: "Kartlar", color: "var(--chart-2)" },
|
||||
} satisfies Record<string, { label: string; color: string }>;
|
||||
|
||||
const barConfig = {
|
||||
approved: { label: 'Tassyklanan', color: 'var(--chart-1)' },
|
||||
rejected: { label: 'Ýatyryldy', color: 'var(--chart-5)' },
|
||||
} satisfies Record<string, { label: string; color: string }>
|
||||
approved: { label: "Tassyklanan", color: "var(--chart-1)" },
|
||||
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)' },
|
||||
} satisfies Record<string, { label: string; color: string }>
|
||||
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 ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -105,82 +112,232 @@ function StatCard({
|
||||
icon: React.ElementType
|
||||
accent: string
|
||||
}) {
|
||||
const positive = change >= 0
|
||||
const positive = change >= 0;
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between pb-2 space-y-0">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">{title}</CardTitle>
|
||||
<div className={cn('flex h-9 w-9 items-center justify-center rounded-lg', accent)}>
|
||||
<div className={cn("flex h-9 w-9 items-center justify-center rounded-lg", accent)}>
|
||||
<Icon size={16} />
|
||||
</div>
|
||||
</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',
|
||||
"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>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function StatCardSkeleton() {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between pb-2 space-y-0">
|
||||
<Skeleton className="h-4 w-28" />
|
||||
<Skeleton className="h-9 w-9 rounded-lg" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Skeleton className="h-8 w-24" />
|
||||
<Skeleton className="mt-2 h-3 w-36" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── 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',
|
||||
}
|
||||
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',
|
||||
}
|
||||
approved: "Tassyklandy",
|
||||
pending: "Garaşylýar",
|
||||
rejected: "Ýatyryldy",
|
||||
};
|
||||
return (
|
||||
<Badge variant="secondary" className={cn('text-[10px] px-1.5 py-0', styles[status])}>
|
||||
<Badge variant="secondary" className={cn("text-[10px] px-1.5 py-0", styles[status])}>
|
||||
{labels[status]}
|
||||
</Badge>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function DashboardPage() {
|
||||
const { t } = useTranslation()
|
||||
const total = pieData.reduce((s, d) => s + d.value, 0)
|
||||
export default function DashboardPage({ isLoading = false }: { isLoading?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const total = pieData.reduce((s, d) => s + d.value, 0);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="w-full space-y-6">
|
||||
<div className="space-y-1.5">
|
||||
<Skeleton className="h-7 w-40" />
|
||||
<Skeleton className="h-4 w-64" />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{[...Array(4)].map((_, i) => <StatCardSkeleton key={i} />)}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
{/* Area chart skeleton */}
|
||||
<Card className="lg:col-span-2">
|
||||
<CardHeader>
|
||||
<Skeleton className="h-5 w-48" />
|
||||
<Skeleton className="h-3 w-32 mt-1" />
|
||||
</CardHeader>
|
||||
<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" />)}
|
||||
</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" />)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
{[...Array(2)].map((_, i) => (
|
||||
<div key={i} className="flex items-center gap-1.5">
|
||||
<Skeleton className="h-3 w-3 rounded-full" />
|
||||
<Skeleton className="h-3 w-12" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Pie chart skeleton */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-5 w-32" />
|
||||
<Skeleton className="h-3 w-24 mt-1" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="h-[160px] w-full flex items-center justify-center">
|
||||
<div className="relative h-[144px] w-[144px]">
|
||||
<Skeleton className="h-full w-full rounded-full" />
|
||||
<div className="absolute inset-0 m-auto h-[96px] w-[96px] rounded-full bg-card" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 space-y-2">
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<div key={i} className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Skeleton className="h-1.5 w-1.5 rounded-full" />
|
||||
<Skeleton className="h-3 w-24" />
|
||||
</div>
|
||||
<Skeleton className="h-3 w-8" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
{/* Bar chart skeleton */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-5 w-36" />
|
||||
<Skeleton className="h-3 w-24 mt-1" />
|
||||
</CardHeader>
|
||||
<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" />)}
|
||||
</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) => (
|
||||
<div key={i} className="flex-1 flex items-end gap-0.5">
|
||||
<Skeleton className="flex-1 rounded-t-sm" style={{ height: `${h}%` }} />
|
||||
<Skeleton className="flex-1 rounded-t-sm" style={{ height: `${h * 0.15}%` }} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 mt-2 flex justify-between">
|
||||
{[...Array(7)].map((_, i) => <Skeleton key={i} className="h-2.5 w-4" />)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
{[12, 14].map((w, i) => (
|
||||
<div key={i} className="flex items-center gap-1.5">
|
||||
<Skeleton className="h-3 w-3 rounded-full" />
|
||||
<Skeleton className={`h-3 w-${w}`} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Recent activity skeleton */}
|
||||
<Card className="lg:col-span-2">
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-3">
|
||||
<div className="space-y-1.5">
|
||||
<Skeleton className="h-5 w-36" />
|
||||
<Skeleton className="h-3 w-44" />
|
||||
</div>
|
||||
<Skeleton className="h-4 w-12" />
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<div className="divide-y divide-border">
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<div key={i} className="flex items-center gap-3 px-6 py-3">
|
||||
<Skeleton className="h-8 w-8 rounded-full shrink-0" />
|
||||
<div className="flex-1 space-y-1.5">
|
||||
<Skeleton className="h-3.5 w-36" />
|
||||
<Skeleton className="h-3 w-28" />
|
||||
</div>
|
||||
<div className="text-right space-y-1.5 shrink-0">
|
||||
<Skeleton className="h-3.5 w-20 ml-auto" />
|
||||
<Skeleton className="h-4 w-16 ml-auto rounded-full" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full space-y-6">
|
||||
|
||||
{/* Header */}
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">
|
||||
{t('Dashboard', 'Baş sahypa')}
|
||||
{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')}
|
||||
{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 */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
|
||||
<Card className="lg:col-span-2">
|
||||
<CardHeader>
|
||||
<CardTitle>{t('Loan & card trend', 'Karz we kart tendensiýasy')}</CardTitle>
|
||||
<CardTitle>{t("Loan & card trend", "Karz we kart tendensiýasy")}</CardTitle>
|
||||
<CardDescription>2024 — ýyllyk görünüş</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
@@ -197,8 +354,8 @@ export default function DashboardPage() {
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<CartesianGrid strokeDasharray="3 3" vertical={false} stroke="var(--border)" />
|
||||
<XAxis dataKey="month" tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: 'var(--muted-foreground)' }} />
|
||||
<YAxis tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: 'var(--muted-foreground)' }} />
|
||||
<XAxis dataKey="month" tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: "var(--muted-foreground)" }} />
|
||||
<YAxis tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: "var(--muted-foreground)" }} />
|
||||
<ChartTooltip content={<ChartTooltipContent />} />
|
||||
<Area type="monotone" dataKey="loans" stroke="var(--color-loans)" strokeWidth={2} fill="url(#fillLoans)" dot={false} />
|
||||
<Area type="monotone" dataKey="cards" stroke="var(--color-cards)" strokeWidth={2} fill="url(#fillCards)" dot={false} />
|
||||
@@ -210,7 +367,7 @@ export default function DashboardPage() {
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t('Loan status', 'Karz ýagdaýy')}</CardTitle>
|
||||
<CardTitle>{t("Loan status", "Karz ýagdaýy")}</CardTitle>
|
||||
<CardDescription>{total.toLocaleString()} jemi sargyt</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
@@ -228,10 +385,7 @@ export default function DashboardPage() {
|
||||
{pieData.map((d) => (
|
||||
<div key={d.key} className="flex items-center justify-between text-xs">
|
||||
<span className="flex items-center gap-1.5 text-muted-foreground">
|
||||
<span
|
||||
className="h-1.5 w-1.5 rounded-full flex-shrink-0"
|
||||
style={{ background: `var(--color-${d.key})` }}
|
||||
/>
|
||||
<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">
|
||||
@@ -242,23 +396,21 @@ export default function DashboardPage() {
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Bar chart + Recent activity */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t('Weekly orders', 'Hepdelik sargytlar')}</CardTitle>
|
||||
<CardDescription>{t('Last 7 days', 'Soňky 7 gün')}</CardDescription>
|
||||
<CardTitle>{t("Weekly orders", "Hepdelik sargytlar")}</CardTitle>
|
||||
<CardDescription>{t("Last 7 days", "Soňky 7 gün")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ChartContainer config={barConfig} className="h-[180px] w-full">
|
||||
<BarChart data={barData} margin={{ top: 4, right: 4, left: -24, bottom: 0 }} barGap={3}>
|
||||
<CartesianGrid strokeDasharray="3 3" vertical={false} stroke="var(--border)" />
|
||||
<XAxis dataKey="day" tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: 'var(--muted-foreground)' }} />
|
||||
<YAxis tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: 'var(--muted-foreground)' }} />
|
||||
<XAxis dataKey="day" tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: "var(--muted-foreground)" }} />
|
||||
<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} />
|
||||
@@ -271,8 +423,10 @@ export default function DashboardPage() {
|
||||
<Card className="lg:col-span-2">
|
||||
<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>
|
||||
<CardTitle>{t("Recent activity", "Soňky hereketler")}</CardTitle>
|
||||
<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} />
|
||||
@@ -299,8 +453,7 @@ export default function DashboardPage() {
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -26,25 +26,36 @@ import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
}
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
}
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
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} />
|
||||
function LoanOrderMobileStatusBadge({
|
||||
status,
|
||||
}: {
|
||||
status: LoanOrderMobileStatus;
|
||||
}) {
|
||||
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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -55,7 +66,10 @@ 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" />
|
||||
@@ -64,54 +78,53 @@ function LoanOrderViewSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function LoanOrderViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const deleteMutation = useDeleteLoanOrder()
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanOrder();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useLoanOrderById(id!)
|
||||
const { data: order, isLoading } = useLoanOrderById(id!);
|
||||
|
||||
const handleDelete = () => {
|
||||
setShowDeleteDialog(true)
|
||||
}
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => navigate("/loan-orders"),
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanOrderViewSkeleton />
|
||||
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>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const auditLogs: AuditRowProps[] = [
|
||||
{
|
||||
id: "44548",
|
||||
id: "44548",
|
||||
action: t("audit.actions.view", "Görmek"),
|
||||
by: order.createdBy ?? "",
|
||||
by: order.createdBy ?? "",
|
||||
target: `${t("loanOrders.title", "Karz sargyt")}: ${order.id}`,
|
||||
status: "FINISHED",
|
||||
date: order.createdAt ?? "",
|
||||
date: order.createdAt ?? "",
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
@@ -145,9 +158,7 @@ export default function LoanOrderViewPage() {
|
||||
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||
value={order.createdAt}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.status", "Status")}
|
||||
>
|
||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
@@ -191,7 +202,9 @@ export default function LoanOrderViewPage() {
|
||||
{/* ── Row 2: Personal + Contacts ──────────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
{/* Personal */}
|
||||
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||
<BentoCard
|
||||
title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}
|
||||
>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.fullName", "Doly ady")}
|
||||
value={order.fullName ?? `${order.firstName} ${order.lastName}`}
|
||||
@@ -209,11 +222,17 @@ export default function LoanOrderViewPage() {
|
||||
value={order.birthDate ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")}
|
||||
label={t(
|
||||
"loanOrders.fields.registeredAddress",
|
||||
"Ýazgy edilen salgy",
|
||||
)}
|
||||
value={order.registeredAddress ?? undefined}
|
||||
/>
|
||||
<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}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -248,7 +267,10 @@ export default function LoanOrderViewPage() {
|
||||
value={order.employer ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.deptPhone", "Işgärler bölüminiň belgisi")}
|
||||
label={t(
|
||||
"loanOrders.fields.deptPhone",
|
||||
"Işgärler bölüminiň belgisi",
|
||||
)}
|
||||
value={order.deptPhone ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
@@ -281,11 +303,17 @@ export default function LoanOrderViewPage() {
|
||||
value={order.passportNumber ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")}
|
||||
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>
|
||||
@@ -301,19 +329,28 @@ export default function LoanOrderViewPage() {
|
||||
</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)")}
|
||||
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>
|
||||
@@ -331,5 +368,5 @@ export default function LoanOrderViewPage() {
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle, ChevronDown, Plus, Search, SlidersHorizontal, ChevronUp } from "lucide-react";
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle, Inbox } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
@@ -14,80 +14,27 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import {
|
||||
Section,
|
||||
InfoRow,
|
||||
CollapsibleSection,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import { useUser, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
||||
|
||||
// ─── Collapsible Section ──────────────────────────────────────────────────────
|
||||
// ─── EmptyState ───────────────────────────────────────────────────────────────
|
||||
|
||||
interface CollapsibleBlockProps {
|
||||
title: string;
|
||||
actionLabel: string;
|
||||
onAction: () => void;
|
||||
emptyMessage: string;
|
||||
searchPlaceholder?: string;
|
||||
showFilter?: boolean;
|
||||
interface EmptyStateProps {
|
||||
label: string;
|
||||
}
|
||||
|
||||
function CollapsibleBlock({ title, actionLabel, onAction, emptyMessage, searchPlaceholder, showFilter = false }: CollapsibleBlockProps) {
|
||||
const [open, setOpen] = useState(true);
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
function EmptyState({ label }: EmptyStateProps) {
|
||||
return (
|
||||
<div className="mb-6">
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="flex items-center gap-1.5 text-base font-semibold text-foreground mb-2 hover:opacity-80 transition-opacity select-none"
|
||||
>
|
||||
{title}
|
||||
{open ? <ChevronDown size={15} /> : <ChevronUp size={15} />}
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{/* Sub-toolbar */}
|
||||
<div className="flex items-center justify-between px-4 py-3 border-b border-border">
|
||||
<div className="relative">
|
||||
<Search size={13} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" />
|
||||
<input
|
||||
type="text"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder={searchPlaceholder}
|
||||
className="h-8 pl-8 pr-3 rounded-md border border-border bg-background text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring w-48"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{showFilter && (
|
||||
<Button variant="outline" size="icon" className="h-8 w-8">
|
||||
<SlidersHorizontal size={13} />
|
||||
</Button>
|
||||
)}
|
||||
<Button size="sm" className="h-8 gap-1.5" onClick={onAction}>
|
||||
<Plus size={13} />
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Empty state */}
|
||||
<div className="flex flex-col items-center justify-center py-16 gap-3">
|
||||
<div className="w-16 h-16 rounded-lg border border-border bg-muted/30 flex items-center justify-center">
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" className="text-muted-foreground/40">
|
||||
<rect x="4" y="8" width="24" height="18" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M4 13h24" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M9 8V6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
<path d="M23 8V6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
<circle cx="22" cy="22" r="5" fill="currentColor" fillOpacity="0.1" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M22 20v4M20 22h4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">{emptyMessage}</p>
|
||||
<Button variant="outline" size="sm" onClick={onAction}>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-col items-center justify-center py-16 gap-3">
|
||||
<div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center">
|
||||
<Inbox size={32} className="text-muted-foreground" />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">{label}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -104,6 +51,10 @@ export default function UserViewPage() {
|
||||
const deleteUser = useDeleteUser();
|
||||
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
const [roleSearch, setRoleSearch] = useState("");
|
||||
const [permSearch, setPermSearch] = useState("");
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [auditSearch, setAuditSearch] = useState("");
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
await deleteUser.mutateAsync(userId);
|
||||
@@ -116,7 +67,10 @@ export default function UserViewPage() {
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<div
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0"
|
||||
>
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
@@ -127,7 +81,11 @@ export default function UserViewPage() {
|
||||
}
|
||||
|
||||
if (isError || !user) {
|
||||
return <div className="p-6 text-center text-muted-foreground">{t("common.notFound", "Maglumat tapylmady")}</div>;
|
||||
return (
|
||||
<div className="p-6 text-center text-muted-foreground">
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -135,7 +93,8 @@ export default function UserViewPage() {
|
||||
{/* Title + actions */}
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<h1 className="text-xl font-bold text-foreground leading-tight">
|
||||
{t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name} ({user.username})
|
||||
{t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name} (
|
||||
{user.username})
|
||||
</h1>
|
||||
<div className="flex items-center gap-2 shrink-0 ml-4">
|
||||
<Button
|
||||
@@ -146,7 +105,12 @@ export default function UserViewPage() {
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => navigate(`/users/${userId}/edit`)}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={() => navigate(`/users/${userId}/edit`)}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -155,10 +119,19 @@ export default function UserViewPage() {
|
||||
{/* Main info */}
|
||||
<Section>
|
||||
<InfoRow label={t("common.id", "ID")} value={user.id} />
|
||||
<InfoRow label={t("users.fields.username", "Ulanyjy ady")} value={user.username} />
|
||||
<InfoRow
|
||||
label={t("users.fields.username", "Ulanyjy ady")}
|
||||
value={user.username}
|
||||
/>
|
||||
<InfoRow label={t("users.fields.name", "Ady")} value={user.name} />
|
||||
<InfoRow label={t("users.fields.phone", "Telefon")} value={user.phone} />
|
||||
<InfoRow label={t("users.fields.email", "E-poçta")} value={user.email} />
|
||||
<InfoRow
|
||||
label={t("users.fields.phone", "Telefon")}
|
||||
value={user.phone}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("users.fields.email", "E-poçta")}
|
||||
value={user.email}
|
||||
/>
|
||||
<InfoRow label={t("users.fields.isActive", "Işjeň")}>
|
||||
{user.isActive ? (
|
||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||
@@ -169,57 +142,113 @@ export default function UserViewPage() {
|
||||
</Section>
|
||||
|
||||
{/* Rollar */}
|
||||
<CollapsibleBlock
|
||||
title={t("users.sections.roles", "Rollar")}
|
||||
actionLabel={t("users.actions.addRole", "Rol birikdiriň")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t("users.empty.roles", "Berlen kriteriýalara Rol gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
<CollapsibleSection title={t("users.sections.roles", "Rollar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={roleSearch}
|
||||
onSearchChange={setRoleSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("users.actions.addRole", "Rol birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState
|
||||
label={t(
|
||||
"users.empty.roles",
|
||||
"Berlen kriteriýalara Rol gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* Rugsatlar */}
|
||||
<CollapsibleBlock
|
||||
title={t("users.sections.permissions", "Rugsatlar")}
|
||||
actionLabel={t("users.actions.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t("users.empty.permissions", "Berlen kriteriýalara Rugsat gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
<CollapsibleSection title={t("users.sections.permissions", "Rugsatlar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={permSearch}
|
||||
onSearchChange={setPermSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("users.actions.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState
|
||||
label={t(
|
||||
"users.empty.permissions",
|
||||
"Berlen kriteriýalara Rugsat gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* Şahamçalar */}
|
||||
<CollapsibleBlock
|
||||
title={t("users.sections.branches", "Şahamçalar")}
|
||||
actionLabel={t("users.actions.addBranch", "Şahamça birikdiriň")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t("users.empty.branches", "Berlen kriteriýalara Şahamça gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
showFilter
|
||||
/>
|
||||
<CollapsibleSection title={t("users.sections.branches", "Şahamçalar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={branchSearch}
|
||||
onSearchChange={setBranchSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("users.actions.addBranch", "Şahamça birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState
|
||||
label={t(
|
||||
"users.empty.branches",
|
||||
"Berlen kriteriýalara Şahamça gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* Ammallar */}
|
||||
<CollapsibleBlock
|
||||
title={t("users.sections.audit", "Ammallar")}
|
||||
actionLabel={t("users.actions.addAction", "Hereket")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t("users.empty.audit", "Berlen kriteriýalara Hereket gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
<CollapsibleSection title={t("users.sections.audit", "Ammallar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={auditSearch}
|
||||
onSearchChange={setAuditSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("users.actions.addAction", "Hereket")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState
|
||||
label={t(
|
||||
"users.empty.audit",
|
||||
"Berlen kriteriýalara Hereket gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("users.deleteDialog.title", "Ulanyjyny öçürmek")}</AlertDialogTitle>
|
||||
<AlertDialogTitle>
|
||||
{t("users.deleteDialog.title", "Ulanyjyny öçürmek")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("users.deleteDialog.description", 'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.').replace(
|
||||
"{name}",
|
||||
user.username,
|
||||
)}
|
||||
{t(
|
||||
"users.deleteDialog.description",
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace("{name}", user.username)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýok")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleDeleteConfirm} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{t("common.delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, ChevronDown, XCircle, CheckCircle2 } from 'lucide-react'
|
||||
import { Pencil, Trash2, XCircle, CheckCircle2, Inbox } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog, CollapsibleSection } from '@/components/viewPageComponents'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import { useClient, useDeleteClient } from '@/features/clients/hooks/useClients'
|
||||
@@ -21,73 +21,21 @@ function ActiveIndicator({ active }: { active: boolean }) {
|
||||
);
|
||||
}
|
||||
|
||||
// ─── CollapsibleSection ───────────────────────────────────────────────────────
|
||||
|
||||
interface CollapsibleSectionProps {
|
||||
title: string
|
||||
actionLabel: string
|
||||
onAction: () => void
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
function CollapsibleSection({ title, actionLabel, onAction, children }: CollapsibleSectionProps) {
|
||||
const [open, setOpen] = useState(true)
|
||||
return (
|
||||
<div>
|
||||
<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'}`}
|
||||
/>
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-primary hover:bg-primary/90 text-primary-foreground h-8 text-xs"
|
||||
onClick={onAction}
|
||||
>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── EmptyState ───────────────────────────────────────────────────────────────
|
||||
|
||||
interface EmptyStateProps {
|
||||
label: string
|
||||
actionLabel: string
|
||||
onAction: () => void
|
||||
label: string;
|
||||
}
|
||||
|
||||
function EmptyState({ label, actionLabel, onAction }: EmptyStateProps) {
|
||||
function EmptyState({ label }: EmptyStateProps) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-12 gap-4">
|
||||
<div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center">
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" className="text-muted-foreground">
|
||||
<rect x="4" y="8" width="24" height="18" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M4 13h24" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M10 8V6M22 8V6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
<circle cx="16" cy="20" r="3" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M19 23l2 2" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
<Inbox size={32} className="text-muted-foreground" />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground text-center">{label}</p>
|
||||
<Button size="sm" variant="outline" className="h-8 text-xs" onClick={onAction}>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -284,116 +232,86 @@ export default function ClientDetailPage() {
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Rollar ───────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.roles', 'Rollar')}
|
||||
actionLabel={t('clients.addRole', 'Rol birikdiriň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<CollapsibleSection title={t('clients.sections.roles', 'Rollar')}>
|
||||
<DataTableToolbar
|
||||
searchValue={roleSearch}
|
||||
onSearchChange={setRoleSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
columnOrder={[]} onColumnOrderChange={() => {}}
|
||||
actionLabel={t('clients.addRole', 'Rol birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
{filteredRoles.length > 0 ? (
|
||||
<DataTable columns={roleColumns} data={filteredRoles} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||
) : (
|
||||
<EmptyState
|
||||
label={t('clients.noRoles', 'Berlen kriterýalara Rol gabat gelmedi.')}
|
||||
actionLabel={t('clients.addRole', 'Rol birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t('clients.noRoles', 'Berlen kriterýalara Rol gabat gelmedi.')} />
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Rugsatlar ────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.permissions', 'Rugsatlar')}
|
||||
actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<CollapsibleSection title={t('clients.sections.permissions', 'Rugsatlar')}>
|
||||
<DataTableToolbar
|
||||
searchValue={permSearch}
|
||||
onSearchChange={setPermSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
columnOrder={[]} onColumnOrderChange={() => {}}
|
||||
actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
{(client.permissions ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t('clients.noPermissions', 'Berlen kriterýalara Rugsat gabat gelmedi.')}
|
||||
actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t('clients.noPermissions', 'Berlen kriterýalara Rugsat gabat gelmedi.')} />
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Şahamçalar ───────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.branches', 'Şahamçalar')}
|
||||
actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<CollapsibleSection title={t('clients.sections.branches', 'Şahamçalar')}>
|
||||
<DataTableToolbar
|
||||
searchValue={branchSearch}
|
||||
onSearchChange={setBranchSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
columnOrder={[]} onColumnOrderChange={() => {}}
|
||||
actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
{filteredBranches.length > 0 ? (
|
||||
<DataTable columns={branchColumns} data={filteredBranches} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||
) : (
|
||||
<EmptyState
|
||||
label={t('clients.noBranches', 'Berlen kriterýalara Şahamça gabat gelmedi.')}
|
||||
actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t('clients.noBranches', 'Berlen kriterýalara Şahamça gabat gelmedi.')} />
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Karz sargyt ──────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.loanOrders', 'Karz sargyt')}
|
||||
actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<CollapsibleSection title={t('clients.sections.loanOrders', 'Karz sargyt')}>
|
||||
<DataTableToolbar
|
||||
searchValue={loanSearch}
|
||||
onSearchChange={setLoanSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
columnOrder={[]} onColumnOrderChange={() => {}}
|
||||
actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
{(client.loanOrders ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t('clients.noLoanOrders', 'Berlen kriterýalara Karz sargyt gabat gelmedi.')}
|
||||
actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t('clients.noLoanOrders', 'Berlen kriterýalara Karz sargyt gabat gelmedi.')} />
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Kart sargyt ──────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.cardOrders', 'Kart sargyt')}
|
||||
actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<CollapsibleSection title={t('clients.sections.cardOrders', 'Kart sargyt')}>
|
||||
<DataTableToolbar
|
||||
searchValue={cardSearch}
|
||||
onSearchChange={setCardSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
columnOrder={[]} onColumnOrderChange={() => {}}
|
||||
actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
{(client.cardOrders ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t('clients.noCardOrders', 'Berlen kriterýalara Kart sargyt gabat gelmedi.')}
|
||||
actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t('clients.noCardOrders', 'Berlen kriterýalara Kart sargyt gabat gelmedi.')} />
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
|
||||
@@ -219,14 +219,19 @@ export default function OperatorsPage() {
|
||||
{/* Delete dialog */}
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
onOpenChange={(o) => {
|
||||
if (!o) setDeleteTarget(null);
|
||||
}}
|
||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
description={t("operators.deleteDescription", 'Siz "{name}" operatoryny pozjakmy?').replace("{name}", deleteTarget?.name ?? "")}
|
||||
description={t(
|
||||
"operators.deleteDescription",
|
||||
'Siz "{name}" operatoryny pozjakmy?',
|
||||
).replace("{name}", deleteTarget?.name ?? "")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id)
|
||||
setDeleteTarget(null)
|
||||
deleteMutation.mutate(deleteTarget.id);
|
||||
setDeleteTarget(null);
|
||||
}
|
||||
}}
|
||||
isLoading={deleteMutation.isPending}
|
||||
|
||||
@@ -1,17 +1,38 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, ChevronDown, CheckCircle2, XCircle, } from "lucide-react";
|
||||
import {
|
||||
Pencil,
|
||||
Trash2,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
Inbox,
|
||||
Eye,
|
||||
} from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog } from "@/components/viewPageComponents";
|
||||
import {
|
||||
BentoGrid,
|
||||
BentoCard,
|
||||
InfoRow,
|
||||
AuditLog,
|
||||
CollapsibleSection,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import { useOperator, useDeleteOperator } from "@/features/operators/hooks/useOperators";
|
||||
import type { OperatorRole, OperatorBranch, OperatorAuditLog } from "@/features/operators/api/operatorsApi";
|
||||
import {
|
||||
useOperator,
|
||||
useDeleteOperator,
|
||||
} from "@/features/operators/hooks/useOperators";
|
||||
import type {
|
||||
OperatorRole,
|
||||
OperatorBranch,
|
||||
OperatorAuditLog,
|
||||
OperatorPermission,
|
||||
} from "@/features/operators/api/operatorsApi";
|
||||
|
||||
// ─── IsActive indicator ───────────────────────────────────────────────────────
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
|
||||
function ActiveIndicator({ active }: { active: boolean }) {
|
||||
return active ? (
|
||||
@@ -21,62 +42,19 @@ function ActiveIndicator({ active }: { active: boolean }) {
|
||||
);
|
||||
}
|
||||
|
||||
// ─── CollapsibleSection ───────────────────────────────────────────────────────
|
||||
|
||||
interface CollapsibleSectionProps {
|
||||
title: string;
|
||||
actionLabel: string;
|
||||
onAction: () => void;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
function CollapsibleSection({ title, actionLabel, onAction, children }: CollapsibleSectionProps) {
|
||||
const [open, setOpen] = useState(true);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<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"}`} />
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
<div className="flex justify-end">
|
||||
<Button size="sm" className="bg-primary hover:bg-primary/90 text-primary-foreground h-8 text-xs" onClick={onAction}>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── EmptyState ───────────────────────────────────────────────────────────────
|
||||
|
||||
interface EmptyStateProps {
|
||||
label: string;
|
||||
actionLabel: string;
|
||||
onAction: () => void;
|
||||
}
|
||||
|
||||
function EmptyState({ label, actionLabel, onAction }: EmptyStateProps) {
|
||||
function EmptyState({ label }: EmptyStateProps) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-12 gap-4">
|
||||
<div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center">
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" className="text-muted-foreground">
|
||||
<rect x="4" y="8" width="24" height="18" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M4 13h24" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M10 8V6M22 8V6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
<circle cx="16" cy="20" r="3" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M19 23l2 2" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
<Inbox size={32} className="text-muted-foreground" />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground text-center">{label}</p>
|
||||
<Button size="sm" variant="outline" className="h-8 text-xs" onClick={onAction}>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -103,7 +81,11 @@ export default function OperatorDetailPage() {
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("common.id", "ID"),
|
||||
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-semibold text-sm">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
@@ -119,11 +101,14 @@ export default function OperatorDetailPage() {
|
||||
{
|
||||
accessorKey: "guardName",
|
||||
header: t("roles.fields.guardName", "GUARD NAME"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.guardName}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm">{row.original.guardName}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
size: 120,
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-1 justify-end">
|
||||
<Button
|
||||
@@ -132,20 +117,67 @@ export default function OperatorDetailPage() {
|
||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => navigate(`/roles/${row.original.id}`)}
|
||||
>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
<Eye size={14} />
|
||||
</Button>
|
||||
<Button size="icon" variant="ghost" className="h-7 w-7 text-muted-foreground hover:text-foreground">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Pencil size={13} />
|
||||
</Button>
|
||||
<Button size="icon" variant="ghost" className="h-7 w-7 text-muted-foreground hover:text-destructive">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
||||
>
|
||||
<Trash2 size={13} />
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
// ── Permission columns ────────────────────────────────────────────────────
|
||||
|
||||
const permissionColumns: ColumnDef<OperatorPermission>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("common.id", "ID"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-semibold text-sm">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
accessorKey: "name",
|
||||
header: t("permissions.fields.name", "ADY"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.name}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "guardName",
|
||||
header: t("permissions.fields.guardName", "GUARD NAME"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm">{row.original.guardName}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
size: 60,
|
||||
cell: () => (
|
||||
<div className="flex items-center justify-end">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
||||
>
|
||||
<Trash2 size={13} />
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
size: 120,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -155,7 +187,11 @@ export default function OperatorDetailPage() {
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("common.id", "ID"),
|
||||
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-semibold text-sm">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
size: 60,
|
||||
},
|
||||
{
|
||||
@@ -171,12 +207,16 @@ export default function OperatorDetailPage() {
|
||||
{
|
||||
accessorKey: "district",
|
||||
header: t("branches.fields.district", "ETRAP"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.district}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm">{row.original.district}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "uniqueCode",
|
||||
header: t("branches.fields.uniqueCode", "UNIKAL BELGI"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.uniqueCode}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm">{row.original.uniqueCode}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "isActive",
|
||||
@@ -187,29 +227,45 @@ export default function OperatorDetailPage() {
|
||||
{
|
||||
accessorKey: "billingUsernameIbr",
|
||||
header: t("branches.fields.billingIbr", "BILLING ULANYJY ADY"),
|
||||
cell: ({ row }) => <span className="text-sm font-mono text-xs">{row.original.billingUsernameIbr}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-mono text-xs">
|
||||
{row.original.billingUsernameIbr}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "billingUsernameSber",
|
||||
header: t("branches.fields.billingSber", "BILLING USERNAME (SBER)"),
|
||||
cell: ({ row }) => <span className="text-sm font-mono text-xs">{row.original.billingUsernameSber}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-mono text-xs">
|
||||
{row.original.billingUsernameSber}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "billingUsernameVisa",
|
||||
header: t("branches.fields.billingVisa", "BILLING USERNAME (VISA)"),
|
||||
cell: ({ row }) => <span className="text-sm font-mono text-xs">{row.original.billingUsernameVisa}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-mono text-xs">
|
||||
{row.original.billingUsernameVisa}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
size: 60,
|
||||
cell: () => (
|
||||
<div className="flex items-center gap-1 justify-end">
|
||||
<Button size="icon" variant="ghost" className="h-7 w-7 text-muted-foreground hover:text-destructive">
|
||||
<div className="flex items-center justify-end">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
||||
>
|
||||
<Trash2 size={13} />
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
size: 60,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -221,7 +277,10 @@ export default function OperatorDetailPage() {
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<div
|
||||
key={i}
|
||||
className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3"
|
||||
>
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
@@ -245,12 +304,21 @@ export default function OperatorDetailPage() {
|
||||
}));
|
||||
|
||||
const filteredRoles = (operator.roles ?? []).filter(
|
||||
(r) => r.name.toLowerCase().includes(roleSearch.toLowerCase()) || r.code.toLowerCase().includes(roleSearch.toLowerCase()),
|
||||
(r) =>
|
||||
r.name.toLowerCase().includes(roleSearch.toLowerCase()) ||
|
||||
r.code.toLowerCase().includes(roleSearch.toLowerCase()),
|
||||
);
|
||||
|
||||
const filteredPermissions = (operator.permissions ?? []).filter((p) =>
|
||||
p.name.toLowerCase().includes(permSearch.toLowerCase()),
|
||||
);
|
||||
|
||||
const filteredBranches = (operator.branches ?? []).filter((b) =>
|
||||
b.name.toLowerCase().includes(branchSearch.toLowerCase()),
|
||||
);
|
||||
const filteredBranches = (operator.branches ?? []).filter((b) => b.name.toLowerCase().includes(branchSearch.toLowerCase()));
|
||||
|
||||
return (
|
||||
<div className=" flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-6">
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
@@ -276,29 +344,37 @@ export default function OperatorDetailPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Row 1: Esasy maglumatlar + Kontakt ──────────────────────────── */}
|
||||
{/* ── Esasy maglumatlar + Kontakt ──────────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("operators.sections.basic", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={operator.id} />
|
||||
<InfoRow label={t("operators.fields.username", "Ulanyjy ady")} value={operator.username} />
|
||||
<InfoRow label={t("operators.fields.name", "Ady")} value={operator.name} />
|
||||
<InfoRow
|
||||
label={t("operators.fields.username", "Ulanyjy ady")}
|
||||
value={operator.username}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("operators.fields.name", "Ady")}
|
||||
value={operator.name}
|
||||
/>
|
||||
<InfoRow label={t("operators.fields.isActive", "Işjeň")}>
|
||||
<ActiveIndicator active={operator.isActive} />
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("operators.sections.contact", "Kontakt")}>
|
||||
<InfoRow label={t("operators.fields.phone", "Telefon")} value={operator.phone ?? "—"} />
|
||||
<InfoRow label={t("operators.fields.email", "E-poçta")} value={operator.email ?? "—"} />
|
||||
<InfoRow
|
||||
label={t("operators.fields.phone", "Telefon")}
|
||||
value={operator.phone ?? "—"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("operators.fields.email", "E-poçta")}
|
||||
value={operator.email ?? "—"}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Rollar ───────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t("operators.sections.roles", "Rollar")}
|
||||
actionLabel={t("operators.addRole", "Rol birikdiriň")}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<CollapsibleSection title={t("operators.sections.roles", "Rollar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={roleSearch}
|
||||
onSearchChange={setRoleSearch}
|
||||
@@ -308,16 +384,22 @@ export default function OperatorDetailPage() {
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
hideAction
|
||||
actionLabel={t("operators.addRole", "Rol birikdiriň")}
|
||||
onAction={() => {
|
||||
/* modal aç ya da navigate */
|
||||
}}
|
||||
/>
|
||||
<DataTable
|
||||
columns={roleColumns}
|
||||
data={filteredRoles}
|
||||
getRowId={(r) => String(r.id)}
|
||||
enableRowSelection
|
||||
/>
|
||||
<DataTable columns={roleColumns} data={filteredRoles} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Rugsatlar ────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t("operators.sections.permissions", "Rugsatlar")}
|
||||
actionLabel={t("operators.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={permSearch}
|
||||
@@ -328,13 +410,22 @@ export default function OperatorDetailPage() {
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
hideAction
|
||||
actionLabel={t("operators.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
{(operator.permissions ?? []).length === 0 && (
|
||||
{filteredPermissions.length === 0 ? (
|
||||
<EmptyState
|
||||
label={t("operators.noPermissions", "Berlen kriterýalara Rugsat gabat gelmedi.")}
|
||||
actionLabel={t("operators.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
label={t(
|
||||
"operators.noPermissions",
|
||||
"Berlen kriterýalara Rugsat gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<DataTable
|
||||
columns={permissionColumns}
|
||||
data={filteredPermissions}
|
||||
getRowId={(p) => String(p.id)}
|
||||
enableRowSelection
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
@@ -342,8 +433,6 @@ export default function OperatorDetailPage() {
|
||||
{/* ── Şahamçalar ───────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t("operators.sections.branches", "Şahamçalar")}
|
||||
actionLabel={t("operators.addBranch", "Şahamça birikdiriň")}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={branchSearch}
|
||||
@@ -354,22 +443,39 @@ export default function OperatorDetailPage() {
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
hideAction
|
||||
actionLabel={t("operators.addBranch", "Şahamça birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<DataTable
|
||||
columns={branchColumns}
|
||||
data={filteredBranches}
|
||||
getRowId={(r) => String(r.id)}
|
||||
enableRowSelection
|
||||
/>
|
||||
<DataTable columns={branchColumns} data={filteredBranches} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Karz sargyt ──────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t("operators.sections.loanLimits", "Karz sargyt")}
|
||||
actionLabel={t("operators.addLoanLimit", "Karz sargyt döredin")}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue=""
|
||||
onSearchChange={() => {}}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("operators.addLoanLimit", "Karz sargyt döredin")}
|
||||
onAction={() => {}}
|
||||
hideSearch
|
||||
/>
|
||||
{(operator.loanLimits ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t("operators.noLoanLimits", "Berlen kriterýalara Karz sargyt gabat gelmedi.")}
|
||||
actionLabel={t("operators.addLoanLimit", "Karz sargyt döredin")}
|
||||
onAction={() => {}}
|
||||
label={t(
|
||||
"operators.noLoanLimits",
|
||||
"Berlen kriterýalara Karz sargyt gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
@@ -377,14 +483,25 @@ export default function OperatorDetailPage() {
|
||||
{/* ── Kart sargyt ──────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t("operators.sections.cardLimits", "Kart sargyt")}
|
||||
actionLabel={t("operators.addCardLimit", "Kart sargyt döredin")}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue=""
|
||||
onSearchChange={() => {}}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("operators.addCardLimit", "Kart sargyt döredin")}
|
||||
onAction={() => {}}
|
||||
hideSearch
|
||||
/>
|
||||
{(operator.cardLimits ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t("operators.noCardLimits", "Berlen kriterýalara Kart sargyt gabat gelmedi.")}
|
||||
actionLabel={t("operators.addCardLimit", "Kart sargyt döredin")}
|
||||
onAction={() => {}}
|
||||
label={t(
|
||||
"operators.noCardLimits",
|
||||
"Berlen kriterýalara Kart sargyt gabat gelmedi.",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
@@ -396,9 +513,17 @@ export default function OperatorDetailPage() {
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
description={t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", { name: operator.name })}
|
||||
description={t(
|
||||
"operators.deleteConfirm",
|
||||
"{{name}} operatoryny pozmak isleýärsiňizmi?",
|
||||
{ name: operator.name },
|
||||
)}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() => deleteMutation.mutate(operatorId, { onSuccess: () => navigate("/operators") })}
|
||||
onConfirm={() =>
|
||||
deleteMutation.mutate(operatorId, {
|
||||
onSuccess: () => navigate("/operators"),
|
||||
})
|
||||
}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user