refactored code, fixed checkbox
This commit is contained in:
1 parent
4adc153503
commit
d56620be2e
16 files changed
+640
-267
No files matched your search
@@ -127,6 +127,8 @@ const DistrictsViewPage = lazy(() => import("@/pages/settings/location/districts
|
|||||||
const DistrictEditPage = lazy(() => import("@/pages/settings/location/districtsEdit"));
|
const DistrictEditPage = lazy(() => import("@/pages/settings/location/districtsEdit"));
|
||||||
|
|
||||||
const BranchesPage = lazy(() => import("@/pages/settings/location/branches"));
|
const BranchesPage = lazy(() => import("@/pages/settings/location/branches"));
|
||||||
|
|
||||||
|
const BackupsPage = lazy(() => import("@/pages/backups"));
|
||||||
const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate"));
|
const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate"));
|
||||||
const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView"));
|
const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView"));
|
||||||
const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit"));
|
const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit"));
|
||||||
@@ -949,6 +951,15 @@ export const router = createBrowserRouter([
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Sidebar: /backups
|
||||||
|
path: "/backups",
|
||||||
|
element: (
|
||||||
|
<Suspense fallback={<PageLoader />}>
|
||||||
|
<BackupsPage />
|
||||||
|
</Suspense>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Sidebar: /settings/location/branches
|
// Sidebar: /settings/location/branches
|
||||||
path: "/settings/location/branches",
|
path: "/settings/location/branches",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function CreditCardVisual({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`${bgGradient} w-full max-w-[340px] h-[210px] rounded-2xl p-6 flex flex-col justify-between text-white shadow-xl relative overflow-hidden`}
|
className={`${bgGradient} w-full max-w-[360px] h-[210px] rounded-2xl p-6 flex flex-col justify-between text-white shadow-xl relative overflow-hidden`}
|
||||||
>
|
>
|
||||||
{/* Glow effects */}
|
{/* Glow effects */}
|
||||||
<div className="absolute -top-16 -right-16 w-32 h-32 bg-white/10 rounded-full blur-2xl pointer-events-none"></div>
|
<div className="absolute -top-16 -right-16 w-32 h-32 bg-white/10 rounded-full blur-2xl pointer-events-none"></div>
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ interface SelectAllDropdownProps {
|
|||||||
isAllTotalSelected: boolean
|
isAllTotalSelected: boolean
|
||||||
totalCount: number
|
totalCount: number
|
||||||
pageCount: number
|
pageCount: number
|
||||||
onSelectPage: (checked: boolean) => void
|
onTogglePage: (checked: boolean) => void
|
||||||
|
onSelectThisPage: () => void
|
||||||
onSelectAll: () => void
|
onSelectAll: () => void
|
||||||
onClearAll: () => void
|
onClearAll: () => void
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,8 @@ function SelectAllDropdown({
|
|||||||
isAllTotalSelected,
|
isAllTotalSelected,
|
||||||
totalCount,
|
totalCount,
|
||||||
pageCount,
|
pageCount,
|
||||||
onSelectPage,
|
onTogglePage,
|
||||||
|
onSelectThisPage,
|
||||||
onSelectAll,
|
onSelectAll,
|
||||||
onClearAll,
|
onClearAll,
|
||||||
}: SelectAllDropdownProps) {
|
}: SelectAllDropdownProps) {
|
||||||
@@ -143,28 +145,42 @@ function SelectAllDropdown({
|
|||||||
const ref = useRef<HTMLDivElement>(null)
|
const ref = useRef<HTMLDivElement>(null)
|
||||||
useOutsideClick(ref, () => setOpen(false))
|
useOutsideClick(ref, () => setOpen(false))
|
||||||
|
|
||||||
const checkboxChecked = isAllPageSelected || (isSomePageSelected && 'indeterminate')
|
const checkboxChecked = isAllTotalSelected || isAllPageSelected
|
||||||
|
? true
|
||||||
|
: isSomePageSelected
|
||||||
|
? 'indeterminate'
|
||||||
|
: false
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={ref} className="flex items-center gap-0.5">
|
<div ref={ref} className="flex items-center gap-1">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={checkboxChecked as boolean | 'indeterminate'}
|
checked={checkboxChecked}
|
||||||
onCheckedChange={(value) => onSelectPage(!!value)}
|
onCheckedChange={(value) => onTogglePage(!!value)}
|
||||||
aria-label="Select all on page"
|
aria-label="Select all on page"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
className="after:content-none"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => setOpen((v) => !v)}
|
type="button"
|
||||||
className="flex items-center text-muted-foreground hover:text-foreground transition-colors p-0.5"
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
setOpen((v) => !v)
|
||||||
|
}}
|
||||||
|
className="relative z-10 flex items-center justify-center w-5 h-5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors rounded"
|
||||||
aria-label="Selection options"
|
aria-label="Selection options"
|
||||||
>
|
>
|
||||||
<ChevronDown size={11} />
|
<ChevronDown size={12} />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{open && (
|
{open && (
|
||||||
<div className="absolute top-10 left-0 z-50 w-52 bg-card border border-border rounded-md shadow-lg py-1">
|
<div className="absolute top-8 left-0 z-50 w-52 bg-card border border-border rounded-md shadow-lg py-1">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
type="button"
|
||||||
onSelectPage(true)
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
onSelectThisPage()
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}}
|
}}
|
||||||
className="w-full text-left px-3 py-2 text-sm hover:bg-muted/50 transition-colors"
|
className="w-full text-left px-3 py-2 text-sm hover:bg-muted/50 transition-colors"
|
||||||
@@ -173,7 +189,10 @@ function SelectAllDropdown({
|
|||||||
<span className="ml-1 text-muted-foreground text-xs">({pageCount})</span>
|
<span className="ml-1 text-muted-foreground text-xs">({pageCount})</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
type="button"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
onSelectAll()
|
onSelectAll()
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}}
|
}}
|
||||||
@@ -186,7 +205,10 @@ function SelectAllDropdown({
|
|||||||
<>
|
<>
|
||||||
<div className="border-t border-border my-1" />
|
<div className="border-t border-border my-1" />
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
type="button"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
onClearAll()
|
onClearAll()
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}}
|
}}
|
||||||
@@ -257,9 +279,18 @@ export function DataTable<TData>({
|
|||||||
isAllTotalSelected={allTotalSelected}
|
isAllTotalSelected={allTotalSelected}
|
||||||
totalCount={resolvedTotalCount}
|
totalCount={resolvedTotalCount}
|
||||||
pageCount={data.length}
|
pageCount={data.length}
|
||||||
onSelectPage={(checked) => {
|
onTogglePage={(checked) => {
|
||||||
table.toggleAllPageRowsSelected(checked)
|
if (!checked) {
|
||||||
if (!checked) setAllTotalSelected(false)
|
if (allTotalSelected) setAllTotalSelected(false)
|
||||||
|
table.toggleAllPageRowsSelected(false)
|
||||||
|
table.setRowSelection({})
|
||||||
|
} else {
|
||||||
|
table.toggleAllPageRowsSelected(true)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onSelectThisPage={() => {
|
||||||
|
table.toggleAllPageRowsSelected(true)
|
||||||
|
setAllTotalSelected(false)
|
||||||
}}
|
}}
|
||||||
onSelectAll={() => {
|
onSelectAll={() => {
|
||||||
table.toggleAllPageRowsSelected(true)
|
table.toggleAllPageRowsSelected(true)
|
||||||
@@ -267,19 +298,36 @@ export function DataTable<TData>({
|
|||||||
}}
|
}}
|
||||||
onClearAll={() => {
|
onClearAll={() => {
|
||||||
table.toggleAllPageRowsSelected(false)
|
table.toggleAllPageRowsSelected(false)
|
||||||
|
table.setRowSelection({})
|
||||||
setAllTotalSelected(false)
|
setAllTotalSelected(false)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => (
|
cell: ({ row, table }) => {
|
||||||
<Checkbox
|
const isSelected = allTotalSelected || row.getIsSelected()
|
||||||
checked={row.getIsSelected()}
|
return (
|
||||||
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
<Checkbox
|
||||||
aria-label="Select row"
|
checked={isSelected}
|
||||||
onClick={(e) => e.stopPropagation()}
|
onCheckedChange={(value) => {
|
||||||
/>
|
if (allTotalSelected && !value) {
|
||||||
),
|
const newSelection: RowSelectionState = {}
|
||||||
|
table.getRowModel().rows.forEach((r) => {
|
||||||
|
if (r.id !== row.id) {
|
||||||
|
newSelection[r.id] = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
table.setRowSelection(newSelection)
|
||||||
|
setAllTotalSelected(false)
|
||||||
|
} else {
|
||||||
|
row.toggleSelected(!!value)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
aria-label="Select row"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
size: 48,
|
size: 48,
|
||||||
@@ -357,6 +405,7 @@ export function DataTable<TData>({
|
|||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
table.toggleAllPageRowsSelected(false)
|
table.toggleAllPageRowsSelected(false)
|
||||||
|
table.setRowSelection({})
|
||||||
setAllTotalSelected(false)
|
setAllTotalSelected(false)
|
||||||
}}
|
}}
|
||||||
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
|
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import apiClient from '@/lib/api/client'
|
||||||
|
|
||||||
|
export type BackupStatus = 'completed' | 'failed' | 'in_progress'
|
||||||
|
|
||||||
|
export interface Backup {
|
||||||
|
id: number
|
||||||
|
fileName: string
|
||||||
|
fileSize: string
|
||||||
|
status: BackupStatus
|
||||||
|
createdAt: string
|
||||||
|
createdBy: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BackupListResponse {
|
||||||
|
data: Backup[]
|
||||||
|
total: number
|
||||||
|
page: number
|
||||||
|
per_page: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BackupListParams {
|
||||||
|
page?: number
|
||||||
|
per_page?: number
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const MOCK_BACKUPS: Backup[] = [
|
||||||
|
{ id: 1, fileName: 'backup_2026_05_22_01.sql', fileSize: '256 MB', status: 'completed', createdAt: '2026-05-22 03:00', createdBy: 'Admin' },
|
||||||
|
{ id: 2, fileName: 'backup_2026_05_21_01.sql', fileSize: '251 MB', status: 'completed', createdAt: '2026-05-21 03:00', createdBy: 'Admin' },
|
||||||
|
{ id: 3, fileName: 'backup_2026_05_20_01.sql', fileSize: '248 MB', status: 'completed', createdAt: '2026-05-20 03:00', createdBy: 'Admin' },
|
||||||
|
{ id: 4, fileName: 'backup_2026_05_19_01.sql', fileSize: '245 MB', status: 'failed', createdAt: '2026-05-19 03:05', createdBy: 'Admin' },
|
||||||
|
{ id: 5, fileName: 'backup_2026_05_18_01.sql', fileSize: '242 MB', status: 'completed', createdAt: '2026-05-18 03:00', createdBy: 'System' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const backupsApi = {
|
||||||
|
getAll: async (params?: BackupListParams): Promise<BackupListResponse> => {
|
||||||
|
const { data } = await apiClient.get('/backups', { params }).catch(() => ({ data: null }))
|
||||||
|
if (data) return data
|
||||||
|
|
||||||
|
const { search = '', page = 1, per_page = 25 } = params ?? {}
|
||||||
|
let filtered = [...MOCK_BACKUPS]
|
||||||
|
if (search) {
|
||||||
|
const s = search.toLowerCase()
|
||||||
|
filtered = filtered.filter((b) => b.fileName.toLowerCase().includes(s))
|
||||||
|
}
|
||||||
|
const total = filtered.length
|
||||||
|
const start = (page - 1) * per_page
|
||||||
|
return { data: filtered.slice(start, start + per_page), total, page, per_page }
|
||||||
|
},
|
||||||
|
|
||||||
|
create: async (): Promise<Backup> => {
|
||||||
|
const { data } = await apiClient.post('/backups').catch(() => ({ data: null }))
|
||||||
|
if (data) return data
|
||||||
|
|
||||||
|
const newBackup: Backup = {
|
||||||
|
id: Math.floor(Math.random() * 10000),
|
||||||
|
fileName: `backup_${new Date().toISOString().slice(0, 10).replace(/-/g, '_')}_01.sql`,
|
||||||
|
fileSize: '0 MB',
|
||||||
|
status: 'in_progress',
|
||||||
|
createdAt: new Date().toLocaleString('tr-TR'),
|
||||||
|
createdBy: 'Admin',
|
||||||
|
}
|
||||||
|
MOCK_BACKUPS.unshift(newBackup)
|
||||||
|
return newBackup
|
||||||
|
},
|
||||||
|
|
||||||
|
download: async (id: number): Promise<Blob> => {
|
||||||
|
const { data } = await apiClient.get(`/backups/${id}/download`, { responseType: 'blob' }).catch(() => ({ data: null }))
|
||||||
|
if (data) return data
|
||||||
|
return new Blob(['mock backup content'], { type: 'application/sql' })
|
||||||
|
},
|
||||||
|
|
||||||
|
delete: async (id: number): Promise<void> => {
|
||||||
|
await apiClient.delete(`/backups/${id}`).catch(() => {})
|
||||||
|
const index = MOCK_BACKUPS.findIndex((b) => b.id === id)
|
||||||
|
if (index !== -1) MOCK_BACKUPS.splice(index, 1)
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { backupsApi, type BackupListParams } from '../api/backupsApi'
|
||||||
|
|
||||||
|
const QUERY_KEY = 'backups'
|
||||||
|
|
||||||
|
export function useBackups(params?: BackupListParams) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: [QUERY_KEY, params],
|
||||||
|
queryFn: () => backupsApi.getAll(params),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreateBackup() {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: () => backupsApi.create(),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||||
|
toast.success(t('backups.toast.created', 'Backup üstünlikli döredildi!'))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDownloadBackup() {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async (id: number) => {
|
||||||
|
const blob = await backupsApi.download(id)
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = url
|
||||||
|
a.download = `backup-${id}.sql`
|
||||||
|
a.click()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success(t('backups.toast.downloaded', 'Backup üstünlikli ýüklenildi'))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDeleteBackup() {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (id: number) => backupsApi.delete(id),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||||
|
toast.success(t('backups.toast.deleted', 'Backup üstünlikli pozuldy!'))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -121,7 +121,7 @@ export function CurrencyRateForm({ mode, initialData }: CurrencyRateFormProps) {
|
|||||||
? t('currencyRates.createTitle', 'Walýuta kursy dörediň')
|
? t('currencyRates.createTitle', 'Walýuta kursy dörediň')
|
||||||
: t('currencyRates.editTitle', 'Walýuta kursy üýtgetmek')}
|
: t('currencyRates.editTitle', 'Walýuta kursy üýtgetmek')}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6 bg-card border border-border rounded-xl overflow-hidden">
|
||||||
{/* Currency From */}
|
{/* Currency From */}
|
||||||
<div className="grid grid-cols-[220px_1fr] items-start py-4 px-6 border-b border-border">
|
<div className="grid grid-cols-[220px_1fr] items-start py-4 px-6 border-b border-border">
|
||||||
<label className="text-sm text-muted-foreground pt-1.5">
|
<label className="text-sm text-muted-foreground pt-1.5">
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export function VisaMasterSettingForm({
|
|||||||
? t('visaMasterSettings.createTitle', 'Visa/Master, Sber sazlamalar dörediň')
|
? t('visaMasterSettings.createTitle', 'Visa/Master, Sber sazlamalar dörediň')
|
||||||
: t('visaMasterSettings.editTitle', 'Visa/Master, Sber sazlamalar üýtgetmek')}
|
: t('visaMasterSettings.editTitle', 'Visa/Master, Sber sazlamalar üýtgetmek')}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="space-y-0">
|
<div className="space-y-0 bg-card border border-border rounded-xl overflow-hidden">
|
||||||
{/* Kod */}
|
{/* Kod */}
|
||||||
<div className="grid grid-cols-[220px_1fr] items-start py-4 px-6 border-b border-border">
|
<div className="grid grid-cols-[220px_1fr] items-start py-4 px-6 border-b border-border">
|
||||||
<label className="text-sm text-muted-foreground pt-1.5">
|
<label className="text-sm text-muted-foreground pt-1.5">
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Download, Trash2, Database, CheckCircle2, XCircle, Clock } from 'lucide-react'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogAction,
|
||||||
|
AlertDialogCancel,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
} from '@/components/ui/alert-dialog'
|
||||||
|
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||||
|
import { DataTableToolbar, type ColumnMeta } from '@/components/dataTableToolbar'
|
||||||
|
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||||
|
import type { VisibilityState } from '@tanstack/react-table'
|
||||||
|
import { useBackups, useCreateBackup, useDeleteBackup, useDownloadBackup } from '@/features/backups/hooks/useBackups'
|
||||||
|
import type { Backup, BackupStatus } from '@/features/backups/api/backupsApi'
|
||||||
|
|
||||||
|
const PER_PAGE = 25
|
||||||
|
|
||||||
|
const STATUS_CONFIG: Record<BackupStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||||
|
completed: { label: 'Tamamlandy', variant: 'success', icon: CheckCircle2 },
|
||||||
|
failed: { label: 'Şowsuz', variant: 'error', icon: XCircle },
|
||||||
|
in_progress: { label: 'Dowam edýär', variant: 'warning', icon: Clock },
|
||||||
|
}
|
||||||
|
|
||||||
|
function BackupStatusBadge({ status }: { status: BackupStatus }) {
|
||||||
|
const cfg = STATUS_CONFIG[status]
|
||||||
|
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function BackupsPage() {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [perPage, setPerPage] = useState(PER_PAGE)
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const [deleteId, setDeleteId] = useState<number | null>(null)
|
||||||
|
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({})
|
||||||
|
const [columnOrder, setColumnOrder] = useState<string[]>([])
|
||||||
|
|
||||||
|
const { data, isLoading } = useBackups({ page, per_page: perPage, search })
|
||||||
|
const createBackup = useCreateBackup()
|
||||||
|
const downloadBackup = useDownloadBackup()
|
||||||
|
const deleteBackup = useDeleteBackup()
|
||||||
|
|
||||||
|
const columns: ColumnDef<Backup>[] = [
|
||||||
|
{
|
||||||
|
id: 'fileName',
|
||||||
|
accessorKey: 'fileName',
|
||||||
|
header: t('backups.col.fileName', 'Faýl ady'),
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<span className="font-mono text-sm">{row.original.fileName}</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'fileSize',
|
||||||
|
accessorKey: 'fileSize',
|
||||||
|
header: t('backups.col.fileSize', 'Ölçegi'),
|
||||||
|
cell: ({ row }) => <span>{row.original.fileSize}</span>,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'status',
|
||||||
|
accessorKey: 'status',
|
||||||
|
header: t('backups.col.status', 'Status'),
|
||||||
|
cell: ({ row }) => <BackupStatusBadge status={row.original.status} />,
|
||||||
|
size: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'createdAt',
|
||||||
|
accessorKey: 'createdAt',
|
||||||
|
header: t('backups.col.createdAt', 'Döredilen wagty'),
|
||||||
|
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.createdAt}</span>,
|
||||||
|
size: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'createdBy',
|
||||||
|
accessorKey: 'createdBy',
|
||||||
|
header: t('backups.col.createdBy', 'Döreden'),
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'actions',
|
||||||
|
header: '',
|
||||||
|
enableHiding: false,
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className="flex items-center gap-1 justify-end">
|
||||||
|
<Button
|
||||||
|
variant="ghost" size="icon" className="h-7 w-7"
|
||||||
|
onClick={() => downloadBackup.mutate(row.original.id)}
|
||||||
|
disabled={row.original.status === 'in_progress'}
|
||||||
|
title={t('common.download', 'Ýükle')}
|
||||||
|
>
|
||||||
|
<Download size={14} />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost" size="icon"
|
||||||
|
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||||
|
onClick={() => setDeleteId(row.original.id)}
|
||||||
|
title={t('common.delete', 'Poz')}
|
||||||
|
>
|
||||||
|
<Trash2 size={14} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const columnMeta: ColumnMeta[] = columns
|
||||||
|
.filter((c) => c.id !== 'actions')
|
||||||
|
.map((c) => ({
|
||||||
|
id: c.id!,
|
||||||
|
label: typeof c.header === 'string' ? c.header : c.id!,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const total = data?.total ?? 0
|
||||||
|
const totalPages = Math.ceil(total / perPage)
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
if (deleteId === null) return
|
||||||
|
await deleteBackup.mutateAsync(deleteId)
|
||||||
|
setDeleteId(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<h1 className="text-xl font-semibold text-foreground flex items-center gap-2">
|
||||||
|
<Database className="size-5 text-muted-foreground" />
|
||||||
|
{t('backups.title', 'Bekaplar')}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="bg-card border border-border rounded-xl p-4">
|
||||||
|
<DataTableToolbar
|
||||||
|
searchValue={search}
|
||||||
|
onSearchChange={(v) => { setSearch(v); setPage(1) }}
|
||||||
|
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||||
|
columns={columnMeta}
|
||||||
|
columnVisibility={columnVisibility}
|
||||||
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
|
columnOrder={columnOrder}
|
||||||
|
onColumnOrderChange={setColumnOrder}
|
||||||
|
perPageOptions={[10, 25, 50, 100]}
|
||||||
|
perPage={perPage}
|
||||||
|
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||||
|
actionLabel={createBackup.isPending ? t('common.loading', 'Döredilýär...') : t('backups.create', 'Backup dörediň')}
|
||||||
|
onAction={() => createBackup.mutate()}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DataTable
|
||||||
|
columns={columns}
|
||||||
|
data={data?.data ?? []}
|
||||||
|
isLoading={isLoading}
|
||||||
|
columnVisibility={columnVisibility}
|
||||||
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
|
columnOrder={columnOrder}
|
||||||
|
onColumnOrderChange={setColumnOrder}
|
||||||
|
enableRowSelection
|
||||||
|
getRowId={(row) => String(row.id)}
|
||||||
|
currentPage={page}
|
||||||
|
totalPages={totalPages}
|
||||||
|
totalCount={total}
|
||||||
|
onPageChange={setPage}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<AlertDialog open={deleteId !== null} onOpenChange={(open) => !open && setDeleteId(null)}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>{t('backups.deleteConfirm.title', 'Eminsiňizmi?')}</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
{t('backups.deleteConfirm.description', 'Bu backup pozulsynmy? Bu amal yzyna gaýtarylmaz.')}
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||||
|
<AlertDialogAction
|
||||||
|
onClick={handleDelete}
|
||||||
|
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||||
|
>
|
||||||
|
{deleteBackup.isPending ? t('common.deleting', 'Pozulýar...') : t('common.delete', 'Poz')}
|
||||||
|
</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
import { useState } from "react";
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Trash2, Pencil, DownloadCloud } from "lucide-react";
|
import {
|
||||||
import { Button } from "@/components/ui/button";
|
useCardRequisite,
|
||||||
|
useDeleteCardRequisite,
|
||||||
|
useDownloadCardRequisite,
|
||||||
|
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||||
|
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
import { Button } from "@/components/ui/button";
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
import { Pencil, Trash2, Download } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -15,268 +18,262 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
|
AlertDialogTrigger,
|
||||||
} from "@/components/ui/alert-dialog";
|
} from "@/components/ui/alert-dialog";
|
||||||
import {
|
import {
|
||||||
useCardRequisite,
|
StatusBadge,
|
||||||
useDeleteCardRequisite,
|
type StatusBadgeVariant,
|
||||||
useDownloadCardRequisite,
|
} from "@/components/ui/statusBadge";
|
||||||
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
import { InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||||
import { InfoRow } from "@/components/viewPageComponents";
|
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status config ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_VARIANT: Record<CardRequisiteStatus, StatusBadgeVariant> = {
|
const STATUS_VARIANT: Record<CardRequisiteStatus, StatusBadgeVariant> = {
|
||||||
pending: "warning",
|
pending: "warning",
|
||||||
approved: "success",
|
approved: "success",
|
||||||
rejected: "error",
|
rejected: "error",
|
||||||
};
|
}
|
||||||
|
|
||||||
const STATUS_ICON: Record<CardRequisiteStatus, React.ElementType> = {
|
const STATUS_ICON: Record<CardRequisiteStatus, React.ElementType> = {
|
||||||
pending: AlertCircle,
|
pending: AlertCircle,
|
||||||
approved: CheckCircle2,
|
approved: CheckCircle2,
|
||||||
rejected: XCircle,
|
rejected: XCircle,
|
||||||
};
|
}
|
||||||
|
|
||||||
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation()
|
||||||
const variant = STATUS_VARIANT[status];
|
const variant = STATUS_VARIANT[status]
|
||||||
const Icon = STATUS_ICON[status];
|
const Icon = STATUS_ICON[status]
|
||||||
if (!variant)
|
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||||
return <span className="text-xs text-muted-foreground">{status}</span>;
|
return <StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
|
||||||
return (
|
|
||||||
<StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Section header ───────────────────────────────────────────────────────────
|
// ─── 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" : ""
|
||||||
|
|
||||||
function SectionTitle({ children }: { children: React.ReactNode }) {
|
|
||||||
return (
|
return (
|
||||||
<h2 className="text-base font-semibold text-foreground mt-6 mb-3">
|
<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}
|
{children}
|
||||||
</h2>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Passport image row ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function PassportImageRow({ label, url }: { label: string; url?: string }) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-[220px_1fr] border-b border-border/50 last:border-0">
|
|
||||||
<div className="px-4 py-3 text-sm text-muted-foreground font-medium bg-muted/10">
|
|
||||||
{label}
|
|
||||||
</div>
|
|
||||||
<div className="px-4 py-4 flex flex-col gap-2">
|
|
||||||
{url ? (
|
|
||||||
<>
|
|
||||||
<img
|
|
||||||
src={url}
|
|
||||||
alt={label}
|
|
||||||
className="max-w-[200px] rounded-md border border-border object-cover"
|
|
||||||
/>
|
|
||||||
<a
|
|
||||||
href={url}
|
|
||||||
download
|
|
||||||
className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
|
|
||||||
>
|
|
||||||
<DownloadCloud size={13} />
|
|
||||||
{t("Download", "Göçürip al")}
|
|
||||||
</a>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<span className="text-muted-foreground text-sm">—</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function CardRequisiteViewPage() {
|
export default function CardRequisiteViewPage() {
|
||||||
const { t } = useTranslation();
|
const { id } = useParams<{ id: string }>()
|
||||||
const { id } = useParams<{ id: string }>();
|
const navigate = useNavigate()
|
||||||
const navigate = useNavigate();
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const { data, isLoading, isError } = useCardRequisite(id ?? "")
|
||||||
|
const deleteMutation = useDeleteCardRequisite()
|
||||||
const { data, isLoading } = useCardRequisite(id ?? "");
|
const downloadMutation = useDownloadCardRequisite()
|
||||||
const deleteMutation = useDeleteCardRequisite();
|
|
||||||
const downloadMutation = useDownloadCardRequisite();
|
|
||||||
|
|
||||||
const handleDelete = async () => {
|
|
||||||
await deleteMutation.mutateAsync(id ?? "");
|
|
||||||
navigate("/card-requisites");
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-24">
|
<div className="flex items-center justify-center py-24">
|
||||||
<Spinner className="size-7 text-primary" />
|
<Spinner className="size-8 text-primary" />
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (isError || !data) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center py-24 text-muted-foreground">
|
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||||
{t("Not found", "Tapylmady")}
|
{t("common.notFound", "Maglumat tapylmady")}
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-0">
|
<div className="mx-auto flex flex-col gap-6">
|
||||||
{/* Header */}
|
|
||||||
<div className="flex items-center justify-between mb-4">
|
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<div className="flex items-start justify-between">
|
||||||
{t("Card requisite detail", "Kart rekwizit giňişleýin")}: {data.id}
|
<h1 className="text-xl font-bold text-foreground">
|
||||||
|
{t("cardRequisite.viewTitle", "Kart rekwizit giňişleýin")}: {data.id}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
size="icon" variant="ghost"
|
||||||
size="sm"
|
className="h-8 w-8"
|
||||||
onClick={() => downloadMutation.mutate(data.id)}
|
onClick={() => downloadMutation.mutate(data.id)}
|
||||||
disabled={downloadMutation.isPending}
|
disabled={downloadMutation.isPending}
|
||||||
>
|
>
|
||||||
<Download size={14} />
|
<Download size={15} />
|
||||||
</Button>
|
</Button>
|
||||||
|
<AlertDialog>
|
||||||
|
<AlertDialogTrigger asChild>
|
||||||
|
<Button
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||||
|
>
|
||||||
|
<Trash2 size={15} />
|
||||||
|
</Button>
|
||||||
|
</AlertDialogTrigger>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>
|
||||||
|
{t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||||
|
</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
{t("cardRequisite.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} {data.id}
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel disabled={deleteMutation.isPending}>
|
||||||
|
{t("common.cancel", "Ýatyr")}
|
||||||
|
</AlertDialogCancel>
|
||||||
|
<AlertDialogAction
|
||||||
|
disabled={deleteMutation.isPending}
|
||||||
|
className="bg-destructive hover:bg-destructive/90"
|
||||||
|
onClick={() => deleteMutation.mutate(data.id, { onSuccess: () => navigate("/card-requisites") })}
|
||||||
|
>
|
||||||
|
{t("common.delete", "Poz")}
|
||||||
|
</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
size="icon" variant="ghost" className="h-8 w-8"
|
||||||
size="sm"
|
onClick={() => navigate(`/card-requisites/${id}/edit`)}
|
||||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteOpen(true)}
|
|
||||||
>
|
>
|
||||||
<Trash2 size={14} />
|
<Pencil size={15} />
|
||||||
</Button>
|
|
||||||
<Button variant="outline" size="sm" asChild>
|
|
||||||
<Link to={`/card-requisites/${data.id}/edit`}>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</Link>
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* General info */}
|
{/* ── Row 1: Meta + Kart + Lokasiýa ────────────────────────────────── */}
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<BentoGrid cols={3}>
|
||||||
<InfoRow label={t("ID", "ID")}>{data.id}</InfoRow>
|
<BentoCard title={t("cardRequisite.metaSection", "Esasy maglumatlar")}>
|
||||||
<InfoRow label={t("Created at", "Döredilen wagty")}>
|
<InfoRow label={t("common.id", "ID")}>
|
||||||
{data.created_at}
|
<span className="font-mono">{data.id}</span>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t("Status", "Status")}>
|
<InfoRow label={t("cardRequisite.createdAt", "Döredilen wagty")}>
|
||||||
<CardRequisiteStatusBadge status={data.status} />
|
{data.created_at}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t("Note", "Bellik")}>{data.note || "—"}</InfoRow>
|
<InfoRow label={t("cardRequisite.status", "Status")}>
|
||||||
<InfoRow label={t("Requested by", "Sargyt eden:")}>
|
<CardRequisiteStatusBadge status={data.status} />
|
||||||
{data.first_name && data.last_name ? (
|
</InfoRow>
|
||||||
<span className="text-primary font-medium">
|
<InfoRow label={t("cardRequisite.note", "Bellik")}>
|
||||||
{data.last_name}_{data.first_name} ({data.first_name})
|
{data.note || "—"}
|
||||||
</span>
|
</InfoRow>
|
||||||
) : (
|
<InfoRow label={t("cardRequisite.createdBy", "Sargyt eden")}>
|
||||||
"—"
|
{data.first_name && data.last_name ? (
|
||||||
)}
|
<span className="text-primary font-medium">
|
||||||
</InfoRow>
|
{data.last_name}_{data.first_name}
|
||||||
</div>
|
</span>
|
||||||
|
) : "—"}
|
||||||
|
</InfoRow>
|
||||||
|
</BentoCard>
|
||||||
|
|
||||||
{/* Card */}
|
<BentoCard title={t("cardRequisite.cardSection", "Kart")}>
|
||||||
<SectionTitle>{t("Card", "Kart")}</SectionTitle>
|
<InfoRow label={t("cardRequisite.cardNumber", "Kart belgisi")}>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
<span className="font-mono tracking-wider">{data.card_number}</span>
|
||||||
<InfoRow label={t("Card number", "Kart belgisi")}>
|
</InfoRow>
|
||||||
{data.card_number}
|
<InfoRow label={t("cardRequisite.cardExpireMonth", "Kart Möhleti (aý)")}>
|
||||||
</InfoRow>
|
{data.card_expiry_month}
|
||||||
<InfoRow label={t("Card expiry month", "Kart Möhleti (aý)")}>
|
</InfoRow>
|
||||||
{data.card_expiry_month}
|
<InfoRow label={t("cardRequisite.cardExpireYear", "Kart Möhleti (ýyl)")}>
|
||||||
</InfoRow>
|
{data.card_expiry_year}
|
||||||
<InfoRow label={t("Card expiry year", "Kart Möhleti (ýyl)")}>
|
</InfoRow>
|
||||||
{data.card_expiry_year}
|
</BentoCard>
|
||||||
</InfoRow>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Location */}
|
<BentoCard title={t("cardRequisite.locationSection", "Lokasiýa")}>
|
||||||
<SectionTitle>{t("Location", "Lokasiýa")}</SectionTitle>
|
<InfoRow label={t("cardRequisite.province", "Welaýat")}>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
{data.province_name ?? "—"}
|
||||||
<InfoRow label={t("Province", "Welaýat")}>
|
</InfoRow>
|
||||||
{data.province_name ?? "—"}
|
<InfoRow label={t("cardRequisite.branch", "Şahamça")}>
|
||||||
</InfoRow>
|
<span className="text-primary font-medium">{data.branch_name ?? "—"}</span>
|
||||||
<InfoRow label={t("Branch", "Şahamça")}>
|
</InfoRow>
|
||||||
<span className="text-primary font-medium">
|
</BentoCard>
|
||||||
{data.branch_name ?? "—"}
|
</BentoGrid>
|
||||||
</span>
|
|
||||||
</InfoRow>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Personal */}
|
{/* ── Row 2: Şahsy + Pasport maglumatlary ──────────────────────────── */}
|
||||||
<SectionTitle>
|
<BentoGrid cols={2}>
|
||||||
{t("Personal information", "Şahsy maglumatlar")}
|
<BentoCard title={t("cardRequisite.personalSection", "Şahsy maglumatlar")}>
|
||||||
</SectionTitle>
|
<InfoRow label={t("cardRequisite.fullName", "Doly ady")}>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
{[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(" ")}
|
||||||
<InfoRow label={t("Full name", "Doly ady")}>
|
</InfoRow>
|
||||||
{[data.first_name, data.last_name, data.middle_name]
|
<InfoRow label={t("cardRequisite.birthDate", "Doglan güni")}>
|
||||||
.filter(Boolean)
|
{data.birth_date}
|
||||||
.join(" ")}
|
</InfoRow>
|
||||||
</InfoRow>
|
<InfoRow label={t("cardRequisite.phone", "Telefon")}>
|
||||||
<InfoRow label={t("Birth date", "Doglan güni")}>
|
{data.phone}
|
||||||
{data.birth_date}
|
</InfoRow>
|
||||||
</InfoRow>
|
</BentoCard>
|
||||||
<InfoRow label={t("Phone", "Telefon")}>{data.phone}</InfoRow>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Passport */}
|
<BentoCard title={t("cardRequisite.passportSection", "Pasport")}>
|
||||||
<SectionTitle>{t("Passport", "Pasport")}</SectionTitle>
|
<InfoRow label={t("cardRequisite.passportSeries", "Pasport seriýasy")}>
|
||||||
<div className="rounded-lg border border-border bg-card overflow-hidden">
|
{data.passport_series}
|
||||||
<InfoRow label={t("Passport series", "Pasport seriýasy")}>
|
</InfoRow>
|
||||||
{data.passport_series}
|
<InfoRow label={t("cardRequisite.passportNumber", "Pasport belgisi")}>
|
||||||
</InfoRow>
|
{data.passport_number}
|
||||||
<InfoRow label={t("Passport number", "Pasport belgisi")}>
|
</InfoRow>
|
||||||
{data.passport_number}
|
</BentoCard>
|
||||||
</InfoRow>
|
</BentoGrid>
|
||||||
<PassportImageRow
|
|
||||||
label={t("Passport (page 1)", "Pasport (sahypa 1)")}
|
{/* ── Row 3: Passport images ────────────────────────────────────────── */}
|
||||||
url={data.passport_page1_url}
|
<BentoGrid cols={4}>
|
||||||
/>
|
<BentoCard title={t("cardRequisite.passportFile1", "Sahypa 1")}>
|
||||||
<PassportImageRow
|
<PassportImage
|
||||||
label={t("Passport (pages 2-3)", "Pasport (2-3-nji sahypa)")}
|
label={t("cardRequisite.passportFile1", "Pasport (sahypa 1)")}
|
||||||
url={data.passport_page2_3_url}
|
src={data.passport_page1_url}
|
||||||
/>
|
/>
|
||||||
<PassportImageRow
|
</BentoCard>
|
||||||
label={t("Passport (pages 8-9)", "Pasport (8-9 sahypa)")}
|
<BentoCard title={t("cardRequisite.passportFile2", "Sahypa 2-3")}>
|
||||||
url={data.passport_page8_9_url}
|
<PassportImage
|
||||||
/>
|
label={t("cardRequisite.passportFile2", "Pasport (2-3-nji sahypa)")}
|
||||||
<PassportImageRow
|
src={data.passport_page2_3_url}
|
||||||
label={t("Passport (page 32)", "Pasport (32-nji sahypa)")}
|
/>
|
||||||
url={data.passport_page32_url}
|
</BentoCard>
|
||||||
/>
|
<BentoCard title={t("cardRequisite.passportFile3", "Sahypa 8-9")}>
|
||||||
</div>
|
<PassportImage
|
||||||
|
label={t("cardRequisite.passportFile3", "Pasport (8-9 sahypa)")}
|
||||||
|
src={data.passport_page8_9_url}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
<BentoCard title={t("cardRequisite.passportFile4", "Sahypa 32")}>
|
||||||
|
<PassportImage
|
||||||
|
label={t("cardRequisite.passportFile4", "Pasport (32-nji sahypa)")}
|
||||||
|
src={data.passport_page32_url}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
</BentoGrid>
|
||||||
|
|
||||||
{/* Delete dialog */}
|
|
||||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>
|
|
||||||
{t("Are you sure?", "Eminsiňizmi?")}
|
|
||||||
</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
{t(
|
|
||||||
"This action cannot be undone.",
|
|
||||||
"Bu amal yzyna gaýtarylmaz. Kart rekwiziti hemişelik öçüriler.",
|
|
||||||
)}
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
|
||||||
<AlertDialogAction
|
|
||||||
onClick={handleDelete}
|
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
||||||
>
|
|
||||||
{deleteMutation.isPending
|
|
||||||
? t("Deleting...", "Öçürilýär...")
|
|
||||||
: t("Delete", "Öçür")}
|
|
||||||
</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
@@ -315,6 +315,7 @@ export default function CardOrdersPage() {
|
|||||||
onColumnVisibilityChange={setColumnVisibility}
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
columnOrder={columnOrder}
|
columnOrder={columnOrder}
|
||||||
onColumnOrderChange={setColumnOrder}
|
onColumnOrderChange={setColumnOrder}
|
||||||
|
enableRowSelection
|
||||||
getRowId={(row) => row.id}
|
getRowId={(row) => row.id}
|
||||||
currentPage={page}
|
currentPage={page}
|
||||||
totalPages={data?.totalPages ?? 1}
|
totalPages={data?.totalPages ?? 1}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export default function LoanTypeViewPage() {
|
|||||||
// ── Skeleton ───────────────────────────────────────────────────────────────
|
// ── Skeleton ───────────────────────────────────────────────────────────────
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="p-6 max-w-3xl">
|
<div className="p-6">
|
||||||
<Skeleton className="h-4 w-64 mb-4" />
|
<Skeleton className="h-4 w-64 mb-4" />
|
||||||
<Skeleton className="h-7 w-80 mb-6" />
|
<Skeleton className="h-7 w-80 mb-6" />
|
||||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||||
@@ -68,7 +68,7 @@ export default function LoanTypeViewPage() {
|
|||||||
|
|
||||||
// ── View ───────────────────────────────────────────────────────────────────
|
// ── View ───────────────────────────────────────────────────────────────────
|
||||||
return (
|
return (
|
||||||
<div className="p-6 max-w-3xl">
|
<div className="p-6">
|
||||||
|
|
||||||
|
|
||||||
{/* Page header */}
|
{/* Page header */}
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ export default function PermissionsPage() {
|
|||||||
onColumnVisibilityChange={setColumnVisibility}
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
columnOrder={columnOrder}
|
columnOrder={columnOrder}
|
||||||
onColumnOrderChange={setColumnOrder}
|
onColumnOrderChange={setColumnOrder}
|
||||||
|
enableRowSelection
|
||||||
getRowId={(row) => String(row.id)}
|
getRowId={(row) => String(row.id)}
|
||||||
currentPage={data?.meta?.current_page ?? 1}
|
currentPage={data?.meta?.current_page ?? 1}
|
||||||
totalPages={data?.meta?.last_page ?? 1}
|
totalPages={data?.meta?.last_page ?? 1}
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ export default function RolesPage() {
|
|||||||
onColumnVisibilityChange={setColumnVisibility}
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
columnOrder={columnOrder}
|
columnOrder={columnOrder}
|
||||||
onColumnOrderChange={setColumnOrder}
|
onColumnOrderChange={setColumnOrder}
|
||||||
|
enableRowSelection
|
||||||
getRowId={(row) => String(row.id)}
|
getRowId={(row) => String(row.id)}
|
||||||
currentPage={data?.meta?.current_page ?? 1}
|
currentPage={data?.meta?.current_page ?? 1}
|
||||||
totalPages={data?.meta?.last_page ?? 1}
|
totalPages={data?.meta?.last_page ?? 1}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export default function UserViewPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 max-w-4xl space-y-0">
|
<div className="p-6 space-y-0">
|
||||||
{/* Title + actions */}
|
{/* Title + actions */}
|
||||||
<div className="flex items-start justify-between mb-6">
|
<div className="flex items-start justify-between mb-6">
|
||||||
<h1 className="text-xl font-bold text-foreground leading-tight">
|
<h1 className="text-xl font-bold text-foreground leading-tight">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useParams, useNavigate } from 'react-router-dom'
|
import { useParams, useNavigate } from 'react-router-dom'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pencil, Trash2, ChevronDown } from 'lucide-react'
|
import { Pencil, Trash2, ChevronDown, XCircle, CheckCircle2 } from 'lucide-react'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||||
import { InfoRow, AuditLog } from '@/components/viewPageComponents'
|
import { InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||||
@@ -54,18 +54,10 @@ function BentoCard({
|
|||||||
|
|
||||||
function ActiveIndicator({ active }: { active: boolean }) {
|
function ActiveIndicator({ active }: { active: boolean }) {
|
||||||
return active ? (
|
return active ? (
|
||||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
|
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||||
<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">
|
<XCircle size={18} className="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 ───────────────────────────────────────────────────────
|
// ─── CollapsibleSection ───────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useParams, useNavigate } from "react-router-dom";
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Pencil, Trash2, ChevronDown } from "lucide-react";
|
import { Pencil, Trash2, ChevronDown, CheckCircle2, XCircle, } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||||
@@ -41,17 +41,9 @@ function BentoCard({ title, span, children }: { title?: string; span?: "full" |
|
|||||||
|
|
||||||
function ActiveIndicator({ active }: { active: boolean }) {
|
function ActiveIndicator({ active }: { active: boolean }) {
|
||||||
return active ? (
|
return active ? (
|
||||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
|
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||||
<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">
|
<XCircle size={18} className="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>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user