started refactor
This commit is contained in:
@@ -193,7 +193,7 @@ export function CardPinForm({ mode, initialData, onSubmit, isSubmitting }: CardP
|
||||
: t('cardPin.editBtn', 'Kart pin bukja redaktirläň')
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto space-y-6">
|
||||
<div className=" mx-auto space-y-6">
|
||||
<h1 className="text-2xl font-bold text-foreground">{title}</h1>
|
||||
|
||||
{/* ── Status & Note ────────────────────────────────────────────────── */}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from 'lucide-react'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import type { LoanOrderStatus } from '../api/loanOrdersApi'
|
||||
|
||||
interface LoanOrderStatusConfig {
|
||||
labelKey: string
|
||||
variant: StatusBadgeVariant
|
||||
icon: React.ElementType
|
||||
}
|
||||
|
||||
const STATUS_CONFIG: Record<LoanOrderStatus, LoanOrderStatusConfig> = {
|
||||
GARAŞYLÝAR: { labelKey: 'loanOrderStatus.GARAŞYLÝAR', variant: 'warning', icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { labelKey: 'loanOrderStatus.KANAGATLANDYRYLAN', variant: 'success', icon: CheckCircle2 },
|
||||
RED_EDILDI: { labelKey: 'loanOrderStatus.RED_EDILDI', variant: 'error', icon: XCircle },
|
||||
IŞLENÝÄR: { labelKey: 'loanOrderStatus.IŞLENÝÄR', variant: 'info', icon: Loader2 },
|
||||
}
|
||||
|
||||
interface LoanOrderStatusBadgeProps {
|
||||
status: LoanOrderStatus
|
||||
}
|
||||
|
||||
export function LoanOrderStatusBadge({ status }: LoanOrderStatusBadgeProps) {
|
||||
const { t } = useTranslation()
|
||||
const config = STATUS_CONFIG[status]
|
||||
|
||||
if (!config) {
|
||||
console.warn(`[LoanOrderStatusBadge] Unknown status: ${status}`);
|
||||
return (
|
||||
<StatusBadge
|
||||
label={status ? String(status) : t('common.unknown', 'Näbelli')}
|
||||
variant="default"
|
||||
icon={AlertCircle}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return <StatusBadge label={t(config.labelKey)} variant={config.variant} icon={config.icon} />
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
import { Link } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import type { ColumnDef } from '@/components/dataTable'
|
||||
import type { CardOrderListItem, CardOrderStatus } from '../api/orderNewCardApi'
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG: Record<
|
||||
CardOrderStatus,
|
||||
{ label: string; className: string }
|
||||
> = {
|
||||
PENDING: {
|
||||
label: 'Garaşylýar',
|
||||
className:
|
||||
'inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold tracking-wide ' +
|
||||
'bg-amber-500/10 text-amber-400 border border-amber-500/20',
|
||||
},
|
||||
APPROVED: {
|
||||
label: 'Tassyklandy',
|
||||
className:
|
||||
'inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold tracking-wide ' +
|
||||
'bg-emerald-500/10 text-emerald-400 border border-emerald-500/20',
|
||||
},
|
||||
REJECTED: {
|
||||
label: 'Ýatyryldy',
|
||||
className:
|
||||
'inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold tracking-wide ' +
|
||||
'bg-red-500/10 text-red-400 border border-red-500/20',
|
||||
},
|
||||
}
|
||||
|
||||
function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const cfg = STATUS_CONFIG[status]
|
||||
const icons: Record<CardOrderStatus, string> = {
|
||||
PENDING: '⏳',
|
||||
APPROVED: '✓',
|
||||
REJECTED: '✕',
|
||||
}
|
||||
return (
|
||||
<span className={cfg.className}>
|
||||
<span className="text-[10px]">{icons[status]}</span>
|
||||
{cfg.label}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Coloured text helper ─────────────────────────────────────────────────────
|
||||
|
||||
function HighlightText({
|
||||
value,
|
||||
variant,
|
||||
}: {
|
||||
value: string
|
||||
variant: 'teal' | 'cyan' | 'muted'
|
||||
}) {
|
||||
const cls =
|
||||
variant === 'teal' ? 'text-teal-400 font-semibold' :
|
||||
variant === 'cyan' ? 'text-cyan-400 font-semibold' :
|
||||
'text-muted-foreground'
|
||||
return <span className={cls}>{value}</span>
|
||||
}
|
||||
|
||||
// ─── useCardOrderColumns ──────────────────────────────────────────────────────
|
||||
|
||||
export function useCardOrderColumns(): ColumnDef<CardOrderListItem>[] {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: t('cardOrder.col.id', 'ID'),
|
||||
cell: ({ row }) => (
|
||||
<Link
|
||||
to={`/order-new-card/${row.original.id}`}
|
||||
className="font-mono text-xs text-primary hover:underline"
|
||||
>
|
||||
{row.original.id}
|
||||
</Link>
|
||||
),
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
accessorKey: 'issuanceReasonName',
|
||||
header: t('cardOrder.col.reason', 'Sebäp'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">
|
||||
{row.original.issuanceReasonName}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'createdAt',
|
||||
header: t('cardOrder.col.createdAt', 'Döredilen wagty'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-muted-foreground whitespace-nowrap">
|
||||
{row.original.createdAt}
|
||||
</span>
|
||||
),
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
accessorKey: 'cardTypeName',
|
||||
header: t('cardOrder.col.cardType', 'Görnüşi'),
|
||||
cell: ({ row }) => {
|
||||
const isAltyn = row.original.cardTypeName === 'Altyn Asyr'
|
||||
return (
|
||||
<HighlightText
|
||||
value={row.original.cardTypeName}
|
||||
variant={isAltyn ? 'cyan' : 'teal'}
|
||||
/>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'provinceName',
|
||||
header: t('cardOrder.col.province', 'Welaýat'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.provinceName}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'branchName',
|
||||
header: t('cardOrder.col.branch', 'Şahamça'),
|
||||
cell: ({ row }) => {
|
||||
const specialBranches = [
|
||||
'Köpetdag', 'Türkmenabat', 'Türkmenbaşy',
|
||||
'Seýdi', 'Çandybil', 'Balkan', 'Baş bank',
|
||||
]
|
||||
const isSpecial = specialBranches.includes(row.original.branchName)
|
||||
return (
|
||||
<HighlightText
|
||||
value={row.original.branchName}
|
||||
variant={isSpecial ? 'cyan' : 'muted'}
|
||||
/>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'fullName',
|
||||
header: t('cardOrder.col.name', 'Ady'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">
|
||||
{row.original.lastName} {row.original.firstName}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: t('cardOrder.col.status', 'Status'),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
size: 130,
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export function SberPaymentForm({ mode, initialData, orderId }: SberPaymentFormP
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-8 max-w-4xl pb-8">
|
||||
<div className="space-y-8 pb-8">
|
||||
{/* Status Section */}
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-base font-semibold text-foreground">Status</h2>
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import { cn } from '@/lib/utils'
|
||||
import type { PaymentStatus, PaymentPaidStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||
|
||||
interface StatusBadgeProps {
|
||||
status: PaymentStatus
|
||||
className?: string
|
||||
}
|
||||
|
||||
const statusConfig: Record<PaymentStatus, { label: string; className: string }> = {
|
||||
GARASYLYYAR: {
|
||||
label: 'Garasylyyar',
|
||||
className: 'bg-[oklch(0.75_0.18_85)] text-[oklch(0.20_0_0)]',
|
||||
},
|
||||
KANAGATLANDYRYLAN: {
|
||||
label: 'Kanagatlandyrylan',
|
||||
className: 'bg-[oklch(0.72_0.19_160)] text-[oklch(0.15_0_0)]',
|
||||
},
|
||||
RET_EDILEN: {
|
||||
label: 'Ret edilen',
|
||||
className: 'bg-destructive text-destructive-foreground',
|
||||
},
|
||||
}
|
||||
|
||||
export function StatusBadge({ status, className }: StatusBadgeProps) {
|
||||
const config = statusConfig[status]
|
||||
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
'inline-flex items-center px-2 py-0.5 rounded text-xs font-semibold uppercase tracking-wide',
|
||||
config.className,
|
||||
className
|
||||
)}
|
||||
>
|
||||
{config.label}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
interface PaidStatusBadgeProps {
|
||||
status: PaymentPaidStatus
|
||||
className?: string
|
||||
}
|
||||
|
||||
export function PaidStatusBadge({ status, className }: PaidStatusBadgeProps) {
|
||||
const isPaid = status === 'Tolendi'
|
||||
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
'inline-flex items-center text-sm',
|
||||
isPaid ? 'text-primary' : 'text-muted-foreground',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{status}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export function IntlPaymentForm({ mode, initialData, onSubmit, isSubmitting }: I
|
||||
: t('intlPayment.editBtn', 'Visa/Master tölegler (talyplar üçin) redaktirläň')
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto space-y-6">
|
||||
<div className="mx-auto space-y-6">
|
||||
<h1 className="text-2xl font-bold text-foreground">{title}</h1>
|
||||
|
||||
{/* ── Status ────────────────────────────────────────────────────────── */}
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
CardPinStatus,
|
||||
} from "@/features/cardPins/api/cardPinApi";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -22,38 +22,36 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_MAP: Record<CardPinStatus, { label: string; className: string }> =
|
||||
{
|
||||
pending: {
|
||||
label: "Garaşylýar",
|
||||
className: "bg-yellow-500/20 text-yellow-400 border-yellow-500/30",
|
||||
},
|
||||
approved: {
|
||||
label: "Tassyklandy",
|
||||
className: "bg-green-500/20 text-green-400 border-green-500/30",
|
||||
},
|
||||
rejected: {
|
||||
label: "Ret edildi",
|
||||
className: "bg-red-500/20 text-red-400 border-red-500/30",
|
||||
},
|
||||
};
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
|
||||
function StatusBadge({ status }: { status: CardPinStatus }) {
|
||||
const cfg = STATUS_MAP[status] ?? STATUS_MAP.pending;
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold border",
|
||||
cfg.className,
|
||||
)}
|
||||
>
|
||||
{cfg.label}
|
||||
</span>
|
||||
);
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
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 }>
|
||||
|
||||
function CardPinStatusStatusBadge({ 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} />
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -139,7 +137,7 @@ export default function CardPinsPage() {
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("cardPin.status", "Status"),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <CardPinStatusStatusBadge status={row.original.status} />,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -16,24 +16,33 @@ import {
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_MAP: Record<CardPinStatus, { label: string; className: string }> = {
|
||||
pending: { label: 'Garaşylýar', className: 'bg-yellow-500/20 text-yellow-500 border-yellow-500/30' },
|
||||
approved: { label: 'Tassyklandy', className: 'bg-green-500/20 text-green-500 border-green-500/30' },
|
||||
rejected: { label: 'Ret edildi', className: 'bg-red-500/20 text-red-500 border-red-500/30' },
|
||||
}
|
||||
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 }>
|
||||
|
||||
function StatusBadge({ status }: { status: CardPinStatus }) {
|
||||
const cfg = STATUS_MAP[status] ?? STATUS_MAP.pending
|
||||
return (
|
||||
<span className={cn('inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold border', cfg.className)}>
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-current" />
|
||||
{cfg.label}
|
||||
</span>
|
||||
)
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Field row ────────────────────────────────────────────────────────────────
|
||||
@@ -102,7 +111,7 @@ export default function CardPinViewPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto space-y-6">
|
||||
<div className="mx-auto space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between">
|
||||
<h1 className="text-xl font-bold text-foreground">
|
||||
@@ -157,7 +166,7 @@ export default function CardPinViewPage() {
|
||||
{data.created_at}
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.status', 'Status')}>
|
||||
<StatusBadge status={data.status} />
|
||||
<CardPinStatusBadge status={data.status} />
|
||||
</FieldRow>
|
||||
<FieldRow label={t('cardPin.note', 'Bellik')}>
|
||||
{data.note || '—'}
|
||||
|
||||
@@ -1,22 +1,60 @@
|
||||
import { useState, useMemo, useCallback } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useNavigate, Link } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Eye, Pencil, Trash2 } from 'lucide-react'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle, AlertCircle } from 'lucide-react'
|
||||
import type { ColumnDef, VisibilityState } from '@tanstack/react-table'
|
||||
|
||||
import { DataTable } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import type { ActiveFilter, FilterField } from '@/components/dataTableToolbar'
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from '@/components/dataTableToolbar'
|
||||
import {
|
||||
useCardOrders,
|
||||
useDeleteCardOrder,
|
||||
useProvinces,
|
||||
useBranches,
|
||||
} from '@/features/orderNewCard/hooks/useOrderNewCard'
|
||||
import { useCardOrderColumns } from '@/features/orderNewCard/components/orderNewCardTable'
|
||||
import type { CardOrderStatus } from '@/features/orderNewCard/api/orderNewCardApi'
|
||||
import type { CardOrderListItem, CardOrderStatus } from '@/features/orderNewCard/api/orderNewCardApi'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
|
||||
// ─── Column meta list (for toolbar toggle) ────────────────────────────────────
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
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<CardOrderStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
|
||||
function OrderNewCardStatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
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} />
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ─── Coloured text helper ─────────────────────────────────────────────────────
|
||||
|
||||
function HighlightText({ value, variant }: { value: string; variant: 'teal' | 'cyan' | 'muted' }) {
|
||||
const cls =
|
||||
variant === 'teal' ? 'text-teal-400 font-semibold' :
|
||||
variant === 'cyan' ? 'text-cyan-400 font-semibold' :
|
||||
'text-muted-foreground'
|
||||
return <span className={cls}>{value}</span>
|
||||
}
|
||||
|
||||
// ─── Column meta (toolbar toggle) ────────────────────────────────────────────
|
||||
|
||||
const COLUMN_META = [
|
||||
{ id: 'id', label: 'ID' },
|
||||
@@ -29,13 +67,18 @@ const COLUMN_META = [
|
||||
{ id: 'status', label: 'Status' },
|
||||
]
|
||||
|
||||
const SPECIAL_BRANCHES = [
|
||||
'Köpetdag', 'Türkmenabat', 'Türkmenbaşy',
|
||||
'Seýdi', 'Çandybil', 'Balkan', 'Baş bank',
|
||||
]
|
||||
|
||||
const DEFAULT_ORDER = COLUMN_META.map((c) => c.id)
|
||||
|
||||
// ─── CardOrdersPage ───────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardOrdersPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
@@ -55,7 +98,7 @@ export default function CardOrdersPage() {
|
||||
const { data: provincesData } = useProvinces()
|
||||
const { data: branchesData } = useBranches(provinceId ? Number(provinceId) : undefined)
|
||||
|
||||
// ── Data ───────────────────────────────────────────────────────────────────
|
||||
// ── Query params ───────────────────────────────────────────────────────────
|
||||
const queryParams = useMemo(() => {
|
||||
const filterMap = Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value]))
|
||||
return {
|
||||
@@ -73,12 +116,11 @@ export default function CardOrdersPage() {
|
||||
// ── Handlers ───────────────────────────────────────────────────────────────
|
||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) => {
|
||||
const newFilters = prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f))
|
||||
// Reset branch if province changes
|
||||
const updated = prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f))
|
||||
if (fieldId === 'provinceId') {
|
||||
return newFilters.map((f) => (f.fieldId === 'branchId' ? { ...f, value: '' } : f))
|
||||
return updated.map((f) => (f.fieldId === 'branchId' ? { ...f, value: '' } : f))
|
||||
}
|
||||
return newFilters
|
||||
return updated
|
||||
})
|
||||
setPage(1)
|
||||
}, [])
|
||||
@@ -97,15 +139,83 @@ export default function CardOrdersPage() {
|
||||
)
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const baseColumns = useCardOrderColumns()
|
||||
const columns = useMemo(
|
||||
const columns = useMemo<ColumnDef<CardOrderListItem>[]>(
|
||||
() => [
|
||||
...baseColumns,
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: t('cardOrder.col.id', 'ID'),
|
||||
cell: ({ row }) => (
|
||||
<Link
|
||||
to={`/order-new-card/${row.original.id}`}
|
||||
className="font-mono text-xs text-primary hover:underline"
|
||||
>
|
||||
{row.original.id}
|
||||
</Link>
|
||||
),
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
accessorKey: 'issuanceReasonName',
|
||||
header: t('cardOrder.col.reason', 'Sebäp'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.issuanceReasonName}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'createdAt',
|
||||
header: t('cardOrder.col.createdAt', 'Döredilen wagty'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-muted-foreground whitespace-nowrap">{row.original.createdAt}</span>
|
||||
),
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
accessorKey: 'cardTypeName',
|
||||
header: t('cardOrder.col.cardType', 'Görnüşi'),
|
||||
cell: ({ row }) => (
|
||||
<HighlightText
|
||||
value={row.original.cardTypeName}
|
||||
variant={row.original.cardTypeName === 'Altyn Asyr' ? 'cyan' : 'teal'}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'provinceName',
|
||||
header: t('cardOrder.col.province', 'Welaýat'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.provinceName}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'branchName',
|
||||
header: t('cardOrder.col.branch', 'Şahamça'),
|
||||
cell: ({ row }) => (
|
||||
<HighlightText
|
||||
value={row.original.branchName}
|
||||
variant={SPECIAL_BRANCHES.includes(row.original.branchName) ? 'cyan' : 'muted'}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'fullName',
|
||||
header: t('cardOrder.col.name', 'Ady'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">
|
||||
{row.original.lastName} {row.original.firstName}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: t('cardOrder.col.status', 'Status'),
|
||||
cell: ({ row }) => <OrderNewCardStatusBadge status={row.original.status} />,
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
enableHiding: false,
|
||||
cell: ({ row }: { row: any }) => (
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-1.5 justify-end">
|
||||
<button
|
||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
@@ -134,44 +244,44 @@ export default function CardOrdersPage() {
|
||||
size: 100,
|
||||
},
|
||||
],
|
||||
[baseColumns, t, navigate, handleDelete, deleteMutation.isPending]
|
||||
[t, navigate, handleDelete, deleteMutation.isPending]
|
||||
)
|
||||
|
||||
// ── Filter fields ──────────────────────────────────────────────────────────
|
||||
const filterFields: FilterField[] = useMemo(() => [
|
||||
{
|
||||
id: 'status',
|
||||
label: t('cardOrder.col.status', 'Status'),
|
||||
options: [
|
||||
{ value: 'PENDING', label: t('cardOrder.status.pending', 'Garaşylýar') },
|
||||
{ value: 'APPROVED', label: t('cardOrder.status.approved', 'Tassyklandy') },
|
||||
{ value: 'REJECTED', label: t('cardOrder.status.rejected', 'Ýatyryldy') },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'provinceId',
|
||||
label: t('cardOrder.col.province', 'Welaýat'),
|
||||
options: provincesData?.map(p => ({ value: String(p.id), label: p.name })) || [],
|
||||
},
|
||||
{
|
||||
id: 'branchId',
|
||||
label: t('cardOrder.col.branch', 'Şahamça'),
|
||||
options: branchesData?.map(b => ({ value: String(b.id), label: b.name })) || [],
|
||||
},
|
||||
], [t, provincesData, branchesData])
|
||||
|
||||
// ── Render ────────────────────────────────────────────────────────────────
|
||||
const filterFields = useMemo<FilterField[]>(
|
||||
() => [
|
||||
{
|
||||
id: 'status',
|
||||
label: t('cardOrder.col.status', 'Status'),
|
||||
options: [
|
||||
{ value: 'PENDING', label: t('cardOrder.status.pending', 'Garaşylýar') },
|
||||
{ value: 'APPROVED', label: t('cardOrder.status.approved', 'Tassyklandy') },
|
||||
{ value: 'REJECTED', label: t('cardOrder.status.rejected', 'Ýatyryldy') },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'provinceId',
|
||||
label: t('cardOrder.col.province', 'Welaýat'),
|
||||
options: provincesData?.map((p) => ({ value: String(p.id), label: p.name })) ?? [],
|
||||
},
|
||||
{
|
||||
id: 'branchId',
|
||||
label: t('cardOrder.col.branch', 'Şahamça'),
|
||||
options: branchesData?.map((b) => ({ value: String(b.id), label: b.name })) ?? [],
|
||||
},
|
||||
],
|
||||
[t, provincesData, branchesData]
|
||||
)
|
||||
|
||||
// ── Render ─────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Page Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground tracking-tight">
|
||||
{t('cardOrder.title', 'Kart sargytlary')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{/* Table Card */}
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
|
||||
@@ -6,9 +6,10 @@ import type { ColumnDef, VisibilityState } from '@tanstack/react-table'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { DataTable } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ColumnMeta, type FilterField, type ActiveFilter } from '@/components/dataTableToolbar'
|
||||
import { StatusBadge, PaidStatusBadge } from '@/features/sberPayments/components/statusBadge'
|
||||
import { useSberPaymentOrders, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments'
|
||||
import { WELAYATLAR, STATUSES, type SberPaymentOrder } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||
import { type SberPaymentOrder, WELAYATLAR, STATUSES, type PaymentStatus, type PaymentPaidStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
|
||||
import {
|
||||
Select,
|
||||
@@ -18,6 +19,53 @@ import {
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
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 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 }>
|
||||
|
||||
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} />
|
||||
}
|
||||
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Column Definitions ───────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -131,12 +179,12 @@ export default function SberPaymentsListPage() {
|
||||
<ArrowUpDown size={12} />
|
||||
</button>
|
||||
),
|
||||
cell: ({ row }) => <StatusBadge status={row.getValue('status')} />,
|
||||
cell: ({ row }) => <PaymentStatusBadge status={row.getValue('status')} />,
|
||||
},
|
||||
{
|
||||
accessorKey: 'paidStatus',
|
||||
header: 'Tolenen (sul ay)',
|
||||
cell: ({ row }) => <PaidStatusBadge status={row.getValue('paidStatus')} />,
|
||||
cell: ({ row }) => <PaymentPaidStatusBadge status={row.getValue('paidStatus')} />,
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
@@ -298,15 +346,6 @@ export default function SberPaymentsListPage() {
|
||||
totalCount={data?.pagination.totalCount ?? 0}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
{/* Pagination Info */}
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
<span>
|
||||
{data?.pagination.currentPage && data?.pagination.perPage && data?.pagination.totalCount
|
||||
? `${(data.pagination.currentPage - 1) * data.pagination.perPage + 1}-${Math.min(data.pagination.currentPage * data.pagination.perPage, data.pagination.totalCount)} of ${data.pagination.totalCount}`
|
||||
: ''}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,69 +1,147 @@
|
||||
import { format } from "date-fns";
|
||||
import {
|
||||
Trash2,
|
||||
Edit,
|
||||
Search,
|
||||
Download,
|
||||
Clock,
|
||||
XCircle,
|
||||
CheckCircle2,
|
||||
AlertCircle,
|
||||
} from "lucide-react";
|
||||
|
||||
import { format } from 'date-fns'
|
||||
import { Trash2, Edit, Search, Download, Clock } from 'lucide-react'
|
||||
|
||||
import { useSberPaymentOrder, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments'
|
||||
import { StatusBadge, PaidStatusBadge } from '@/features/sberPayments/components/statusBadge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { cn } from '@/lib/utils'
|
||||
import {
|
||||
useSberPaymentOrder,
|
||||
useDeleteSberPayment,
|
||||
} from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import type {
|
||||
PaymentPaidStatus,
|
||||
PaymentStatus,
|
||||
} from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
|
||||
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 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 }
|
||||
>;
|
||||
|
||||
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} />
|
||||
);
|
||||
}
|
||||
|
||||
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} />
|
||||
);
|
||||
}
|
||||
// ─── Info Row Component ───────────────────────────────────────────────────────
|
||||
|
||||
function InfoRow({
|
||||
label,
|
||||
value,
|
||||
highlight = false
|
||||
}: {
|
||||
label: string
|
||||
value: React.ReactNode
|
||||
highlight?: boolean
|
||||
function InfoRow({
|
||||
label,
|
||||
value,
|
||||
highlight = false,
|
||||
}: {
|
||||
label: string;
|
||||
value: React.ReactNode;
|
||||
highlight?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-start py-2.5 border-b border-border last:border-b-0">
|
||||
<span className="w-64 shrink-0 text-sm text-muted-foreground">{label}</span>
|
||||
<span className={cn(
|
||||
'flex-1 text-sm',
|
||||
highlight ? 'text-primary font-medium' : 'text-foreground'
|
||||
)}>
|
||||
{value || '—'}
|
||||
<span className="w-64 shrink-0 text-sm text-muted-foreground">
|
||||
{label}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"flex-1 text-sm",
|
||||
highlight ? "text-primary font-medium" : "text-foreground",
|
||||
)}
|
||||
>
|
||||
{value || "—"}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Section Component ────────────────────────────────────────────────────────
|
||||
|
||||
function Section({
|
||||
title,
|
||||
children,
|
||||
className
|
||||
}: {
|
||||
title: string
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
function Section({
|
||||
title,
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
title: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('space-y-1', className)}>
|
||||
<div className={cn("space-y-1", className)}>
|
||||
<h2 className="text-base font-semibold text-foreground mb-3">{title}</h2>
|
||||
<div className="bg-card rounded-lg border border-border">
|
||||
{children}
|
||||
</div>
|
||||
<div className="bg-card rounded-lg border border-border">{children}</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Document Item Component ──────────────────────────────────────────────────
|
||||
|
||||
function DocumentItem({
|
||||
label,
|
||||
fileName,
|
||||
fileUrl
|
||||
}: {
|
||||
label: string
|
||||
fileName: string | null
|
||||
fileUrl: string | null
|
||||
function DocumentItem({
|
||||
label,
|
||||
fileName,
|
||||
fileUrl,
|
||||
}: {
|
||||
label: string;
|
||||
fileName: string | null;
|
||||
fileUrl: string | null;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-start gap-4 py-3 border-b border-border last:border-b-0 px-4">
|
||||
@@ -88,47 +166,51 @@ function DocumentItem({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── View Page Component ──────────────────────────────────────────────────────
|
||||
|
||||
export default function SberPaymentViewPage() {
|
||||
const params = useParams()
|
||||
const navigate = useNavigate()
|
||||
const id = params.id as string
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id)
|
||||
const deleteMutation = useDeleteSberPayment()
|
||||
|
||||
const params = useParams();
|
||||
const navigate = useNavigate();
|
||||
const id = params.id as string;
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id);
|
||||
const deleteMutation = useDeleteSberPayment();
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (confirm('Bu tolegi pozmak isleyanizmi?')) {
|
||||
await deleteMutation.mutateAsync(id)
|
||||
navigate('/sber-payments')
|
||||
if (confirm("Bu tolegi pozmak isleyanizmi?")) {
|
||||
await deleteMutation.mutateAsync(id);
|
||||
navigate("/sber-payments");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Spinner className="w-8 h-8" />
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-[400px] text-muted-foreground">
|
||||
<p>Toleg tapylmady</p>
|
||||
<Button variant="outline" onClick={() => navigate('/sber-payments')} className="mt-4">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => navigate("/sber-payments")}
|
||||
className="mt-4"
|
||||
>
|
||||
Yza
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className="space-y-6 max-w-4xl">
|
||||
<div className="space-y-6">
|
||||
{/* Header Actions */}
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<Button
|
||||
@@ -147,17 +229,23 @@ export default function SberPaymentViewPage() {
|
||||
<Edit size={18} />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
|
||||
{/* Status Section */}
|
||||
<Section title="Status">
|
||||
<div className="px-4">
|
||||
<InfoRow label="ID" value={order.id} />
|
||||
<InfoRow label="Status" value={<StatusBadge status={order.status} />} />
|
||||
<InfoRow label="Tolenen (Sul ay)" value={<PaidStatusBadge status={order.paidStatus} />} />
|
||||
<InfoRow
|
||||
label="Status"
|
||||
value={<PaymentStatusBadge status={order.status} />}
|
||||
/>
|
||||
<InfoRow
|
||||
label="Tolenen (Sul ay)"
|
||||
value={<PaymentPaidStatusBadge status={order.paidStatus} />}
|
||||
/>
|
||||
<InfoRow label="Bellik" value={order.bellik} />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
||||
{/* Location Section */}
|
||||
<Section title="Lokasiya">
|
||||
<div className="px-4">
|
||||
@@ -165,7 +253,7 @@ export default function SberPaymentViewPage() {
|
||||
<InfoRow label="Sahamca" value={order.sahamca} highlight />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
||||
{/* Personal Info Section */}
|
||||
<Section title="Sahsy maglumatlar">
|
||||
<div className="px-4">
|
||||
@@ -176,17 +264,20 @@ export default function SberPaymentViewPage() {
|
||||
<InfoRow label="Hazirki yasayys yeri" value={order.address} />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
||||
{/* Payment Info Section */}
|
||||
<Section title="Toleg">
|
||||
<div className="px-4">
|
||||
<InfoRow
|
||||
label="Tolegi ugradyjynyn maglumatlary"
|
||||
value={`I-M${order.passportNumber?.slice(0, 2) ?? 'XX'}-${order.passportNumber ?? ''} ${order.fullName}`}
|
||||
<InfoRow
|
||||
label="Tolegi ugradyjynyn maglumatlary"
|
||||
value={`I-M${order.passportNumber?.slice(0, 2) ?? "XX"}-${order.passportNumber ?? ""} ${order.fullName}`}
|
||||
/>
|
||||
<InfoRow
|
||||
label="Toleg ugradyjynyn goyum hasaby"
|
||||
value={order.accountNumber}
|
||||
/>
|
||||
<InfoRow label="Toleg ugradyjynyn goyum hasaby" value={order.accountNumber} />
|
||||
</div>
|
||||
|
||||
|
||||
<div className="px-4 py-3 bg-muted/30 border-t border-border">
|
||||
<div className="text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2">
|
||||
Tolegi kabul edijinin maglumatlary
|
||||
@@ -201,13 +292,15 @@ export default function SberPaymentViewPage() {
|
||||
<p className="font-medium">{order.passportNumber}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground">Ady Familiyasy Atasynyn ady</span>
|
||||
<span className="text-muted-foreground">
|
||||
Ady Familiyasy Atasynyn ady
|
||||
</span>
|
||||
<p className="font-medium">{order.fullName}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
||||
{/* Documents - Accepted */}
|
||||
<div className="space-y-3">
|
||||
<h2 className="text-base font-semibold text-foreground">
|
||||
@@ -224,39 +317,43 @@ export default function SberPaymentViewPage() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{/* Documents - Sent */}
|
||||
<div className="space-y-3">
|
||||
<h2 className="text-base font-semibold text-foreground">
|
||||
Ugradyjy boyunca resminamalary
|
||||
</h2>
|
||||
<div className="bg-card rounded-lg border border-border">
|
||||
{order.documents?.slice(6).map((doc) => (
|
||||
<DocumentItem
|
||||
key={doc.id}
|
||||
label={doc.label}
|
||||
fileName={doc.name}
|
||||
fileUrl={doc.fileUrl}
|
||||
/>
|
||||
)) || (
|
||||
{order.documents
|
||||
?.slice(6)
|
||||
.map((doc) => (
|
||||
<DocumentItem
|
||||
key={doc.id}
|
||||
label={doc.label}
|
||||
fileName={doc.name}
|
||||
fileUrl={doc.fileUrl}
|
||||
/>
|
||||
)) || (
|
||||
<div className="px-4 py-8 text-center text-muted-foreground text-sm">
|
||||
Resminamalar yok
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{/* Payment History */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<h2 className="text-base font-semibold text-foreground">Toleg taryhy</h2>
|
||||
<h2 className="text-base font-semibold text-foreground">
|
||||
Toleg taryhy
|
||||
</h2>
|
||||
<button className="text-muted-foreground hover:text-foreground transition-colors">
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
|
||||
<path d="M6 0L7.5 4.5L12 6L7.5 7.5L6 12L4.5 7.5L0 6L4.5 4.5L6 0Z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="bg-card rounded-lg border border-border">
|
||||
<div className="flex items-center gap-2 px-4 py-3 border-b border-border">
|
||||
<Search size={14} className="text-muted-foreground" />
|
||||
@@ -266,28 +363,37 @@ export default function SberPaymentViewPage() {
|
||||
className="flex-1 bg-transparent text-sm placeholder:text-muted-foreground/50 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex items-center justify-center py-12 text-muted-foreground">
|
||||
<div className="text-center">
|
||||
<div className="w-12 h-12 mx-auto mb-3 rounded-lg bg-muted/50 flex items-center justify-center">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.5"
|
||||
>
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" />
|
||||
<line x1="3" y1="9" x2="21" y2="9" />
|
||||
<line x1="9" y1="21" x2="9" y2="9" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm">Berlen kriteriyalara Toleg gabat gelmedi.</p>
|
||||
<p className="text-sm">
|
||||
Berlen kriteriyalara Toleg gabat gelmedi.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex items-center justify-end">
|
||||
<button className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors">
|
||||
<Clock size={16} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{/* Activity Log */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -298,7 +404,7 @@ export default function SberPaymentViewPage() {
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="bg-card rounded-lg border border-border overflow-hidden">
|
||||
{/* Table Header */}
|
||||
<div className="grid grid-cols-6 gap-4 px-4 py-2 bg-muted/40 text-xs font-semibold text-muted-foreground uppercase tracking-wider">
|
||||
@@ -309,27 +415,35 @@ export default function SberPaymentViewPage() {
|
||||
<span>Analys statusy</span>
|
||||
<span>Sene</span>
|
||||
</div>
|
||||
|
||||
|
||||
{/* Table Body */}
|
||||
{order.activityLog?.length ? (
|
||||
order.activityLog.map((log) => (
|
||||
<div key={log.id} className="grid grid-cols-6 gap-4 px-4 py-3 border-t border-border text-sm">
|
||||
<span className="text-primary font-medium">{log.id.split('-')[1] ?? '45384'}</span>
|
||||
<div
|
||||
key={log.id}
|
||||
className="grid grid-cols-6 gap-4 px-4 py-3 border-t border-border text-sm"
|
||||
>
|
||||
<span className="text-primary font-medium">
|
||||
{log.id.split("-")[1] ?? "45384"}
|
||||
</span>
|
||||
<span>{log.analysisName}</span>
|
||||
<span className="text-muted-foreground">{log.createdBy}</span>
|
||||
<span className="text-muted-foreground">{log.target}</span>
|
||||
<span>
|
||||
<span className={cn(
|
||||
'inline-flex items-center px-2 py-0.5 rounded text-xs font-semibold',
|
||||
log.status === 'FINISHED'
|
||||
? 'bg-primary/20 text-primary'
|
||||
: 'bg-muted text-muted-foreground'
|
||||
)}>
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center px-2 py-0.5 rounded text-xs font-semibold",
|
||||
log.status === "FINISHED"
|
||||
? "bg-primary/20 text-primary"
|
||||
: "bg-muted text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{log.status}
|
||||
</span>
|
||||
</span>
|
||||
<span className="text-muted-foreground">
|
||||
{format(new Date(log.createdAt), 'dd/MM/yyyy, HH:mm:ss')} GMT+5
|
||||
{format(new Date(log.createdAt), "dd/MM/yyyy, HH:mm:ss")}{" "}
|
||||
GMT+5
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
@@ -339,14 +453,7 @@ export default function SberPaymentViewPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Pagination */}
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
<span>Onki</span>
|
||||
<span>1-1 of 1</span>
|
||||
<span>Indiki</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,22 +19,32 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
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<IntlPaymentStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
|
||||
const STATUS_MAP: Record<IntlPaymentStatus, { label: string; className: string }> = {
|
||||
pending: { label: 'Garaşylýar', className: 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30' },
|
||||
approved: { label: 'Tassyklandy', className: 'bg-green-500/20 text-green-400 border-green-500/30' },
|
||||
rejected: { label: 'Ret edildi', className: 'bg-red-500/20 text-red-400 border-red-500/30' },
|
||||
}
|
||||
|
||||
function StatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
const cfg = STATUS_MAP[status] ?? STATUS_MAP.pending
|
||||
return (
|
||||
<span className={cn('inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold border', cfg.className)}>
|
||||
{cfg.label}
|
||||
</span>
|
||||
)
|
||||
function IntlPaymentStatusStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Month selector (AÝ TOLEGI) ───────────────────────────────────────────────
|
||||
@@ -153,7 +163,7 @@ export default function IntlPaymentsPage() {
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: t('intlPayment.status', 'Status'),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <IntlPaymentStatusStatusBadge status={row.original.status} />,
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
|
||||
@@ -16,24 +16,21 @@ import {
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useState } from 'react'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_MAP: Record<IntlPaymentStatus, { label: string; className: string }> = {
|
||||
pending: { label: 'Garaşylýar', className: 'bg-yellow-500/20 text-yellow-500 border-yellow-500/30' },
|
||||
approved: { label: 'Tassyklandy', className: 'bg-green-500/20 text-green-500 border-green-500/30' },
|
||||
rejected: { label: 'Ret edildi', className: 'bg-red-500/20 text-red-500 border-red-500/30' },
|
||||
const STATUS_MAP: Record<IntlPaymentStatus, { label: string; variant: StatusBadgeVariant }> = {
|
||||
pending: { label: 'Garaşylýar', variant: 'warning' },
|
||||
approved: { label: 'Tassyklandy', variant: 'success' },
|
||||
rejected: { label: 'Ret edildi', variant: 'error' },
|
||||
}
|
||||
|
||||
function StatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
function PaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
const cfg = STATUS_MAP[status] ?? STATUS_MAP.pending
|
||||
return (
|
||||
<span className={cn('inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold border', cfg.className)}>
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-current" />
|
||||
{cfg.label}
|
||||
</span>
|
||||
<StatusBadge label={cfg.label} variant={cfg.variant} />
|
||||
)
|
||||
}
|
||||
|
||||
@@ -144,7 +141,7 @@ export default function IntlPaymentViewPage() {
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto space-y-6">
|
||||
<div className=" mx-auto space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between">
|
||||
<div /> {/* breadcrumb handled by layout */}
|
||||
@@ -193,7 +190,7 @@ export default function IntlPaymentViewPage() {
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</FieldRow>
|
||||
<FieldRow label={t('intlPayment.status', 'Status')}>
|
||||
<StatusBadge status={data.status} />
|
||||
<PaymentStatusBadge status={data.status} />
|
||||
</FieldRow>
|
||||
<FieldRow label={t('intlPayment.tilowanMonth', 'Tölewan (Aý/aý)')}>
|
||||
{data.created_at}
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
import { useState, useMemo, useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Eye, Pencil, Trash2 } from 'lucide-react'
|
||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle, Loader2 } from 'lucide-react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import type { ColumnDef, VisibilityState } from '@tanstack/react-table'
|
||||
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { DataTable } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from '@/components/dataTableToolbar'
|
||||
import { LoanOrderStatusBadge } from '@/features/loanOrders/components/loanOrderStatusBadge'
|
||||
import {
|
||||
useLoanOrderMobiles,
|
||||
useDeleteLoanOrderMobile,
|
||||
} from '@/features/loanOrderMobiles/hooks/useLoanOrderMobiles'
|
||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
||||
|
||||
|
||||
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARAŞYLÝAR: { label: 'Garaşylýar', variant: 'warning' as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: 'Kanagatlandyrylan', variant: 'success' as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RED_EDILDI: { label: 'Red edildi', variant: 'error' as StatusBadgeVariant, icon: XCircle },
|
||||
IŞLENÝÄR: { label: 'Işlenýär', variant: 'info' as StatusBadgeVariant, icon: Loader2 },
|
||||
} satisfies Record<LoanOrderMobileStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
|
||||
function LoanOrderStatusBadge({ 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} />
|
||||
}
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = [
|
||||
|
||||
@@ -2,10 +2,42 @@ import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Trash2, Pencil, Download, ChevronRight, Eye } from 'lucide-react'
|
||||
import { useLoanOrderMobileById, useDeleteLoanOrderMobile } from '@/features/loanOrderMobiles/hooks/useLoanOrderMobiles'
|
||||
import { LoanOrderStatusBadge } from '@/features/loanOrders/components/loanOrderStatusBadge'
|
||||
import { CreditCardVisual } from '@/components/creditCardVisual'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { toast } from 'sonner'
|
||||
import type { LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
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 }>
|
||||
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Sub-component Types ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -212,7 +244,7 @@ export default function LoanOrderMobilesViewPage() {
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanOrders.columns.status', 'Status')}
|
||||
</span>
|
||||
<LoanOrderStatusBadge status={order.status} />
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
</div>
|
||||
<InfoRow
|
||||
label={t('loanOrders.columns.createdAt', 'Döredilen wagty')}
|
||||
|
||||
@@ -2,9 +2,42 @@ import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Trash2, Pencil, Download, ChevronRight, Eye } from 'lucide-react'
|
||||
import { useLoanOrderById, useDeleteLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
|
||||
import { LoanOrderStatusBadge } from '@/features/loanOrders/components/loanOrderStatusBadge'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { toast } from 'sonner'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import type { LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
||||
|
||||
|
||||
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 }>
|
||||
|
||||
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} />
|
||||
}
|
||||
|
||||
|
||||
// ─── Sub-component Types ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -215,7 +248,7 @@ export default function LoanOrderViewPage() {
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanOrders.columns.status', 'Status')}
|
||||
</span>
|
||||
<LoanOrderStatusBadge status={order.status} />
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
</div>
|
||||
<InfoRow
|
||||
label={t('loanOrders.fields.amount', 'Berlik')}
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
import { useState, useMemo, useCallback } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Eye, Pencil, Trash2 } from 'lucide-react'
|
||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle, Loader2 } 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 { LoanOrderStatusBadge } from '@/features/loanOrders/components/loanOrderStatusBadge'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { useLoanOrders, useDeleteLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
|
||||
import type { LoanOrder, LoanOrderStatus } from '@/features/loanOrders/api/loanOrdersApi'
|
||||
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARAŞYLÝAR: { label: 'Garaşylýar', variant: 'warning' as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: 'Kanagatlandyrylan', variant: 'success' as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RED_EDILDI: { label: 'Red edildi', variant: 'error' as StatusBadgeVariant, icon: XCircle },
|
||||
IŞLENÝÄR: { label: 'Işlenýär', variant: 'info' as StatusBadgeVariant, icon: Loader2 },
|
||||
} satisfies Record<LoanOrderStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>
|
||||
|
||||
function LoanOrderStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
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} />
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = [
|
||||
@@ -20,19 +35,19 @@ const COLUMN_IDS = [
|
||||
// ─── Filter fields ────────────────────────────────────────────────────────────
|
||||
|
||||
const REGION_OPTIONS = [
|
||||
{ value: 'Balkan', label: 'Balkan' },
|
||||
{ value: 'Ahal', label: 'Ahal' },
|
||||
{ value: 'Daşoguz', label: 'Daşoguz' },
|
||||
{ value: 'Lebap', label: 'Lebap' },
|
||||
{ value: 'Mary', label: 'Mary' },
|
||||
{ value: 'Aşgabat', label: 'Aşgabat' },
|
||||
{ value: 'Balkan', label: 'Balkan' },
|
||||
{ value: 'Ahal', label: 'Ahal' },
|
||||
{ value: 'Daşoguz', label: 'Daşoguz' },
|
||||
{ value: 'Lebap', label: 'Lebap' },
|
||||
{ value: 'Mary', label: 'Mary' },
|
||||
{ value: 'Aşgabat', label: 'Aşgabat' },
|
||||
]
|
||||
|
||||
const STATUS_OPTIONS: { value: LoanOrderStatus; label: string }[] = [
|
||||
{ value: 'GARAŞYLÝAR', label: 'GARAŞYLÝAR' },
|
||||
{ value: 'KANAGATLANDYRYLAN', label: 'KANAGATLANDYRYLAN' },
|
||||
{ value: 'RED_EDILDI', label: 'RED EDILDI' },
|
||||
{ value: 'IŞLENÝÄR', label: 'IŞLENÝÄR' },
|
||||
{ value: 'GARAŞYLÝAR', label: 'Garaşylýar' },
|
||||
{ value: 'KANAGATLANDYRYLAN', label: 'Kanagatlandyrylan' },
|
||||
{ value: 'RED_EDILDI', label: 'Red edildi' },
|
||||
{ value: 'IŞLENÝÄR', label: 'Işlenýär' },
|
||||
]
|
||||
|
||||
// ─── Page Component ───────────────────────────────────────────────────────────
|
||||
@@ -42,7 +57,6 @@ export default function LoanOrdersPage() {
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanOrder()
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
const [page, setPage] = useState(1)
|
||||
const [perPage, setPerPage] = useState(10)
|
||||
@@ -55,7 +69,6 @@ export default function LoanOrdersPage() {
|
||||
{ fieldId: 'archived', value: '' },
|
||||
])
|
||||
|
||||
// ── Query params ───────────────────────────────────────────────────────────
|
||||
const queryParams = useMemo(() => {
|
||||
const filterMap = Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value]))
|
||||
return {
|
||||
@@ -70,10 +83,8 @@ export default function LoanOrdersPage() {
|
||||
}, [search, activeFilters, page, perPage])
|
||||
|
||||
const { data, isLoading } = useLoanOrders(queryParams)
|
||||
|
||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1
|
||||
|
||||
// ── Handlers ───────────────────────────────────────────────────────────────
|
||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)))
|
||||
setPage(1)
|
||||
@@ -92,7 +103,6 @@ export default function LoanOrdersPage() {
|
||||
[deleteMutation, t]
|
||||
)
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<LoanOrder>[]>(
|
||||
() => [
|
||||
{
|
||||
@@ -208,10 +218,9 @@ export default function LoanOrdersPage() {
|
||||
size: 100,
|
||||
},
|
||||
],
|
||||
[t, handleDelete, deleteMutation.isPending]
|
||||
[t, navigate, handleDelete, deleteMutation.isPending]
|
||||
)
|
||||
|
||||
// ── Column meta for toolbar ────────────────────────────────────────────────
|
||||
const toggleableColumns = useMemo(
|
||||
() => COLUMN_IDS.map((id) => ({ id, label: t(`loanOrders.columns.${id}`, id) })),
|
||||
[t]
|
||||
@@ -246,17 +255,14 @@ export default function LoanOrdersPage() {
|
||||
[t]
|
||||
)
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<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('loanOrders.title', 'Karz sargytlary')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{/* Table Card */}
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
@@ -275,9 +281,7 @@ export default function LoanOrdersPage() {
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||
actionLabel={t('loanOrderMobiles.createButton', 'Karz sargyt dörediñ')}
|
||||
onAction={() => {
|
||||
navigate('/loan-orders/create')
|
||||
}}
|
||||
onAction={() => navigate('/loan-orders/create')}
|
||||
/>
|
||||
|
||||
<DataTable
|
||||
|
||||
Reference in New Issue
Block a user