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 ────────────────────────────────────────────────────────── */}
|
||||
|
||||
Reference in New Issue
Block a user