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