added lang support to view pages
This commit is contained in:
1 parent
a0ed9a702c
commit
a26e788415
25 files changed
+1213
-610
No files matched your search
@@ -28,16 +28,24 @@ import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
pending: { label: "Garaşylýar", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
approved: { label: "Tassyklandy", variant: "success" as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
rejected: { label: "Ýatyryldy", variant: "error" as StatusBadgeVariant, icon: XCircle },
|
||||
} satisfies Record<CardPinStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
const STATUS_VARIANT: Record<CardPinStatus, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
}
|
||||
|
||||
const STATUS_ICON: Record<CardPinStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
}
|
||||
|
||||
function CardPinStatusBadge({ status }: { status: CardPinStatus }) {
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
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(`cardPin.status.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
@@ -164,7 +172,7 @@ export default function CardPinViewPage() {
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardPin.metaSection", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID">
|
||||
<InfoRow label={t("common.id", "ID")}>
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")}>
|
||||
|
||||
@@ -25,33 +25,26 @@ import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequ
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
pending: {
|
||||
label: "Garaşylýar",
|
||||
variant: "warning" as StatusBadgeVariant,
|
||||
icon: AlertCircle,
|
||||
},
|
||||
approved: {
|
||||
label: "Tassyklanan",
|
||||
variant: "success" as StatusBadgeVariant,
|
||||
icon: CheckCircle2,
|
||||
},
|
||||
rejected: {
|
||||
label: "Ret edilen",
|
||||
variant: "error" as StatusBadgeVariant,
|
||||
icon: XCircle,
|
||||
},
|
||||
} satisfies Record<
|
||||
CardRequisiteStatus,
|
||||
{ label: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||
>;
|
||||
const STATUS_VARIANT: Record<CardRequisiteStatus, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<CardRequisiteStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
};
|
||||
|
||||
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg)
|
||||
return <span className="text-xs text-muted-foreground">{String(status)}</span>;
|
||||
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={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
<StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,6 +61,7 @@ function SectionTitle({ children }: { children: React.ReactNode }) {
|
||||
// ─── Passport image row ───────────────────────────────────────────────────────
|
||||
|
||||
function PassportImageRow({ label, url }: { label: string; url?: string }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="grid grid-cols-[220px_1fr] border-b border-border/50 last:border-0">
|
||||
<div className="px-4 py-3 text-sm text-muted-foreground font-medium bg-muted/10">
|
||||
@@ -87,7 +81,7 @@ function PassportImageRow({ label, url }: { label: string; url?: string }) {
|
||||
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
|
||||
>
|
||||
<DownloadCloud size={13} />
|
||||
{"Göçürip al"}
|
||||
{t("Download", "Göçürip al")}
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -23,18 +23,19 @@ import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CFG: Record<CardOrderStatus, { label: string; className: string; icon: string }> = {
|
||||
PENDING: { label: "Garaşylýar", icon: "⏳", className: "bg-amber-500/10 text-amber-400 border border-amber-500/20" },
|
||||
APPROVED: { label: "Tassyklandy", icon: "✓", className: "bg-emerald-500/10 text-emerald-400 border border-emerald-500/20" },
|
||||
REJECTED: { label: "Ýatyryldy", icon: "✕", className: "bg-red-500/10 text-red-400 border border-red-500/20" },
|
||||
const STATUS_STYLE: Record<CardOrderStatus, { className: string; icon: string }> = {
|
||||
PENDING: { icon: "⏳", className: "bg-amber-500/10 text-amber-400 border border-amber-500/20" },
|
||||
APPROVED: { icon: "✓", className: "bg-emerald-500/10 text-emerald-400 border border-emerald-500/20" },
|
||||
REJECTED: { icon: "✕", className: "bg-red-500/10 text-red-400 border border-red-500/20" },
|
||||
}
|
||||
|
||||
function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const cfg = STATUS_CFG[status]
|
||||
const { t } = useTranslation()
|
||||
const cfg = STATUS_STYLE[status]
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide ${cfg.className}`}>
|
||||
<span className="text-[10px]">{cfg.icon}</span>
|
||||
{cfg.label}
|
||||
{t(`cardOrder.status.${status.toLowerCase()}`)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -163,7 +164,7 @@ export default function CardOrderDetailPage() {
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardOrder.section.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID">{order.id}</InfoRow>
|
||||
<InfoRow label={t("common.id", "ID")}>{order.id}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")}>
|
||||
{order.createdAt}
|
||||
</InfoRow>
|
||||
|
||||
@@ -150,7 +150,7 @@ export default function CurrencyRatesPage() {
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-5">
|
||||
{t("currencyRates.title", "Walýuta kursy")}
|
||||
</h1>
|
||||
|
||||
@@ -83,7 +83,7 @@ export default function CurrencyRateDetailPage() {
|
||||
|
||||
{/* Detail Card */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={rate.id} />
|
||||
<InfoRow label={t('common.id', 'ID')} value={rate.id} />
|
||||
<InfoRow label={t('currencyRates.fields.currencyFrom', 'Currency from')} value={rate.currencyFrom} />
|
||||
<InfoRow label={t('currencyRates.fields.currencyTo', 'Currency to')} value={rate.currencyTo} />
|
||||
<InfoRow label={t('currencyRates.fields.value', 'Value')} value={rate.value} />
|
||||
|
||||
@@ -117,7 +117,7 @@ export default function VisaMasterSettingsPage() {
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("visaMasterSettings.title", "Visa/Master, Sber sazlamalar")}</h1>
|
||||
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { format } from 'date-fns'
|
||||
import { Trash2, Edit, Search, Download, XCircle, CheckCircle2, AlertCircle } from 'lucide-react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { InfoRow, AuditLog, type AuditRowProps } from '@/components/viewPageComponents'
|
||||
@@ -11,27 +12,53 @@ import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARASYLYYAR: { label: 'Garaşylýar', variant: 'warning' as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: 'Tassyklandy', variant: 'success' as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RET_EDILEN: { label: 'Ýatyryldy', variant: 'error' as StatusBadgeVariant, icon: XCircle },
|
||||
} satisfies Record<PaymentStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
const STATUS_VARIANT: Record<PaymentStatus, StatusBadgeVariant> = {
|
||||
GARASYLYYAR: 'warning',
|
||||
KANAGATLANDYRYLAN: 'success',
|
||||
RET_EDILEN: 'error',
|
||||
}
|
||||
|
||||
const PAID_STATUS_CONFIG = {
|
||||
Tolenmedik: { label: 'Tölmedi', variant: 'error' as StatusBadgeVariant, icon: XCircle },
|
||||
Tolendi: { label: 'Tölendi', variant: 'success' as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
} satisfies Record<PaymentPaidStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
const STATUS_ICON: Record<PaymentStatus, React.ElementType> = {
|
||||
GARASYLYYAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RET_EDILEN: XCircle,
|
||||
}
|
||||
|
||||
const STATUS_KEY_MAP: Record<PaymentStatus, string> = {
|
||||
GARASYLYYAR: 'pending',
|
||||
KANAGATLANDYRYLAN: 'approved',
|
||||
RET_EDILEN: 'rejected',
|
||||
}
|
||||
|
||||
const PAID_STATUS_VARIANT: Record<PaymentPaidStatus, StatusBadgeVariant> = {
|
||||
Tolenmedik: 'error',
|
||||
Tolendi: 'success',
|
||||
}
|
||||
|
||||
const PAID_STATUS_ICON: Record<PaymentPaidStatus, React.ElementType> = {
|
||||
Tolenmedik: XCircle,
|
||||
Tolendi: CheckCircle2,
|
||||
}
|
||||
|
||||
const PAID_STATUS_KEY_MAP: Record<PaymentPaidStatus, string> = {
|
||||
Tolenmedik: 'unpaid',
|
||||
Tolendi: 'paid',
|
||||
}
|
||||
|
||||
function PaymentStatusBadge({ status }: { status: PaymentStatus }) {
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
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(`sberPayments.status.${STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
function PaymentPaidStatusBadge({ status }: { status: PaymentPaidStatus }) {
|
||||
const cfg = PAID_STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
const { t } = useTranslation()
|
||||
const variant = PAID_STATUS_VARIANT[status]
|
||||
const Icon = PAID_STATUS_ICON[status]
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={t(`sberPayments.paidStatus.${PAID_STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
@@ -135,6 +162,7 @@ function SberPaymentViewSkeleton() {
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function SberPaymentViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const [historySearch, setHistorySearch] = useState('')
|
||||
@@ -153,7 +181,7 @@ export default function SberPaymentViewPage() {
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
Toleg tapylmady
|
||||
{t('sberPayments.notFound', 'Töleg tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -176,21 +204,21 @@ export default function SberPaymentViewPage() {
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
Sberbank töleg: {order.id}
|
||||
{t('sberPayments.viewTitle', 'Sberbank töleg')}: {order.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title="Poz"
|
||||
title={t('common.delete', 'Poz')}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/sber-payments/${id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title="Redaktirle"
|
||||
title={t('common.edit', 'Redaktirle')}
|
||||
>
|
||||
<Edit size={16} />
|
||||
</button>
|
||||
@@ -199,55 +227,55 @@ export default function SberPaymentViewPage() {
|
||||
|
||||
{/* ── Row 1: Meta + Lokasiýa ────────────────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title="Esasy maglumatlar">
|
||||
<InfoRow label="ID" value={order.id} />
|
||||
<InfoRow label="Status">
|
||||
<BentoCard title={t('sberPayments.view.sections.main', 'Esasy maglumatlar')}>
|
||||
<InfoRow label={t('common.id', 'ID')} value={order.id} />
|
||||
<InfoRow label={t('Status', 'Status')}>
|
||||
<PaymentStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label="Tölenen (Sul aý)">
|
||||
<InfoRow label={t('sberPayments.columns.paidStatus', 'Tölenen (şul aý)')}>
|
||||
<PaymentPaidStatusBadge status={order.paidStatus} />
|
||||
</InfoRow>
|
||||
<InfoRow label="Bellik" value={order.bellik} />
|
||||
<InfoRow label={t('sberPayments.cards.bellik', 'Bellik')} value={order.bellik} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title="Lokasiýa">
|
||||
<InfoRow label="Welaýat" value={order.welayat} />
|
||||
<InfoRow label="Şahamça" value={order.sahamca} isLink />
|
||||
<BentoCard title={t('sberPayments.view.sections.location', 'Lokasiýa')}>
|
||||
<InfoRow label={t('sberPayments.fields.welayat', 'Welaýat')} value={order.welayat} />
|
||||
<InfoRow label={t('sberPayments.fields.sahamca', 'Şahamça')} value={order.sahamca} isLink />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy maglumatlar + Töleg ─────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title="Şahsy maglumatlar">
|
||||
<InfoRow label="Pasportdaky ady" value={order.firstName} />
|
||||
<InfoRow label="Pasportdaky familiýa" value={order.lastName} />
|
||||
<InfoRow label="Telefon" value={order.phone} />
|
||||
<InfoRow label="E-poçta" value={order.email} />
|
||||
<InfoRow label="Häzirki ýaşaýyş ýeri" value={order.address} />
|
||||
<BentoCard title={t('sberPayments.view.sections.personal', 'Şahsy maglumatlar')}>
|
||||
<InfoRow label={t('sberPayments.fields.firstName', 'Pasportdaky ady')} value={order.firstName} />
|
||||
<InfoRow label={t('sberPayments.fields.lastName', 'Pasportdaky familiýa')} value={order.lastName} />
|
||||
<InfoRow label={t('sberPayments.fields.phone', 'Telefon')} value={order.phone} />
|
||||
<InfoRow label={t('sberPayments.fields.email', 'E-poçta')} value={order.email} />
|
||||
<InfoRow label={t('sberPayments.fields.address', 'Salgy')} value={order.address} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title="Töleg">
|
||||
<BentoCard title={t('sberPayments.view.sections.payment', 'Töleg')}>
|
||||
<InfoRow
|
||||
label="Töleg ugradyjynyň maglumatlary"
|
||||
label={t('sberPayments.payerInfo', 'Töleg ugradyjynyň maglumatlary')}
|
||||
value={`I-M${order.passportNumber?.slice(0, 2) ?? 'XX'}-${order.passportNumber ?? ''} ${order.fullName}`}
|
||||
/>
|
||||
<InfoRow label="Töleg ugradyjynyň goýum hasaby" value={order.accountNumber} />
|
||||
<InfoRow label="Pasport seriýasy" value={order.passportSeries} />
|
||||
<InfoRow label="Pasport nomeri" value={order.passportNumber} />
|
||||
<InfoRow label="Ady Familiýasy Atasynyň ady" value={order.fullName} />
|
||||
<InfoRow label={t('sberPayments.fields.accountNumber', 'Goýum hasaby')} value={order.accountNumber} />
|
||||
<InfoRow label={t('sberPayments.fields.passportSeries', 'Pasport seriýasy')} value={order.passportSeries} />
|
||||
<InfoRow label={t('sberPayments.fields.passportNumber', 'Pasport nomeri')} value={order.passportNumber} />
|
||||
<InfoRow label={t('sberPayments.fields.fullName', 'Ady Familiýasy Atasynyň ady')} value={order.fullName} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Kabul ediji resminamalary ─────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title="Kabul ediji talyp boyunca resminamalary">
|
||||
<BentoCard title={t('sberPayments.view.sections.acceptedDocs', 'Kabul ediji talyp boýunça resminamalary')}>
|
||||
{kabulDocs.length > 0
|
||||
? kabulDocs.map((doc) => (
|
||||
<DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />
|
||||
))
|
||||
: (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
Resminamalar ýok
|
||||
{t('sberPayments.view.noDocuments', 'Resminamalar ýok')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -256,14 +284,14 @@ export default function SberPaymentViewPage() {
|
||||
|
||||
{/* ── Row 4: Ugradyjy resminamalary ────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title="Ugradyjy boyunca resminamalary">
|
||||
<BentoCard title={t('sberPayments.view.sections.sentDocs', 'Ugradyjy boýunça resminamalary')}>
|
||||
{ugradDocs.length > 0
|
||||
? ugradDocs.map((doc) => (
|
||||
<DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />
|
||||
))
|
||||
: (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
Resminamalar ýok
|
||||
{t('sberPayments.view.noDocuments', 'Resminamalar ýok')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -272,7 +300,7 @@ export default function SberPaymentViewPage() {
|
||||
|
||||
{/* ── Row 5: Töleg taryhy ───────────────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title="Töleg taryhy">
|
||||
<BentoCard title={t('sberPayments.view.sections.paymentHistory', 'Töleg taryhy')}>
|
||||
<div className="p-4">
|
||||
<div className="relative max-w-xs mb-4">
|
||||
<Search size={13} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" />
|
||||
@@ -280,7 +308,7 @@ export default function SberPaymentViewPage() {
|
||||
type="text"
|
||||
value={historySearch}
|
||||
onChange={(e) => setHistorySearch(e.target.value)}
|
||||
placeholder="Gözlemek"
|
||||
placeholder={t('common.search', 'Gözlemek')}
|
||||
className="h-9 w-full pl-9 pr-3 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
|
||||
/>
|
||||
</div>
|
||||
@@ -293,7 +321,7 @@ export default function SberPaymentViewPage() {
|
||||
<line x1="9" y1="21" x2="9" y2="9" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm">Berlen kriteriýalara Töleg gabat gelmedi.</p>
|
||||
<p className="text-sm">{t('sberPayments.view.noPaymentHistory', 'Berlen kriteriýalara Töleg gabat gelmedi.')}</p>
|
||||
</div>
|
||||
</div>
|
||||
</BentoCard>
|
||||
@@ -305,8 +333,8 @@ export default function SberPaymentViewPage() {
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title="Bu tölegi pozmak isleýärsiňizmi?"
|
||||
confirmLabel="Poz"
|
||||
title={t('sberPayments.deleteDialog.title', 'Bu tölegi pozmak isleýärsiňizmi?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
|
||||
@@ -11,15 +11,23 @@ import type { IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMa
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_MAP: Record<IntlPaymentStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
pending: { label: 'Garaşylýar', variant: 'warning', icon: AlertCircle },
|
||||
approved: { label: 'Tassyklandy', variant: 'success', icon: CheckCircle2 },
|
||||
rejected: { label: 'Ret edildi', variant: 'error', icon: XCircle },
|
||||
const STATUS_VARIANT: Record<IntlPaymentStatus, StatusBadgeVariant> = {
|
||||
pending: 'warning',
|
||||
approved: 'success',
|
||||
rejected: 'error',
|
||||
}
|
||||
|
||||
const STATUS_ICON: Record<IntlPaymentStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
}
|
||||
|
||||
function PaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
const cfg = STATUS_MAP[status] ?? STATUS_MAP.pending
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
const { t } = useTranslation()
|
||||
const variant = STATUS_VARIANT[status] ?? STATUS_VARIANT.pending
|
||||
const Icon = STATUS_ICON[status] ?? STATUS_ICON.pending
|
||||
return <StatusBadge label={t(`intlPayment.status.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
@@ -201,7 +209,7 @@ export default function IntlPaymentViewPage() {
|
||||
<InfoRow label={t('intlPayment.client', 'Ulanyjy')}>
|
||||
<span className="text-primary font-medium">{data.client_label}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label="ID">
|
||||
<InfoRow label={t("common.id", "ID")}>
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('intlPayment.status', 'Status')}>
|
||||
|
||||
@@ -24,17 +24,26 @@ import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARAŞYLÝAR: { label: "Garaşylýar", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: "Tassyklandy", variant: "success" as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RED_EDILDI: { label: "Ýatyryldy", variant: "error" as StatusBadgeVariant, icon: XCircle },
|
||||
IŞLENÝÄR: { label: "Işlenýär", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
} satisfies Record<LoanOrderMobileStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
}
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
}
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
@@ -174,7 +183,7 @@ export default function LoanOrderMobilesViewPage() {
|
||||
{/* ── Row 1: Meta + Loan + Location ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID" value={order.id} />
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.status", "Status")}
|
||||
>
|
||||
|
||||
@@ -23,17 +23,26 @@ import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARAŞYLÝAR: { label: "Garaşylýar", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: "Tassyklandy", variant: "success" as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RED_EDILDI: { label: "Ýatyryldy", variant: "error" as StatusBadgeVariant, icon: XCircle },
|
||||
IŞLENÝÄR: { label: "Işlenýär", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
} satisfies Record<LoanOrderMobileStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
}
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
}
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
@@ -169,7 +178,7 @@ export default function LoanOrderViewPage() {
|
||||
<BentoGrid cols={3}>
|
||||
{/* Meta */}
|
||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID" value={order.id} />
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||
value={order.createdAt}
|
||||
|
||||
@@ -4,27 +4,14 @@ import { Eye, Pencil, Trash2, TableProperties } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import {
|
||||
DataTableToolbar,
|
||||
type ActiveFilter,
|
||||
type FilterField,
|
||||
} from "@/components/dataTableToolbar";
|
||||
import {
|
||||
useLoanPaidOffLetters,
|
||||
useDeleteLoanPaidOffLetter,
|
||||
} from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { useLoanPaidOffLetters, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = [
|
||||
"id",
|
||||
"passportSeries",
|
||||
"passportNumber",
|
||||
"loanAccount",
|
||||
"issuedAt",
|
||||
] as const;
|
||||
const COLUMN_IDS = ["id", "passportSeries", "passportNumber", "loanAccount", "issuedAt"] as const;
|
||||
|
||||
// ─── Empty state component ─────────────────────────────────────────────────────
|
||||
|
||||
@@ -38,19 +25,13 @@ function EmptyState({ onCreate }: { onCreate: () => void }) {
|
||||
<TableProperties size={64} strokeWidth={1} />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground text-center max-w-sm">
|
||||
{t(
|
||||
"loanPaidOffLetters.emptyMessage",
|
||||
"Berlen kriteriýalara Karzyň ýapylandygy barada güwanama almak gabat gelmedi.",
|
||||
)}
|
||||
{t("loanPaidOffLetters.emptyMessage", "Berlen kriteriýalara Karzyň ýapylandygy barada güwanama almak gabat gelmedi.")}
|
||||
</p>
|
||||
<button
|
||||
onClick={onCreate}
|
||||
className="px-4 py-2 rounded-md border border-border text-sm text-foreground hover:bg-muted/60 transition-colors"
|
||||
>
|
||||
{t(
|
||||
"loanPaidOffLetters.createButton",
|
||||
"Karzyň ýapylandygy barada güwanama almak dörediň",
|
||||
)}
|
||||
{t("loanPaidOffLetters.createButton", "Karzyň ýapylandygy barada güwanama almak dörediň")}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
@@ -72,10 +53,7 @@ export default function LoanPaidOffLettersPage() {
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([]);
|
||||
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
const queryParams = useMemo(
|
||||
() => ({ search: search || undefined, page, perPage }),
|
||||
[search, page, perPage],
|
||||
);
|
||||
const queryParams = useMemo(() => ({ search: search || undefined, page, perPage }), [search, page, perPage]);
|
||||
|
||||
const { data, isLoading } = useLoanPaidOffLetters(queryParams);
|
||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1;
|
||||
@@ -83,9 +61,7 @@ export default function LoanPaidOffLettersPage() {
|
||||
|
||||
// ── Handlers ───────────────────────────────────────────────────────────────
|
||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) =>
|
||||
prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)),
|
||||
);
|
||||
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
||||
setPage(1);
|
||||
}, []);
|
||||
|
||||
@@ -115,60 +91,34 @@ export default function LoanPaidOffLettersPage() {
|
||||
id: "id",
|
||||
accessorKey: "id",
|
||||
header: t("loanPaidOffLetters.columns.id", "ID"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-semibold text-primary">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm font-semibold text-primary">{row.original.id}</span>,
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
id: "passportSeries",
|
||||
accessorKey: "passportSeries",
|
||||
header: t(
|
||||
"loanPaidOffLetters.columns.passportSeries",
|
||||
"PASPORT SERIÝASY",
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">
|
||||
{row.original.passportSeries}
|
||||
</span>
|
||||
),
|
||||
header: t("loanPaidOffLetters.columns.passportSeries", "PASPORT SERIÝASY"),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.passportSeries}</span>,
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
id: "passportNumber",
|
||||
accessorKey: "passportNumber",
|
||||
header: t(
|
||||
"loanPaidOffLetters.columns.passportNumber",
|
||||
"PASPORT BELGISI",
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-mono text-foreground">
|
||||
{row.original.passportNumber}
|
||||
</span>
|
||||
),
|
||||
header: t("loanPaidOffLetters.columns.passportNumber", "PASPORT BELGISI"),
|
||||
cell: ({ row }) => <span className="text-sm font-mono text-foreground">{row.original.passportNumber}</span>,
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
id: "loanAccount",
|
||||
accessorKey: "loanAccount",
|
||||
header: t("loanPaidOffLetters.columns.loanAccount", "KARZ HASABY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-mono text-foreground">
|
||||
{row.original.loanAccount}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm font-mono text-foreground">{row.original.loanAccount}</span>,
|
||||
},
|
||||
{
|
||||
id: "issuedAt",
|
||||
accessorKey: "issuedAt",
|
||||
header: t("loanPaidOffLetters.columns.issuedAt", "BERLEN WAGTY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground whitespace-nowrap">
|
||||
{row.original.issuedAt}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{row.original.issuedAt}</span>,
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
@@ -222,75 +172,66 @@ export default function LoanPaidOffLettersPage() {
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Page Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t(
|
||||
"loanPaidOffLetters.title",
|
||||
"Karzyň ýapylandygy barada güwanamalar",
|
||||
)}
|
||||
</h1>
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("loanPaidOffLetters.title", "Karzyň ýapylandygy barada güwanamalar")}</h1>
|
||||
</div>
|
||||
|
||||
{/* Table Card */}
|
||||
<div className="bg-card border border-border rounded-xl">
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
{/* Toolbar: column toggle + filter (right side only, matches screenshot) */}
|
||||
<div className="px-4 pt-3 pb-2 border-b border-border">
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={toggleableColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={filterFields}
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
actionLabel={t(
|
||||
"loanPaidOffLetters.createButton",
|
||||
"Karzyň ýapylandygy barada güwanama almak dörediň",
|
||||
)}
|
||||
onAction={handleCreate}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={toggleableColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={filterFields}
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
actionLabel={t("loanPaidOffLetters.createButton", "Karzyň ýapylandygy barada güwanama almak dörediň")}
|
||||
onAction={handleCreate}
|
||||
/>
|
||||
|
||||
{/* Empty state OR table */}
|
||||
{isEmpty ? (
|
||||
<EmptyState onCreate={handleCreate} />
|
||||
) : (
|
||||
<div className="p-4">
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
onOpenChange={(o) => {
|
||||
if (!o) setDeleteId(null);
|
||||
}}
|
||||
title={t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
|
||||
@@ -85,7 +85,7 @@ export default function LoanRemainingViewPage() {
|
||||
|
||||
{/* ── Basic Info ─────────────────────────────────────────────────────── */}
|
||||
<Section title={t("loanRemaining.sections.info", "Esasy maglumatlar")}>
|
||||
<InfoRow label="ID" value={String(record.id)} />
|
||||
<InfoRow label={t("common.id", "ID")} value={String(record.id)} />
|
||||
<InfoRow
|
||||
label={t("loanRemaining.columns.passportSeries", "Pasport seriýasy")}
|
||||
value={record.passportSeries}
|
||||
|
||||
@@ -8,10 +8,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
import {
|
||||
useGetOnlinePayments,
|
||||
useTriggerPaymentCallback,
|
||||
} from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
|
||||
import { useGetOnlinePayments, useTriggerPaymentCallback } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
|
||||
import type { OnlinePayment } from "@/features/onlinePaymentHistory/api/onlinePaymentsHistoryApi";
|
||||
import { PaymentStatusBadge } from "../../features/onlinePaymentHistory/components/PaymentStatusBadge";
|
||||
|
||||
@@ -25,15 +22,7 @@ const DEFAULT_VISIBILITY = {
|
||||
username: true,
|
||||
createdAt: true,
|
||||
};
|
||||
const DEFAULT_ORDER = [
|
||||
"amount",
|
||||
"apiClient",
|
||||
"description",
|
||||
"status",
|
||||
"username",
|
||||
"createdAt",
|
||||
"actions",
|
||||
];
|
||||
const DEFAULT_ORDER = ["amount", "apiClient", "description", "status", "username", "createdAt", "actions"];
|
||||
|
||||
// ─── OnlinePaymentHistoryPage ─────────────────────────────────────────────────
|
||||
|
||||
@@ -44,8 +33,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage] = useState(25);
|
||||
const [search, setSearch] = useState("");
|
||||
const [columnVisibility, setColumnVisibility] =
|
||||
useState<VisibilityState>(DEFAULT_VISIBILITY);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>(DEFAULT_VISIBILITY);
|
||||
const [columnOrder, setColumnOrder] = useState(DEFAULT_ORDER);
|
||||
|
||||
const { data, isLoading } = useGetOnlinePayments({ page, perPage, search });
|
||||
@@ -62,30 +50,18 @@ export default function OnlinePaymentHistoryPage() {
|
||||
{
|
||||
accessorKey: "amount",
|
||||
header: t("onlinePayments.columns.amount", "MÖÇBERI"),
|
||||
cell: ({ row }) => (
|
||||
<span className="tabular-nums text-foreground font-medium">
|
||||
{row.original.amount}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="tabular-nums text-foreground font-medium">{row.original.amount}</span>,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "apiClient",
|
||||
header: t("onlinePayments.columns.apiClient", "API CLIENT"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-foreground text-xs font-mono truncate max-w-[180px] block">
|
||||
{row.original.apiClient}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-foreground text-xs font-mono truncate max-w-[180px] block">{row.original.apiClient}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "description",
|
||||
header: t("onlinePayments.columns.description", "DESC"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-foreground text-sm">
|
||||
{row.original.description}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-foreground text-sm">{row.original.description}</span>,
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
@@ -97,20 +73,12 @@ export default function OnlinePaymentHistoryPage() {
|
||||
{
|
||||
accessorKey: "username",
|
||||
header: t("onlinePayments.columns.username", "USERNAME"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-foreground text-xs font-mono">
|
||||
{row.original.username}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-foreground text-xs font-mono">{row.original.username}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "createdAt",
|
||||
header: t("onlinePayments.columns.createdAt", "DÖREDILEN WAGTY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-muted-foreground text-xs whitespace-nowrap">
|
||||
{formatDateTime(row.original.createdAt)}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-muted-foreground text-xs whitespace-nowrap">{formatDateTime(row.original.createdAt)}</span>,
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
@@ -136,9 +104,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
||||
onClick={() =>
|
||||
navigate(`/online-payments-history/${row.original.id}`)
|
||||
}
|
||||
onClick={() => navigate(`/online-payments-history/${row.original.id}`)}
|
||||
title={t("common.view", "Görmek")}
|
||||
>
|
||||
<Eye size={15} />
|
||||
@@ -159,41 +125,37 @@ export default function OnlinePaymentHistoryPage() {
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-5">
|
||||
{t("onlinePayments.title", "Onlaýn töleg taryhy")}
|
||||
</h1>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("onlinePayments.title", "Onlaýn töleg taryhy")}</h1>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
hideAction
|
||||
/>
|
||||
|
||||
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
hideAction
|
||||
/>
|
||||
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total ?? 0}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total ?? 0}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export default function LoanTypeViewPage() {
|
||||
|
||||
{/* Detail section */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={data.id} />
|
||||
<InfoRow label={t('common.id', 'ID')} value={data.id} />
|
||||
|
||||
{/* Multilingual name rows */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
|
||||
@@ -70,7 +70,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
|
||||
{/* Main info */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={data.id} />
|
||||
<InfoRow label={t('common.id', 'ID')} value={data.id} />
|
||||
|
||||
{/* Name — multilingual */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
@@ -81,7 +81,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
{(['tk', 'ru', 'en'] as const).map((lang) => (
|
||||
<div key={lang}>
|
||||
<span className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block mb-0.5">
|
||||
{lang === 'tk' ? 'Türkmen' : lang === 'ru' ? 'Русский' : 'English'}
|
||||
{t(lang === 'tk' ? 'languages.tk' : lang === 'ru' ? 'languages.ru' : 'languages.en', lang === 'tk' ? 'Türkmen' : lang === 'ru' ? 'Русский' : 'English')}
|
||||
</span>
|
||||
<span className="text-sm text-foreground">{data.name[lang] || '—'}</span>
|
||||
</div>
|
||||
@@ -98,7 +98,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
{(['tk', 'ru', 'en'] as const).map((lang) => (
|
||||
<div key={lang}>
|
||||
<span className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block mb-1">
|
||||
{lang === 'tk' ? 'Türkmen' : lang === 'ru' ? 'Русский' : 'English'}
|
||||
{t(lang === 'tk' ? 'languages.tk' : lang === 'ru' ? 'languages.ru' : 'languages.en', lang === 'tk' ? 'Türkmen' : lang === 'ru' ? 'Русский' : 'English')}
|
||||
</span>
|
||||
{data.description[lang] ? (
|
||||
<div
|
||||
|
||||
@@ -21,12 +21,6 @@ import { usePermission, useDeletePermission } from '@/features/permissions/hooks
|
||||
|
||||
type LangKey = 'tk' | 'ru' | 'en'
|
||||
|
||||
const LANG_TABS: { key: LangKey; label: string }[] = [
|
||||
{ key: 'tk', label: 'Türkmen' },
|
||||
{ key: 'ru', label: 'Русский' },
|
||||
{ key: 'en', label: 'English' },
|
||||
]
|
||||
|
||||
function LangTabs({
|
||||
active,
|
||||
onChange,
|
||||
@@ -34,6 +28,12 @@ function LangTabs({
|
||||
active: LangKey
|
||||
onChange: (l: LangKey) => void
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const LANG_TABS: { key: LangKey; label: string }[] = [
|
||||
{ key: 'tk', label: t('languages.tk', 'Türkmen') },
|
||||
{ key: 'ru', label: t('languages.ru', 'Русский') },
|
||||
{ key: 'en', label: t('languages.en', 'English') },
|
||||
]
|
||||
return (
|
||||
<div className="flex gap-1 justify-end mb-2">
|
||||
{LANG_TABS.map((tab) => (
|
||||
@@ -130,7 +130,7 @@ export default function PermissionViewPage() {
|
||||
|
||||
{/* Detail section */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={permission.id} />
|
||||
<InfoRow label={t('common.id', 'ID')} value={permission.id} />
|
||||
<InfoRow label={t('permissions.fields.code', 'Kod')} value={permission.code} />
|
||||
|
||||
{/* Name row — with lang switcher */}
|
||||
|
||||
+128
-159
@@ -1,43 +1,41 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
||||
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ActiveFilter } from '@/components/dataTableToolbar'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter } from "@/components/dataTableToolbar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { useUsers, useDeleteUser } from '@/features/allUsers/hooks/useAllUsers'
|
||||
import type { UserListItem } from '@/features/allUsers/api/allUsersApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { useUsers, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
||||
import type { UserListItem } from "@/features/allUsers/api/allUsersApi";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||
|
||||
const DEFAULT_PER_PAGE = 25
|
||||
const DEFAULT_PER_PAGE = 25;
|
||||
|
||||
// ─── UsersListPage ────────────────────────────────────────────────────────────
|
||||
|
||||
export default function UsersListPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteUser = useDeleteUser()
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const deleteUser = useDeleteUser();
|
||||
|
||||
// Table state
|
||||
const [page, setPage] = useState(1)
|
||||
const [perPage, setPerPage] = useState(DEFAULT_PER_PAGE)
|
||||
const [search, setSearch] = useState('')
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([])
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({})
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([
|
||||
'id', 'username', 'name', 'phone', 'email', 'isActive', 'actions',
|
||||
])
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(DEFAULT_PER_PAGE);
|
||||
const [search, setSearch] = useState("");
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([]);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>(["id", "username", "name", "phone", "email", "isActive", "actions"]);
|
||||
|
||||
// Delete confirm dialog
|
||||
const [deleteTarget, setDeleteTarget] = useState<UserListItem | null>(null)
|
||||
const [deleteTarget, setDeleteTarget] = useState<UserListItem | null>(null);
|
||||
|
||||
// ── Derived filter values ───────────────────────────────────────────────────
|
||||
const isActiveFilter = activeFilters.find((f) => f.fieldId === 'isActive')?.value ?? ''
|
||||
const isActiveFilter = activeFilters.find((f) => f.fieldId === "isActive")?.value ?? "";
|
||||
|
||||
// ── Data fetch ─────────────────────────────────────────────────────────────
|
||||
const { data, isLoading } = useUsers({
|
||||
@@ -45,83 +43,67 @@ export default function UsersListPage() {
|
||||
perPage,
|
||||
search,
|
||||
isActive: isActiveFilter || undefined,
|
||||
})
|
||||
});
|
||||
|
||||
// ── Handlers ───────────────────────────────────────────────────────────────
|
||||
const handleSearchChange = (value: string) => {
|
||||
setSearch(value)
|
||||
setPage(1)
|
||||
}
|
||||
setSearch(value);
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const handleFilterChange = (fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) => {
|
||||
const rest = prev.filter((f) => f.fieldId !== fieldId)
|
||||
return value ? [...rest, { fieldId, value }] : rest
|
||||
})
|
||||
setPage(1)
|
||||
}
|
||||
const rest = prev.filter((f) => f.fieldId !== fieldId);
|
||||
return value ? [...rest, { fieldId, value }] : rest;
|
||||
});
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const handleFilterReset = () => {
|
||||
setActiveFilters([])
|
||||
setPage(1)
|
||||
}
|
||||
setActiveFilters([]);
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!deleteTarget) return
|
||||
await deleteUser.mutateAsync(deleteTarget.id)
|
||||
setDeleteTarget(null)
|
||||
}
|
||||
if (!deleteTarget) return;
|
||||
await deleteUser.mutateAsync(deleteTarget.id);
|
||||
setDeleteTarget(null);
|
||||
};
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns: ColumnDef<UserListItem>[] = [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: 'ID',
|
||||
accessorKey: "id",
|
||||
header: "ID",
|
||||
size: 80,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-xs font-mono text-primary font-semibold">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-xs font-mono text-primary font-semibold">{row.original.id}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'username',
|
||||
header: t('users.fields.username', 'ULANYJY ADY'),
|
||||
accessorKey: "username",
|
||||
header: t("users.fields.username", "ULANYJY ADY"),
|
||||
enableSorting: true,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-medium text-foreground">
|
||||
{row.original.username}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm font-medium text-foreground">{row.original.username}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: t('users.fields.name', 'ADY'),
|
||||
accessorKey: "name",
|
||||
header: t("users.fields.name", "ADY"),
|
||||
enableSorting: true,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.name}</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.name}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'phone',
|
||||
header: t('users.fields.phone', 'TELEFON'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground font-mono">{row.original.phone}</span>
|
||||
),
|
||||
accessorKey: "phone",
|
||||
header: t("users.fields.phone", "TELEFON"),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground font-mono">{row.original.phone}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'email',
|
||||
header: t('users.fields.email', 'E-POÇTA'),
|
||||
accessorKey: "email",
|
||||
header: t("users.fields.email", "E-POÇTA"),
|
||||
enableSorting: true,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{row.original.email ?? '—'}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.email ?? "—"}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'isActive',
|
||||
header: t('users.fields.isActive', 'IŞJEŇ'),
|
||||
accessorKey: "isActive",
|
||||
header: t("users.fields.isActive", "IŞJEŇ"),
|
||||
size: 80,
|
||||
cell: ({ row }) =>
|
||||
row.original.isActive ? (
|
||||
@@ -131,26 +113,16 @@ export default function UsersListPage() {
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
id: "actions",
|
||||
header: "",
|
||||
size: 100,
|
||||
enableHiding: false,
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => navigate(`/all-users/${row.original.id}`)}
|
||||
>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => navigate(`/all-users/${row.original.id}`)}>
|
||||
<Eye size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => navigate(`/all-users/${row.original.id}/edit`)}
|
||||
>
|
||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => navigate(`/all-users/${row.original.id}/edit`)}>
|
||||
<Pencil size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
@@ -164,90 +136,87 @@ export default function UsersListPage() {
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
const columnMetas = columns
|
||||
.filter((c) => 'accessorKey' in c || (c.id && c.id !== 'actions' && c.id !== 'select'))
|
||||
.filter((c) => "accessorKey" in c || (c.id && c.id !== "actions" && c.id !== "select"))
|
||||
.map((c) => ({
|
||||
id: 'accessorKey' in c ? (c.accessorKey as string) : (c.id as string),
|
||||
label:
|
||||
typeof c.header === 'string'
|
||||
? c.header
|
||||
: 'accessorKey' in c
|
||||
? (c.accessorKey as string)
|
||||
: (c.id as string),
|
||||
}))
|
||||
id: "accessorKey" in c ? (c.accessorKey as string) : (c.id as string),
|
||||
label: typeof c.header === "string" ? c.header : "accessorKey" in c ? (c.accessorKey as string) : (c.id as string),
|
||||
}));
|
||||
|
||||
// ── Render ─────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
{t('clients.title', 'Ahli Müşderiler')}
|
||||
</h1>
|
||||
<h1 className="text-2xl font-semibold text-foreground">{t("clients.title", "Ahli Müşderiler")}</h1>
|
||||
</div>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
|
||||
{/* Toolbar */}
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchPlaceholder={t('users.searchPlaceholder', 'Gözlemek')}
|
||||
columns={columnMetas}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={[
|
||||
{
|
||||
id: 'isActive',
|
||||
label: t('users.fields.isActive', 'Işjeň'),
|
||||
options: [
|
||||
{ value: 'true', label: t('common.active', 'Işjeň') },
|
||||
{ value: 'false', label: t('common.inactive', 'Işjeň däl') },
|
||||
],
|
||||
},
|
||||
]}
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||
actionLabel={t('users.actions.create', 'Ulanyjy dörediň')}
|
||||
onAction={() => navigate('/all-users/create')}
|
||||
/>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
{/* Toolbar */}
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchPlaceholder={t("users.searchPlaceholder", "Gözlemek")}
|
||||
columns={columnMetas}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={[
|
||||
{
|
||||
id: "isActive",
|
||||
label: t("users.fields.isActive", "Işjeň"),
|
||||
options: [
|
||||
{ value: "true", label: t("common.active", "Işjeň") },
|
||||
{ value: "false", label: t("common.inactive", "Işjeň däl") },
|
||||
],
|
||||
},
|
||||
]}
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
actionLabel={t("users.actions.create", "Ulanyjy dörediň")}
|
||||
onAction={() => navigate("/all-users/create")}
|
||||
/>
|
||||
|
||||
{/* Table */}
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
{/* Table */}
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
|
||||
description={t(
|
||||
'users.deleteDialog.description',
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace('{name}', deleteTarget?.username ?? '')}
|
||||
confirmLabel={t('common.delete', 'Öçür')}
|
||||
onOpenChange={(o) => {
|
||||
if (!o) setDeleteTarget(null);
|
||||
}}
|
||||
title={t("users.deleteDialog.title", "Ulanyjyny öçürmek")}
|
||||
description={t("users.deleteDialog.description", 'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.').replace(
|
||||
"{name}",
|
||||
deleteTarget?.username ?? "",
|
||||
)}
|
||||
confirmLabel={t("common.delete", "Öçür")}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
isLoading={deleteUser.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,19 +1,8 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import {
|
||||
Loader2,
|
||||
Pencil,
|
||||
Trash2,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
ChevronDown,
|
||||
Plus,
|
||||
Search,
|
||||
SlidersHorizontal,
|
||||
ChevronUp,
|
||||
} from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Loader2, Pencil, Trash2, CheckCircle2, XCircle, ChevronDown, Plus, Search, SlidersHorizontal, ChevronUp } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -23,31 +12,24 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useUser, useDeleteUser } from '@/features/allUsers/hooks/useAllUsers'
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import { useUser, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
||||
|
||||
// ─── Collapsible Section ──────────────────────────────────────────────────────
|
||||
|
||||
interface CollapsibleBlockProps {
|
||||
title: string
|
||||
actionLabel: string
|
||||
onAction: () => void
|
||||
emptyMessage: string
|
||||
searchPlaceholder?: string
|
||||
showFilter?: boolean
|
||||
title: string;
|
||||
actionLabel: string;
|
||||
onAction: () => void;
|
||||
emptyMessage: string;
|
||||
searchPlaceholder?: string;
|
||||
showFilter?: boolean;
|
||||
}
|
||||
|
||||
function CollapsibleBlock({
|
||||
title,
|
||||
actionLabel,
|
||||
onAction,
|
||||
emptyMessage,
|
||||
searchPlaceholder = 'Gözlemek',
|
||||
showFilter = false,
|
||||
}: CollapsibleBlockProps) {
|
||||
const [open, setOpen] = useState(true)
|
||||
const [search, setSearch] = useState('')
|
||||
function CollapsibleBlock({ title, actionLabel, onAction, emptyMessage, searchPlaceholder, showFilter = false }: CollapsibleBlockProps) {
|
||||
const [open, setOpen] = useState(true);
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
return (
|
||||
<div className="mb-6">
|
||||
@@ -64,10 +46,7 @@ function CollapsibleBlock({
|
||||
{/* 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"
|
||||
/>
|
||||
<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}
|
||||
@@ -92,13 +71,7 @@ function CollapsibleBlock({
|
||||
{/* 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"
|
||||
>
|
||||
<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" />
|
||||
@@ -115,51 +88,45 @@ function CollapsibleBlock({
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── UserViewPage ─────────────────────────────────────────────────────────────
|
||||
|
||||
export default function UserViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const userId = Number(id)
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const userId = Number(id);
|
||||
|
||||
const { data: user, isLoading, isError } = useUser(userId)
|
||||
const deleteUser = useDeleteUser()
|
||||
const { data: user, isLoading, isError } = useUser(userId);
|
||||
const deleteUser = useDeleteUser();
|
||||
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
await deleteUser.mutateAsync(userId)
|
||||
navigate('/users')
|
||||
}
|
||||
await deleteUser.mutateAsync(userId);
|
||||
navigate("/users");
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Loader2 size={24} className="animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<div className="p-6 max-w-4xl space-y-0">
|
||||
|
||||
|
||||
{/* Title + actions */}
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<h1 className="text-xl font-bold text-foreground leading-tight">
|
||||
{t('users.viewTitle', 'Ulanyjy giňişleýin')}: {user.name} ({user.username})
|
||||
{t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name} ({user.username})
|
||||
</h1>
|
||||
<div className="flex items-center gap-2 shrink-0 ml-4">
|
||||
<Button
|
||||
@@ -170,12 +137,7 @@ export default function UserViewPage() {
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={() => navigate(`/users/${userId}/edit`)}
|
||||
>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => navigate(`/users/${userId}/edit`)}>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -183,12 +145,12 @@ export default function UserViewPage() {
|
||||
|
||||
{/* Main info */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={user.id} />
|
||||
<InfoRow label={t('users.fields.username', 'Ulanyjy ady')} value={user.username} />
|
||||
<InfoRow label={t('users.fields.name', 'Ady')} value={user.name} />
|
||||
<InfoRow label={t('users.fields.phone', 'Telefon')} value={user.phone} />
|
||||
<InfoRow label={t('users.fields.email', 'E-poçta')} value={user.email} />
|
||||
<InfoRow label={t('users.fields.isActive', 'Işjeň')}>
|
||||
<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.name", "Ady")} value={user.name} />
|
||||
<InfoRow label={t("users.fields.phone", "Telefon")} value={user.phone} />
|
||||
<InfoRow label={t("users.fields.email", "E-poçta")} value={user.email} />
|
||||
<InfoRow label={t("users.fields.isActive", "Işjeň")}>
|
||||
{user.isActive ? (
|
||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||
) : (
|
||||
@@ -199,66 +161,61 @@ export default function UserViewPage() {
|
||||
|
||||
{/* Rollar */}
|
||||
<CollapsibleBlock
|
||||
title={t('users.sections.roles', 'Rollar')}
|
||||
actionLabel={t('users.actions.addRole', 'Rol birikdiriň')}
|
||||
title={t("users.sections.roles", "Rollar")}
|
||||
actionLabel={t("users.actions.addRole", "Rol birikdiriň")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t('users.empty.roles', 'Berlen kriteriýalara Rol gabat gelmedi.')}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
emptyMessage={t("users.empty.roles", "Berlen kriteriýalara Rol gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
|
||||
{/* Rugsatlar */}
|
||||
<CollapsibleBlock
|
||||
title={t('users.sections.permissions', 'Rugsatlar')}
|
||||
actionLabel={t('users.actions.addPermission', 'Rugsat birikdiriň')}
|
||||
title={t("users.sections.permissions", "Rugsatlar")}
|
||||
actionLabel={t("users.actions.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t('users.empty.permissions', 'Berlen kriteriýalara Rugsat gabat gelmedi.')}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
emptyMessage={t("users.empty.permissions", "Berlen kriteriýalara Rugsat gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
|
||||
{/* Şahamçalar */}
|
||||
<CollapsibleBlock
|
||||
title={t('users.sections.branches', 'Şahamçalar')}
|
||||
actionLabel={t('users.actions.addBranch', 'Şahamça birikdiriň')}
|
||||
title={t("users.sections.branches", "Şahamçalar")}
|
||||
actionLabel={t("users.actions.addBranch", "Şahamça birikdiriň")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t('users.empty.branches', 'Berlen kriteriýalara Şahamça gabat gelmedi.')}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
emptyMessage={t("users.empty.branches", "Berlen kriteriýalara Şahamça gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
showFilter
|
||||
/>
|
||||
|
||||
{/* Ammallar */}
|
||||
<CollapsibleBlock
|
||||
title={t('users.sections.audit', 'Ammallar')}
|
||||
actionLabel={t('users.actions.addAction', 'Hereket')}
|
||||
title={t("users.sections.audit", "Ammallar")}
|
||||
actionLabel={t("users.actions.addAction", "Hereket")}
|
||||
onAction={() => {}}
|
||||
emptyMessage={t('users.empty.audit', 'Berlen kriteriýalara Hereket gabat gelmedi.')}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
emptyMessage={t("users.empty.audit", "Berlen kriteriýalara Hereket gabat gelmedi.")}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t("users.deleteDialog.title", "Ulanyjyny öçürmek")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'users.deleteDialog.description',
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace('{name}', user.username)}
|
||||
{t("users.deleteDialog.description", 'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.').replace(
|
||||
"{name}",
|
||||
user.username,
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýok')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{t('common.delete', 'Öçür')}
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýok")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleDeleteConfirm} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{t("common.delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ export default function ClientsPage() {
|
||||
}))
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
{t('clients.title', 'Müşderiler')}
|
||||
|
||||
@@ -160,7 +160,7 @@ export default function ClientDetailPage() {
|
||||
const roleColumns: ColumnDef<ClientRole>[] = [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: 'ID',
|
||||
header: t('common.id', 'ID'),
|
||||
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||
size: 80,
|
||||
},
|
||||
@@ -198,7 +198,7 @@ export default function ClientDetailPage() {
|
||||
const branchColumns: ColumnDef<ClientBranch>[] = [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: 'ID',
|
||||
header: t('common.id', 'ID'),
|
||||
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||
size: 60,
|
||||
},
|
||||
@@ -296,7 +296,7 @@ export default function ClientDetailPage() {
|
||||
{/* ── Row 1: Esasy maglumatlar + Kontakt ──────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t('clients.sections.basic', 'Esasy maglumatlar')}>
|
||||
<InfoRow label="ID" value={client.id} />
|
||||
<InfoRow label={t('common.id', 'ID')} value={client.id} />
|
||||
<InfoRow
|
||||
label={t('clients.fields.username', 'Ulanyjy ady')}
|
||||
value={client.username}
|
||||
|
||||
@@ -148,7 +148,7 @@ export default function OperatorsPage() {
|
||||
|
||||
// ── Render ───────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
{/* Page header */}
|
||||
<div className="mb-6">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
|
||||
@@ -136,7 +136,7 @@ export default function OperatorDetailPage() {
|
||||
const roleColumns: ColumnDef<OperatorRole>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "ID",
|
||||
header: t("common.id", "ID"),
|
||||
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||
size: 80,
|
||||
},
|
||||
@@ -188,7 +188,7 @@ export default function OperatorDetailPage() {
|
||||
const branchColumns: ColumnDef<OperatorBranch>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "ID",
|
||||
header: t("common.id", "ID"),
|
||||
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||
size: 60,
|
||||
},
|
||||
@@ -305,7 +305,7 @@ export default function OperatorDetailPage() {
|
||||
{/* ── Row 1: Esasy maglumatlar + Kontakt ──────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("operators.sections.basic", "Esasy maglumatlar")}>
|
||||
<InfoRow label="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 label={t("operators.fields.name", "Ady")} value={operator.name} />
|
||||
<InfoRow label={t("operators.fields.isActive", "Işjeň")}>
|
||||
|
||||
Reference in new issue
Block a user