refactored some view pages
This commit is contained in:
@@ -3,7 +3,7 @@ import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Trash2, Pencil, ChevronDown } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -78,8 +78,16 @@ export default function CardBalanceViewPage() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
<div className="space-y-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
useDeleteCardPin,
|
||||
} from "@/features/cardPins/hooks/useCardPins";
|
||||
import type { CardPinStatus } from "@/features/cardPins/api/cardPinApi";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import {
|
||||
@@ -17,14 +17,13 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -48,42 +47,22 @@ function CardPinStatusBadge({ status }: { status: CardPinStatus }) {
|
||||
return <StatusBadge label={t(`cardPin.status.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: "full" | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === "full" ? "sm:col-span-full" :
|
||||
span === 2 ? "sm:col-span-2" :
|
||||
span === 3 ? "sm:col-span-3" : ""
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function CardPinViewSkeleton() {
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -99,11 +78,7 @@ export default function CardPinViewPage() {
|
||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin()
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-8 text-primary" />
|
||||
</div>
|
||||
)
|
||||
return <CardPinViewSkeleton />
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
@@ -124,7 +99,7 @@ export default function CardPinViewPage() {
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<AlertDialogTitle asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
@@ -132,7 +107,7 @@ export default function CardPinViewPage() {
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
useDownloadCardRequisite,
|
||||
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Pencil, Trash2, Download } from "lucide-react";
|
||||
import {
|
||||
@@ -18,14 +18,13 @@ import {
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -49,42 +48,22 @@ function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
return <StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: "full" | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === "full" ? "sm:col-span-full" :
|
||||
span === 2 ? "sm:col-span-2" :
|
||||
span === 3 ? "sm:col-span-3" : ""
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function CardRequisiteViewSkeleton() {
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -101,11 +80,7 @@ export default function CardRequisiteViewPage() {
|
||||
const downloadMutation = useDownloadCardRequisite()
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-8 text-primary" />
|
||||
</div>
|
||||
)
|
||||
return <CardRequisiteViewSkeleton />
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
@@ -134,7 +109,7 @@ export default function CardRequisiteViewPage() {
|
||||
<Download size={15} />
|
||||
</Button>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<AlertDialogTitle asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
@@ -142,7 +117,7 @@ export default function CardRequisiteViewPage() {
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -42,8 +42,16 @@ export default function CardTransactionViewPage() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
<div className="space-y-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
useDeleteCardOrder,
|
||||
} from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -40,46 +40,6 @@ function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: "full" | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === "full" ? "sm:col-span-full" :
|
||||
span === 2 ? "sm:col-span-2" :
|
||||
span === 3 ? "sm:col-span-3" : ""
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function DetailSkeleton() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetCurrencyRateById, useDeleteCurrencyRate } from '@/features/currencyRates/hooks/useCurrencyRates'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
@@ -32,15 +33,15 @@ export default function CurrencyRateDetailPage() {
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="h-6 w-64 bg-muted rounded animate-pulse" />
|
||||
<div className="h-48 bg-muted rounded-xl animate-pulse" />
|
||||
<Skeleton className="h-6 w-64" />
|
||||
<Skeleton className="h-48 rounded-xl" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!rate) {
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<p className="text-muted-foreground">
|
||||
{t('currencyRates.notFound', 'Walýuta kursy tapylmady')}
|
||||
</p>
|
||||
@@ -51,7 +52,7 @@ export default function CurrencyRateDetailPage() {
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div >
|
||||
|
||||
|
||||
{/* Header */}
|
||||
|
||||
@@ -4,7 +4,7 @@ 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'
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog, type AuditRowProps } from '@/components/viewPageComponents'
|
||||
import { useSberPaymentOrder, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments'
|
||||
import type { PaymentPaidStatus, PaymentStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||
import { useState } from 'react'
|
||||
@@ -61,46 +61,6 @@ function PaymentPaidStatusBadge({ status }: { status: PaymentPaidStatus }) {
|
||||
return <StatusBadge label={t(`sberPayments.paidStatus.${PAID_STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: 'grid-cols-1',
|
||||
2: 'grid-cols-1 sm:grid-cols-2',
|
||||
3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3',
|
||||
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: 'full' | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === 'full' ? 'sm:col-span-full' :
|
||||
span === 2 ? 'sm:col-span-2' :
|
||||
span === 3 ? 'sm:col-span-3' : ''
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Document row ─────────────────────────────────────────────────────────────
|
||||
|
||||
function DocumentRow({
|
||||
|
||||
@@ -163,13 +163,13 @@ export default function IntlPaymentsPage() {
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
size="icon" variant="ghost" className="h-7 w-7"
|
||||
onClick={() => navigate(`/visa-master-payments/${row.original.id}`)}
|
||||
onClick={() => navigate(`/visa-master/${row.original.id}`)}
|
||||
>
|
||||
<Eye size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon" variant="ghost" className="h-7 w-7"
|
||||
onClick={() => navigate(`/visa-master-payments/${row.original.id}/edit`)}
|
||||
onClick={() => navigate(`/visa-master/${row.original.id}/edit`)}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
</Button>
|
||||
@@ -237,7 +237,7 @@ export default function IntlPaymentsPage() {
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||
actionLabel={t('intlPayment.createBtn', 'Visa/Master tölegler (talyplar üçin) dörediň')}
|
||||
onAction={() => navigate('/visa-master-payments/create')}
|
||||
onAction={() => navigate('/visa-master/create')}
|
||||
/>
|
||||
|
||||
<DataTable
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Pencil, Trash2, Download, Search, AlertCircle, CheckCircle2, XCircle }
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { InfoRow } from '@/components/viewPageComponents'
|
||||
import { BentoGrid, BentoCard, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useIntlPayment, useDeleteIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
||||
import type { IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||
|
||||
@@ -30,46 +30,6 @@ function PaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
return <StatusBadge label={t(`intlPayment.status.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: 'grid-cols-1',
|
||||
2: 'grid-cols-1 sm:grid-cols-2',
|
||||
3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3',
|
||||
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: 'full' | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === 'full' ? 'sm:col-span-full' :
|
||||
span === 2 ? 'sm:col-span-2' :
|
||||
span === 3 ? 'sm:col-span-3' : ''
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── DocFile row ──────────────────────────────────────────────────────────────
|
||||
|
||||
function DocFileRow({ label, url }: { label: string; url: string | null }) {
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
BentoGrid,
|
||||
BentoCard,
|
||||
InfoRow,
|
||||
PassportImage,
|
||||
AuditLog,
|
||||
@@ -46,48 +48,6 @@ function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
noPadding,
|
||||
}: {
|
||||
title?: string
|
||||
span?: "full" | 2 | 3
|
||||
children: React.ReactNode
|
||||
noPadding?: boolean
|
||||
}) {
|
||||
const spanClass =
|
||||
span === "full" ? "sm:col-span-full" :
|
||||
span === 2 ? "sm:col-span-2" :
|
||||
span === 3 ? "sm:col-span-3" : ""
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<div className={noPadding ? "" : undefined}>{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function LoanOrderMobilesViewSkeleton() {
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import {
|
||||
BentoGrid,
|
||||
BentoCard,
|
||||
InfoRow,
|
||||
PassportImage,
|
||||
AuditLog,
|
||||
@@ -45,46 +47,6 @@ function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />
|
||||
}
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: "full" | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === "full" ? "sm:col-span-full" :
|
||||
span === 2 ? "sm:col-span-2" :
|
||||
span === 3 ? "sm:col-span-3" : ""
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function LoanOrderViewSkeleton() {
|
||||
|
||||
@@ -13,7 +13,8 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents'
|
||||
import { useCardTypeById, useDeleteCardType } from '@/features/cardTypes/hooks/useCardTypes'
|
||||
|
||||
export function CardTypeViewPage() {
|
||||
@@ -29,7 +30,7 @@ export function CardTypeViewPage() {
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<div>
|
||||
@@ -67,10 +68,10 @@ export function CardTypeViewPage() {
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0"
|
||||
className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border last:border-0 gap-2 sm:gap-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-4 w-40 bg-muted rounded animate-pulse" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -78,29 +79,7 @@ export function CardTypeViewPage() {
|
||||
<Section>
|
||||
<InfoRow label="ID" value={data.id} />
|
||||
|
||||
{/* Multilang name with tabs */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('cardTypes.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div>
|
||||
<div className="flex gap-3 mb-2 justify-end">
|
||||
{(['tk', 'ru', 'en'] as const).map((l) => (
|
||||
<span
|
||||
key={l}
|
||||
className={`text-sm cursor-default ${
|
||||
l === lang
|
||||
? 'text-primary font-semibold underline underline-offset-4'
|
||||
: 'text-muted-foreground'
|
||||
}`}
|
||||
>
|
||||
{l === 'tk' ? 'Türkmen' : l === 'ru' ? 'Русский' : 'English'}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="text-sm text-foreground">{data.name[lang]}</span>
|
||||
</div>
|
||||
</div>
|
||||
<MultiLangRow label={t('cardTypes.fields.name', 'Ady')} value={data.name} />
|
||||
|
||||
<InfoRow label={t('cardTypes.fields.value', 'Baha')} value={data.value} />
|
||||
<InfoRow
|
||||
@@ -108,8 +87,8 @@ export function CardTypeViewPage() {
|
||||
value={data.description ?? undefined}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">
|
||||
{t('cardTypes.fields.isActive', 'Işjeň')}
|
||||
</span>
|
||||
{data.isActive ? (
|
||||
|
||||
@@ -14,7 +14,8 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents'
|
||||
import { useCardReasonById, useDeleteCardReason } from '@/features/cardReasons/hooks/useCardReasons'
|
||||
|
||||
// ─── CardReasonViewPage ────────────────────────────────────────────────────────
|
||||
@@ -32,7 +33,7 @@ export function CardReasonViewPage() {
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div >
|
||||
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<div>
|
||||
@@ -70,10 +71,10 @@ export function CardReasonViewPage() {
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0"
|
||||
className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border last:border-0 gap-2 sm:gap-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-4 w-40 bg-muted rounded animate-pulse" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -81,28 +82,7 @@ export function CardReasonViewPage() {
|
||||
<Section>
|
||||
<InfoRow label="ID" value={data.id} />
|
||||
|
||||
{/* Multilang name tabs */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('CardReasons.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div>
|
||||
{/* Lang switcher is displayed in top-right corner of this cell */}
|
||||
<div className="flex gap-3 mb-2 justify-end">
|
||||
{(['tk', 'ru', 'en'] as const).map((l) => (
|
||||
<span
|
||||
key={l}
|
||||
className={`text-sm cursor-default ${
|
||||
l === lang ? 'text-primary font-semibold underline underline-offset-4' : 'text-muted-foreground'
|
||||
}`}
|
||||
>
|
||||
{l === 'tk' ? 'Türkmen' : l === 'ru' ? 'Русский' : 'English'}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="text-sm text-foreground">{data.name[lang]}</span>
|
||||
</div>
|
||||
</div>
|
||||
<MultiLangRow label={t('CardReasons.fields.name', 'Ady')} value={data.name} />
|
||||
|
||||
<InfoRow
|
||||
label={t('CardReasons.fields.value', 'Baha')}
|
||||
@@ -114,8 +94,8 @@ export function CardReasonViewPage() {
|
||||
/>
|
||||
|
||||
{/* isActive custom row */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">
|
||||
{t('CardReasons.fields.isActive', 'Işjeň')}
|
||||
</span>
|
||||
{data.isActive ? (
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents'
|
||||
import { useGetLoanTypeById, useDeleteLoanType } from '@/features/loanTypes/hooks/useLoanTypes'
|
||||
|
||||
// ─── LoanTypeViewPage ─────────────────────────────────────────────────────────
|
||||
@@ -42,12 +42,12 @@ export default function LoanTypeViewPage() {
|
||||
// ── Skeleton ───────────────────────────────────────────────────────────────
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<Skeleton className="h-4 w-64 mb-4" />
|
||||
<Skeleton className="h-7 w-80 mb-6" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<div key={i} className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center px-4 py-3 gap-2 sm:gap-0">
|
||||
<Skeleton className="h-4 w-20" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
@@ -60,7 +60,7 @@ export default function LoanTypeViewPage() {
|
||||
// ── Error ──────────────────────────────────────────────────────────────────
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="p-6 flex items-center justify-center py-20 text-destructive text-sm">
|
||||
<div className=" flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
)
|
||||
@@ -68,7 +68,7 @@ export default function LoanTypeViewPage() {
|
||||
|
||||
// ── View ───────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div >
|
||||
|
||||
|
||||
{/* Page header */}
|
||||
@@ -102,26 +102,7 @@ export default function LoanTypeViewPage() {
|
||||
<Section>
|
||||
<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">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('loanTypes.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs font-semibold text-muted-foreground w-6">TK</span>
|
||||
<span className="text-sm text-foreground">{data.name.tk}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs font-semibold text-muted-foreground w-6">RU</span>
|
||||
<span className="text-sm text-foreground">{data.name.ru}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs font-semibold text-muted-foreground w-6">EN</span>
|
||||
<span className="text-sm text-foreground">{data.name.en}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<MultiLangRow label={t('loanTypes.fields.name', 'Ady')} value={data.name} />
|
||||
|
||||
<InfoRow
|
||||
label={t('loanTypes.fields.tax', 'Salgyt')}
|
||||
@@ -133,17 +114,17 @@ export default function LoanTypeViewPage() {
|
||||
value={data.loanTerm}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border gap-0.5 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">
|
||||
{t('loanTypes.fields.notes', 'Bellikler')}
|
||||
</span>
|
||||
<span className="text-sm text-foreground">
|
||||
<span className="text-sm text-foreground break-words min-w-0">
|
||||
{data.notes ? data.notes[lang] || '—' : '—'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border last:border-0 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">
|
||||
{t('loanTypes.fields.isActive', 'Işjeň')}
|
||||
</span>
|
||||
{data.isActive ? (
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetRequiredDocumentById, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
@@ -26,7 +27,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="h-12 bg-muted rounded-lg animate-pulse" />
|
||||
<Skeleton key={i} className="h-12 rounded-lg" />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useBranchById, useDeleteBranch } from '@/features/branches/hooks/useBranches'
|
||||
|
||||
@@ -29,7 +30,7 @@ export function BranchViewPage() {
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<div>
|
||||
|
||||
@@ -68,8 +69,8 @@ export function BranchViewPage() {
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-4 w-40 bg-muted rounded animate-pulse" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useDistrictById, useDeleteDistrict } from '@/features/districts/hooks/useDistricts'
|
||||
|
||||
@@ -29,7 +30,7 @@ export function DistrictViewPage() {
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div>
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<div>
|
||||
|
||||
@@ -68,8 +69,8 @@ export function DistrictViewPage() {
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-4 w-40 bg-muted rounded animate-pulse" />
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -14,46 +14,9 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents'
|
||||
import { usePermission, useDeletePermission } from '@/features/permissions/hooks/usePermissions'
|
||||
|
||||
// ─── LangTabs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
type LangKey = 'tk' | 'ru' | 'en'
|
||||
|
||||
function LangTabs({
|
||||
active,
|
||||
onChange,
|
||||
}: {
|
||||
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) => (
|
||||
<button
|
||||
key={tab.key}
|
||||
type="button"
|
||||
onClick={() => onChange(tab.key)}
|
||||
className={`px-3 py-0.5 text-xs font-medium rounded-md transition-colors ${
|
||||
active === tab.key
|
||||
? 'text-primary border-b-2 border-primary'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── PermissionViewPage ───────────────────────────────────────────────────────
|
||||
|
||||
export default function PermissionViewPage() {
|
||||
@@ -62,7 +25,6 @@ export default function PermissionViewPage() {
|
||||
const navigate = useNavigate()
|
||||
const permissionId = Number(id)
|
||||
|
||||
const [activeLang, setActiveLang] = useState<LangKey>('tk')
|
||||
const [showDelete, setShowDelete] = useState(false)
|
||||
|
||||
const { data: permission, isLoading, isError } = usePermission(permissionId)
|
||||
@@ -82,7 +44,7 @@ export default function PermissionViewPage() {
|
||||
<Skeleton className="h-8 w-72 mb-6" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-3 px-4">
|
||||
<div key={i} className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-3 px-4 gap-2 sm:gap-0">
|
||||
<Skeleton className="h-4 w-20" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
@@ -133,18 +95,7 @@ export default function PermissionViewPage() {
|
||||
<InfoRow label={t('common.id', 'ID')} value={permission.id} />
|
||||
<InfoRow label={t('permissions.fields.code', 'Kod')} value={permission.code} />
|
||||
|
||||
{/* Name row — with lang switcher */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('permissions.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div>
|
||||
<LangTabs active={activeLang} onChange={setActiveLang} />
|
||||
<span className="text-sm text-foreground">
|
||||
{permission.name?.[activeLang] || '—'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<MultiLangRow label={t('permissions.fields.name', 'Ady')} value={permission.name} />
|
||||
|
||||
<InfoRow label={t('permissions.fields.guardName', 'Guard name')} value={permission.guard_name} />
|
||||
</Section>
|
||||
|
||||
@@ -14,46 +14,9 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents'
|
||||
import { useRole, useDeleteRole } from '@/features/roles/hooks/useRoles'
|
||||
|
||||
// ─── LangTabs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
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,
|
||||
}: {
|
||||
active: LangKey
|
||||
onChange: (l: LangKey) => void
|
||||
}) {
|
||||
return (
|
||||
<div className="flex gap-1 justify-end mb-2">
|
||||
{LANG_TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.key}
|
||||
type="button"
|
||||
onClick={() => onChange(tab.key)}
|
||||
className={`px-3 py-0.5 text-xs font-medium rounded-md transition-colors ${
|
||||
active === tab.key
|
||||
? 'text-primary border-b-2 border-primary'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── RoleViewPage ─────────────────────────────────────────────────────────────
|
||||
|
||||
export default function RoleViewPage() {
|
||||
@@ -62,7 +25,6 @@ export default function RoleViewPage() {
|
||||
const navigate = useNavigate()
|
||||
const roleId = Number(id)
|
||||
|
||||
const [activeLang, setActiveLang] = useState<LangKey>('tk')
|
||||
const [showDelete, setShowDelete] = useState(false)
|
||||
|
||||
const { data: role, isLoading, isError } = useRole(roleId)
|
||||
@@ -82,7 +44,7 @@ export default function RoleViewPage() {
|
||||
<Skeleton className="h-8 w-72 mb-6" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-3 px-4">
|
||||
<div key={i} className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-3 px-4 gap-2 sm:gap-0">
|
||||
<Skeleton className="h-4 w-20" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
@@ -133,18 +95,7 @@ export default function RoleViewPage() {
|
||||
<InfoRow label="ID" value={role.id} />
|
||||
<InfoRow label={t('roles.fields.code', 'Kod')} value={role.code} />
|
||||
|
||||
{/* Name row — with lang switcher */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('roles.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div>
|
||||
<LangTabs active={activeLang} onChange={setActiveLang} />
|
||||
<span className="text-sm text-foreground">
|
||||
{role.name?.[activeLang] || '—'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<MultiLangRow label={t('roles.fields.name', 'Ady')} value={role.name} />
|
||||
|
||||
<InfoRow label={t('roles.fields.guardName', 'Guard name')} value={role.guard_name} />
|
||||
</Section>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
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 { Pencil, Trash2, CheckCircle2, XCircle, ChevronDown, Plus, Search, SlidersHorizontal, ChevronUp } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -111,8 +112,16 @@ export default function UserViewPage() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Loader2 size={24} className="animate-spin text-muted-foreground" />
|
||||
<div className="p-6 space-y-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -122,7 +131,7 @@ export default function UserViewPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-0">
|
||||
<div className="space-y-0">
|
||||
{/* Title + actions */}
|
||||
<div className="flex items-start justify-between mb-6">
|
||||
<h1 className="text-xl font-bold text-foreground leading-tight">
|
||||
|
||||
@@ -3,53 +3,14 @@ import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, ChevronDown, XCircle, CheckCircle2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import { useClient, useDeleteClient } from '@/features/clients/hooks/useClients'
|
||||
import type { ClientRole, ClientBranch, ClientAuditLog } from '@/features/clients/api/clientsApi'
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: 'grid-cols-1',
|
||||
2: 'grid-cols-1 sm:grid-cols-2',
|
||||
3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3',
|
||||
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
|
||||
}[cols]
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>
|
||||
}
|
||||
|
||||
function BentoCard({
|
||||
title,
|
||||
span,
|
||||
children,
|
||||
}: {
|
||||
title?: string
|
||||
span?: 'full' | 2 | 3
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const spanClass =
|
||||
span === 'full' ? 'sm:col-span-full' :
|
||||
span === 2 ? 'sm:col-span-2' :
|
||||
span === 3 ? 'sm:col-span-3' : ''
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">
|
||||
{title}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
|
||||
function ActiveIndicator({ active }: { active: boolean }) {
|
||||
@@ -232,10 +193,18 @@ export default function ClientDetailPage() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="h-16 bg-muted rounded-xl animate-pulse" />
|
||||
))}
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -260,7 +229,7 @@ export default function ClientDetailPage() {
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="p-6 flex flex-col gap-6">
|
||||
<div className=" flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
|
||||
@@ -3,40 +3,14 @@ import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, ChevronDown, CheckCircle2, XCircle, } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { InfoRow, AuditLog } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog } from "@/components/viewPageComponents";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import { useOperator, useDeleteOperator } from "@/features/operators/hooks/useOperators";
|
||||
import type { OperatorRole, OperatorBranch, OperatorAuditLog } from "@/features/operators/api/operatorsApi";
|
||||
|
||||
// ─── Bento primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) {
|
||||
const colClass = {
|
||||
1: "grid-cols-1",
|
||||
2: "grid-cols-1 sm:grid-cols-2",
|
||||
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
||||
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
||||
}[cols];
|
||||
return <div className={`grid ${colClass} gap-4`}>{children}</div>;
|
||||
}
|
||||
|
||||
function BentoCard({ title, span, children }: { title?: string; span?: "full" | 2 | 3; children: React.ReactNode }) {
|
||||
const spanClass = span === "full" ? "sm:col-span-full" : span === 2 ? "sm:col-span-2" : span === 3 ? "sm:col-span-3" : "";
|
||||
|
||||
return (
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">{title}</p>
|
||||
</div>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── IsActive indicator ───────────────────────────────────────────────────────
|
||||
|
||||
function ActiveIndicator({ active }: { active: boolean }) {
|
||||
@@ -243,10 +217,18 @@ export default function OperatorDetailPage() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="h-16 bg-muted rounded-xl animate-pulse" />
|
||||
))}
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{Array.from({ length: 3 }).map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user