fixed some ui
This commit is contained in:
1 parent
d46c951b7d
commit
a6981e2775
30 files changed
+3093
-3006
No files matched your search
@@ -13,27 +13,158 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Section, InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||
import { 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 }) {
|
||||
return active ? (
|
||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
||||
<path d="M2 6l3 3 5-5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
</span>
|
||||
) : (
|
||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-destructive text-destructive">
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
||||
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── CollapsibleSection ───────────────────────────────────────────────────────
|
||||
|
||||
interface CollapsibleSectionProps {
|
||||
title: string
|
||||
actionLabel: string
|
||||
onAction: () => void
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
function CollapsibleSection({ title, actionLabel, onAction, children }: CollapsibleSectionProps) {
|
||||
const [open, setOpen] = useState(true)
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="flex items-center gap-2 mb-2 cursor-pointer select-none w-fit"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<h2 className="text-base font-semibold text-foreground">{title}</h2>
|
||||
<ChevronDown
|
||||
size={15}
|
||||
className={`text-muted-foreground transition-transform duration-200 ${open ? '' : '-rotate-90'}`}
|
||||
/>
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-primary hover:bg-primary/90 text-primary-foreground h-8 text-xs"
|
||||
onClick={onAction}
|
||||
>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── EmptyState ───────────────────────────────────────────────────────────────
|
||||
|
||||
interface EmptyStateProps {
|
||||
label: string
|
||||
actionLabel: string
|
||||
onAction: () => void
|
||||
}
|
||||
|
||||
function EmptyState({ label, actionLabel, onAction }: EmptyStateProps) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-12 gap-4">
|
||||
<div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center">
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" className="text-muted-foreground">
|
||||
<rect x="4" y="8" width="24" height="18" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M4 13h24" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M10 8V6M22 8V6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
<circle cx="16" cy="20" r="3" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M19 23l2 2" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground text-center">{label}</p>
|
||||
<Button size="sm" variant="outline" className="h-8 text-xs" onClick={onAction}>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function ClientDetailPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const clientId = Number(id)
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const clientId = Number(id)
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteClient()
|
||||
|
||||
const { data: client, isLoading } = useClient(clientId)
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [roleSearch, setRoleSearch] = useState('')
|
||||
const [permSearch, setPermSearch] = useState('')
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [roleSearch, setRoleSearch] = useState('')
|
||||
const [permSearch, setPermSearch] = useState('')
|
||||
const [branchSearch, setBranchSearch] = useState('')
|
||||
const [loanSearch, setLoanSearch] = useState('')
|
||||
const [cardSearch, setCardSearch] = useState('')
|
||||
const [loanSearch, setLoanSearch] = useState('')
|
||||
const [cardSearch, setCardSearch] = useState('')
|
||||
|
||||
// ── Role columns ──────────────────────────────────────────────────────────
|
||||
|
||||
const roleColumns: ColumnDef<ClientRole>[] = [
|
||||
{
|
||||
@@ -71,6 +202,8 @@ export default function ClientDetailPage() {
|
||||
},
|
||||
]
|
||||
|
||||
// ── Branch columns ────────────────────────────────────────────────────────
|
||||
|
||||
const branchColumns: ColumnDef<ClientBranch>[] = [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
@@ -112,6 +245,8 @@ export default function ClientDetailPage() {
|
||||
},
|
||||
]
|
||||
|
||||
// ── Loading ───────────────────────────────────────────────────────────────
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
@@ -125,104 +260,195 @@ export default function ClientDetailPage() {
|
||||
if (!client) return null
|
||||
|
||||
const auditLogs = (client.auditLogs ?? []).map((log: ClientAuditLog) => ({
|
||||
id: String(log.id),
|
||||
id: String(log.id),
|
||||
action: log.actionName,
|
||||
by: log.performedBy,
|
||||
by: log.performedBy,
|
||||
target: log.target,
|
||||
status: log.status,
|
||||
date: log.createdAt,
|
||||
date: log.createdAt,
|
||||
}))
|
||||
|
||||
const filteredRoles = (client.roles ?? []).filter((r) =>
|
||||
r.name.toLowerCase().includes(roleSearch.toLowerCase()) || r.code.toLowerCase().includes(roleSearch.toLowerCase()),
|
||||
const filteredRoles = (client.roles ?? []).filter((r) =>
|
||||
r.name.toLowerCase().includes(roleSearch.toLowerCase()) ||
|
||||
r.code.toLowerCase().includes(roleSearch.toLowerCase()),
|
||||
)
|
||||
|
||||
const filteredBranches = (client.branches ?? []).filter((b) =>
|
||||
b.name.toLowerCase().includes(branchSearch.toLowerCase()),
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
|
||||
<div className="p-6 flex flex-col gap-6">
|
||||
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
{t('clients.detailTitle', 'Müşderi giňişleýin')}: {client.name}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 text-muted-foreground hover:text-destructive" onClick={() => setDeleteOpen(true)}>
|
||||
<Button
|
||||
size="icon" variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 text-muted-foreground hover:text-foreground" onClick={() => navigate(`/clients/${clientId}/edit`)}>
|
||||
<Button
|
||||
size="icon" variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => navigate(`/clients/${clientId}/edit`)}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Section>
|
||||
<InfoRow label="ID" value={client.id} />
|
||||
<InfoRow label={t('clients.fields.username', 'Ulanyjy ady')} value={client.username} />
|
||||
<InfoRow label={t('clients.fields.name', 'Ady')} value={client.name} />
|
||||
<InfoRow label={t('clients.fields.phone', 'Telefon')} value={client.phone ?? '—'} />
|
||||
<InfoRow label={t('clients.fields.email', 'E-poçta')} value={client.email ?? '—'} />
|
||||
<InfoRow label={t('clients.fields.isActive', 'Işjeň')}>
|
||||
{client.isActive ? (
|
||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
||||
<path d="M2 6l3 3 5-5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
</span>
|
||||
) : (
|
||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-destructive text-destructive">
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
||||
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
|
||||
</svg>
|
||||
</span>
|
||||
)}
|
||||
</InfoRow>
|
||||
</Section>
|
||||
{/* ── Row 1: Esasy maglumatlar + Kontakt ──────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t('clients.sections.basic', 'Esasy maglumatlar')}>
|
||||
<InfoRow label="ID" value={client.id} />
|
||||
<InfoRow
|
||||
label={t('clients.fields.username', 'Ulanyjy ady')}
|
||||
value={client.username}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t('clients.fields.name', 'Ady')}
|
||||
value={client.name}
|
||||
/>
|
||||
<InfoRow label={t('clients.fields.isActive', 'Işjeň')}>
|
||||
<ActiveIndicator active={client.isActive} />
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
<CollapsibleSection title={t('clients.sections.roles', 'Rollar')} actionLabel={t('clients.addRole', 'Rol birikdiriň')} onAction={() => {}}>
|
||||
<DataTableToolbar searchValue={roleSearch} onSearchChange={setRoleSearch} searchPlaceholder={t('common.search', 'Gözlemek')} columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
|
||||
{(filteredRoles.length > 0) ? (
|
||||
<BentoCard title={t('clients.sections.contact', 'Kontakt')}>
|
||||
<InfoRow
|
||||
label={t('clients.fields.phone', 'Telefon')}
|
||||
value={client.phone ?? '—'}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t('clients.fields.email', 'E-poçta')}
|
||||
value={client.email ?? '—'}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Rollar ───────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.roles', 'Rollar')}
|
||||
actionLabel={t('clients.addRole', 'Rol birikdiriň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={roleSearch}
|
||||
onSearchChange={setRoleSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
/>
|
||||
{filteredRoles.length > 0 ? (
|
||||
<DataTable columns={roleColumns} data={filteredRoles} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||
) : (
|
||||
<EmptyState label={t('clients.noRoles', 'Berlen kriterýalara Rol gabat gelmedi.')} actionLabel={t('clients.addRole', 'Rol birikdiriň')} onAction={() => {}} />
|
||||
<EmptyState
|
||||
label={t('clients.noRoles', 'Berlen kriterýalara Rol gabat gelmedi.')}
|
||||
actionLabel={t('clients.addRole', 'Rol birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
<CollapsibleSection title={t('clients.sections.permissions', 'Rugsatlar')} actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')} onAction={() => {}}>
|
||||
<DataTableToolbar searchValue={permSearch} onSearchChange={setPermSearch} searchPlaceholder={t('common.search', 'Gözlemek')} columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
|
||||
{(client.permissions ?? []).length === 0 ? (
|
||||
<EmptyState label={t('clients.noPermissions', 'Berlen kriterýalara Rugsat gabat gelmedi.')} actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')} onAction={() => {}} />
|
||||
) : null}
|
||||
{/* ── Rugsatlar ────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.permissions', 'Rugsatlar')}
|
||||
actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={permSearch}
|
||||
onSearchChange={setPermSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
/>
|
||||
{(client.permissions ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t('clients.noPermissions', 'Berlen kriterýalara Rugsat gabat gelmedi.')}
|
||||
actionLabel={t('clients.addPermission', 'Rugsat birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
<CollapsibleSection title={t('clients.sections.branches', 'Şahamçalar')} actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')} onAction={() => {}}>
|
||||
<DataTableToolbar searchValue={branchSearch} onSearchChange={setBranchSearch} searchPlaceholder={t('common.search', 'Gözlemek')} columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
|
||||
{(filteredBranches.length > 0) ? (
|
||||
{/* ── Şahamçalar ───────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.branches', 'Şahamçalar')}
|
||||
actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={branchSearch}
|
||||
onSearchChange={setBranchSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
/>
|
||||
{filteredBranches.length > 0 ? (
|
||||
<DataTable columns={branchColumns} data={filteredBranches} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||
) : (
|
||||
<EmptyState label={t('clients.noBranches', 'Berlen kriterýalara Şahamça gabat gelmedi.')} actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')} onAction={() => {}} />
|
||||
<EmptyState
|
||||
label={t('clients.noBranches', 'Berlen kriterýalara Şahamça gabat gelmedi.')}
|
||||
actionLabel={t('clients.addBranch', 'Şahamça birikdiriň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
<CollapsibleSection title={t('clients.sections.loanOrders', 'Karz sargyt')} actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')} onAction={() => {}}>
|
||||
<DataTableToolbar searchValue={loanSearch} onSearchChange={setLoanSearch} searchPlaceholder={t('common.search', 'Gözlemek')} columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
|
||||
{(client.loanOrders ?? []).length === 0 ? (
|
||||
<EmptyState label={t('clients.noLoanOrders', 'Berlen kriterýalara Karz sargyt gabat gelmedi.')} actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')} onAction={() => {}} />
|
||||
) : null}
|
||||
{/* ── Karz sargyt ──────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.loanOrders', 'Karz sargyt')}
|
||||
actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={loanSearch}
|
||||
onSearchChange={setLoanSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
/>
|
||||
{(client.loanOrders ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t('clients.noLoanOrders', 'Berlen kriterýalara Karz sargyt gabat gelmedi.')}
|
||||
actionLabel={t('clients.addLoanOrder', 'Karz sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
<CollapsibleSection title={t('clients.sections.cardOrders', 'Kart sargyt')} actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')} onAction={() => {}}>
|
||||
<DataTableToolbar searchValue={cardSearch} onSearchChange={setCardSearch} searchPlaceholder={t('common.search', 'Gözlemek')} columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
|
||||
{(client.cardOrders ?? []).length === 0 ? (
|
||||
<EmptyState label={t('clients.noCardOrders', 'Berlen kriterýalara Kart sargyt gabat gelmedi.')} actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')} onAction={() => {}} />
|
||||
) : null}
|
||||
{/* ── Kart sargyt ──────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection
|
||||
title={t('clients.sections.cardOrders', 'Kart sargyt')}
|
||||
actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
>
|
||||
<DataTableToolbar
|
||||
searchValue={cardSearch}
|
||||
onSearchChange={setCardSearch}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={[]} columnVisibility={{}} onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]} onColumnOrderChange={() => {}} hideAction
|
||||
/>
|
||||
{(client.cardOrders ?? []).length === 0 && (
|
||||
<EmptyState
|
||||
label={t('clients.noCardOrders', 'Berlen kriterýalara Kart sargyt gabat gelmedi.')}
|
||||
actionLabel={t('clients.addCardOrder', 'Kart sargyt dörediň')}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
)}
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
{/* ── Delete dialog ────────────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
@@ -233,54 +459,16 @@ export default function ClientDetailPage() {
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction className="bg-destructive hover:bg-destructive/90 text-destructive-foreground" onClick={() => deleteMutation.mutate(clientId, { onSuccess: () => navigate('/clients') })}>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => deleteMutation.mutate(clientId, { onSuccess: () => navigate('/clients') })}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface CollapsibleSectionProps { title: string; actionLabel: string; onAction: () => void; children: React.ReactNode }
|
||||
function CollapsibleSection({ title, actionLabel, onAction, children }: CollapsibleSectionProps) {
|
||||
const [open, setOpen] = useState(true)
|
||||
return (
|
||||
<div className="mb-6">
|
||||
<div className="flex items-center justify-between mb-2 cursor-pointer select-none w-fit gap-2" onClick={() => setOpen((v) => !v)}>
|
||||
<h2 className="text-base font-semibold text-foreground">{title}</h2>
|
||||
<ChevronDown size={15} className={`text-muted-foreground transition-transform duration-200 ${open ? '' : '-rotate-90'}`} />
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
<div className="flex justify-end">
|
||||
<Button size="sm" className="bg-primary hover:bg-primary/90 text-primary-foreground h-8 text-xs" onClick={onAction}>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface EmptyStateProps { label: string; actionLabel: string; onAction: () => void }
|
||||
function EmptyState({ label, actionLabel, onAction }: EmptyStateProps) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-12 gap-4">
|
||||
<div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center">
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" className="text-muted-foreground">
|
||||
<rect x="4" y="8" width="24" height="18" rx="2" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M4 13h24" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M10 8V6M22 8V6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
<circle cx="16" cy="20" r="3" stroke="currentColor" strokeWidth="1.5" />
|
||||
<path d="M19 23l2 2" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground text-center">{label}</p>
|
||||
<Button size="sm" variant="outline" className="h-8 text-xs" onClick={onAction}>{actionLabel}</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user