fixed button color, some select components
This commit is contained in:
1 parent
6f0f88af3c
commit
c4d3ee0191
7 files changed
+246
-215
No files matched your search
@@ -243,6 +243,9 @@ interface DataTableProps<TData> {
|
|||||||
totalPages?: number
|
totalPages?: number
|
||||||
totalCount?: number
|
totalCount?: number
|
||||||
onPageChange?: (page: number) => void
|
onPageChange?: (page: number) => void
|
||||||
|
|
||||||
|
// Optional content rendered above the table (e.g. month selector)
|
||||||
|
headerContent?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DataTable<TData>({
|
export function DataTable<TData>({
|
||||||
@@ -260,6 +263,7 @@ export function DataTable<TData>({
|
|||||||
totalPages = 1,
|
totalPages = 1,
|
||||||
totalCount,
|
totalCount,
|
||||||
onPageChange,
|
onPageChange,
|
||||||
|
headerContent,
|
||||||
}: DataTableProps<TData>) {
|
}: DataTableProps<TData>) {
|
||||||
const [sorting, setSorting] = useState<SortingState>([])
|
const [sorting, setSorting] = useState<SortingState>([])
|
||||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
||||||
@@ -394,6 +398,11 @@ export function DataTable<TData>({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-0">
|
<div className="space-y-0">
|
||||||
|
{/* Header content (e.g. month selector) */}
|
||||||
|
{headerContent && (
|
||||||
|
<div className="mb-3">{headerContent}</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Selection banner */}
|
{/* Selection banner */}
|
||||||
{showBanner && (
|
{showBanner && (
|
||||||
<div className="flex items-center justify-between px-3 py-2 bg-primary/5 border border-primary/20 rounded-t-lg text-sm border-b-0">
|
<div className="flex items-center justify-between px-3 py-2 bg-primary/5 border border-primary/20 rounded-t-lg text-sm border-b-0">
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ import { useOutsideClick } from '@/lib/hooks/useOutsideClick'
|
|||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { TableSearchInput } from '@/components/tableSearch'
|
import { TableSearchInput } from '@/components/tableSearch'
|
||||||
import { TableActionButton } from '@/components/tableButton'
|
import { TableActionButton } from '@/components/tableButton'
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from '@/components/ui/popover'
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -50,6 +62,8 @@ interface DataTableToolbarProps {
|
|||||||
|
|
||||||
hideSearch?: boolean
|
hideSearch?: boolean
|
||||||
hideAction?: boolean
|
hideAction?: boolean
|
||||||
|
|
||||||
|
extraActions?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Toggle Columns Dropdown ──────────────────────────────────────────────────
|
// ─── Toggle Columns Dropdown ──────────────────────────────────────────────────
|
||||||
@@ -84,7 +98,6 @@ function ToggleColumnsDropdown({
|
|||||||
onColumnVisibilityChange({ ...columnVisibility, [id]: !isVisible(id) })
|
onColumnVisibilityChange({ ...columnVisibility, [id]: !isVisible(id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
// columnOrder'a göre sırala; columnOrder'da olmayan kolonları sona at
|
|
||||||
const orderedColumns = [...columns].sort((a, b) => {
|
const orderedColumns = [...columns].sort((a, b) => {
|
||||||
const ai = columnOrder.indexOf(a.id)
|
const ai = columnOrder.indexOf(a.id)
|
||||||
const bi = columnOrder.indexOf(b.id)
|
const bi = columnOrder.indexOf(b.id)
|
||||||
@@ -94,9 +107,7 @@ function ToggleColumnsDropdown({
|
|||||||
return ai - bi
|
return ai - bi
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleDragStart = (id: string) => {
|
const handleDragStart = (id: string) => { dragIdRef.current = id }
|
||||||
dragIdRef.current = id
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDragOver = (e: React.DragEvent, id: string) => {
|
const handleDragOver = (e: React.DragEvent, id: string) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -106,19 +117,14 @@ function ToggleColumnsDropdown({
|
|||||||
const handleDrop = (targetId: string) => {
|
const handleDrop = (targetId: string) => {
|
||||||
const sourceId = dragIdRef.current
|
const sourceId = dragIdRef.current
|
||||||
if (!sourceId || sourceId === targetId) return
|
if (!sourceId || sourceId === targetId) return
|
||||||
|
|
||||||
const next = [...columnOrder]
|
const next = [...columnOrder]
|
||||||
const from = next.indexOf(sourceId)
|
const from = next.indexOf(sourceId)
|
||||||
const to = next.indexOf(targetId)
|
const to = next.indexOf(targetId)
|
||||||
|
|
||||||
// columnOrder'da yoksa ekle
|
|
||||||
const safeFrom = from === -1 ? next.length : from
|
const safeFrom = from === -1 ? next.length : from
|
||||||
const safeTo = to === -1 ? next.length : to
|
const safeTo = to === -1 ? next.length : to
|
||||||
|
|
||||||
next.splice(safeFrom, 1)
|
next.splice(safeFrom, 1)
|
||||||
next.splice(safeTo, 0, sourceId)
|
next.splice(safeTo, 0, sourceId)
|
||||||
onColumnOrderChange(next)
|
onColumnOrderChange(next)
|
||||||
|
|
||||||
dragIdRef.current = null
|
dragIdRef.current = null
|
||||||
setDragOverId(null)
|
setDragOverId(null)
|
||||||
}
|
}
|
||||||
@@ -226,8 +232,6 @@ function FilterDropdown({
|
|||||||
}: FilterDropdownProps) {
|
}: FilterDropdownProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const ref = useRef<HTMLDivElement>(null)
|
|
||||||
useOutsideClick(ref, () => setOpen(false))
|
|
||||||
|
|
||||||
const activeCount = activeFilters.filter((f) => f.value !== '').length
|
const activeCount = activeFilters.filter((f) => f.value !== '').length
|
||||||
const hasActive = activeCount > 0
|
const hasActive = activeCount > 0
|
||||||
@@ -236,95 +240,138 @@ function FilterDropdown({
|
|||||||
activeFilters.find((f) => f.fieldId === fieldId)?.value ?? ''
|
activeFilters.find((f) => f.fieldId === fieldId)?.value ?? ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={ref} className="relative">
|
<Popover open={open} onOpenChange={setOpen}>
|
||||||
<button
|
<PopoverTrigger asChild>
|
||||||
onClick={() => setOpen((v) => !v)}
|
<button
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex items-center gap-1.5 h-9 px-3 rounded-md border border-border cursor-pointer',
|
'flex items-center gap-1.5 h-9 px-3 rounded-md border border-border cursor-pointer',
|
||||||
'text-muted-foreground bg-background',
|
'text-muted-foreground bg-background',
|
||||||
'hover:bg-muted/50 hover:text-foreground transition-colors',
|
'hover:bg-muted/50 hover:text-foreground transition-colors',
|
||||||
open && 'bg-muted/50 text-foreground border-ring',
|
open && 'bg-muted/50 text-foreground border-ring',
|
||||||
// emerald yerine primary token
|
hasActive && 'border-primary text-primary'
|
||||||
hasActive && 'border-primary text-primary'
|
)}
|
||||||
)}
|
>
|
||||||
>
|
<Filter size={14} />
|
||||||
<Filter size={14} />
|
{hasActive && (
|
||||||
{hasActive && (
|
<span className="text-xs font-semibold bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center leading-none">
|
||||||
<span className="text-xs font-semibold bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center leading-none">
|
{activeCount}
|
||||||
{activeCount}
|
</span>
|
||||||
</span>
|
)}
|
||||||
)}
|
<ChevronDown size={12} />
|
||||||
<ChevronDown size={12} />
|
</button>
|
||||||
</button>
|
</PopoverTrigger>
|
||||||
|
|
||||||
{open && (
|
<PopoverContent align="end" sideOffset={4} className="w-64 p-0">
|
||||||
<div className="absolute right-0 mt-1.5 w-64 bg-card border border-border rounded-md shadow-lg z-50 py-3">
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between px-3 pb-2 border-b border-border mb-2">
|
<div className="flex items-center justify-between px-3 py-2 border-b border-border">
|
||||||
<p className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">
|
<p className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">
|
||||||
{t('table.filters', 'Filters')}
|
{t('table.filters', 'Filters')}
|
||||||
</p>
|
</p>
|
||||||
{hasActive && (
|
</div>
|
||||||
<button
|
|
||||||
onClick={onFilterReset}
|
|
||||||
className="flex items-center gap-1 text-xs text-destructive hover:text-destructive/80 transition-colors"
|
|
||||||
>
|
|
||||||
<X size={11} />
|
|
||||||
{t('table.reset', 'Reset')}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="px-3 space-y-3">
|
{/* Fields */}
|
||||||
{filterFields.map((field) => (
|
<div className="px-3 py-3 space-y-3">
|
||||||
<div key={field.id}>
|
{filterFields.map((field) => {
|
||||||
<label className="block text-[11px] font-semibold text-muted-foreground uppercase tracking-wider mb-1">
|
const current = getActiveValue(field.id)
|
||||||
|
const isFieldActive = current !== ''
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={field.id} className="space-y-1">
|
||||||
|
<label className="block text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">
|
||||||
{field.label}
|
{field.label}
|
||||||
</label>
|
</label>
|
||||||
<select
|
|
||||||
value={getActiveValue(field.id)}
|
|
||||||
onChange={(e) => onFilterChange(field.id, e.target.value)}
|
|
||||||
className={cn(
|
|
||||||
'w-full h-8 px-2 rounded-md border border-border bg-background',
|
|
||||||
'text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring',
|
|
||||||
'transition-colors appearance-none cursor-pointer'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<option value="">—</option>
|
|
||||||
{field.options.map((opt) => (
|
|
||||||
<option key={opt.value} value={opt.value}>
|
|
||||||
{opt.label}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{onPerPageChange && (
|
{/* MonthSelect ile aynı pattern: manuel span + sentinel */}
|
||||||
<div>
|
<div className="flex items-center gap-1">
|
||||||
<label className="block text-[11px] font-semibold text-muted-foreground uppercase tracking-wider mb-1">
|
<Select
|
||||||
{t('table.perPage', 'Sahypa başyna')}
|
value={current || '__all__'}
|
||||||
</label>
|
onValueChange={(val) =>
|
||||||
<select
|
onFilterChange(field.id, val === '__all__' ? '' : val)
|
||||||
value={perPage}
|
}
|
||||||
onChange={(e) => onPerPageChange(Number(e.target.value))}
|
>
|
||||||
className={cn(
|
<SelectTrigger
|
||||||
'w-full h-8 px-2 rounded-md border border-border bg-background',
|
className={cn(
|
||||||
'text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring',
|
'h-8 flex-1 text-sm gap-1.5 transition-colors',
|
||||||
'transition-colors appearance-none cursor-pointer'
|
isFieldActive
|
||||||
|
? 'border-primary text-primary [&>svg:last-child]:text-primary'
|
||||||
|
: 'text-muted-foreground'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{/* SelectValue kullanmıyoruz — MonthSelect gibi manuel */}
|
||||||
|
<span className="flex-1 text-left truncate">
|
||||||
|
{isFieldActive
|
||||||
|
? field.options.find((o) => o.value === current)?.label
|
||||||
|
: '—'}
|
||||||
|
</span>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent position="popper" sideOffset={4} className='p-1'>
|
||||||
|
<SelectItem value="__all__">
|
||||||
|
<span className="text-muted-foreground">— Ählisi</span>
|
||||||
|
</SelectItem>
|
||||||
|
{field.options.map((opt) => (
|
||||||
|
<SelectItem key={opt.value} value={opt.value}>
|
||||||
|
{opt.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
{/* Field bazlı temizle — MonthSelect'teki X butonu ile aynı */}
|
||||||
|
{isFieldActive && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => onFilterChange(field.id, '')}
|
||||||
|
className="h-6 w-6 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0"
|
||||||
|
>
|
||||||
|
<X size={11} />
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
>
|
</div>
|
||||||
{perPageOptions.map((n) => (
|
|
||||||
<option key={n} value={n}>
|
|
||||||
{n}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)
|
||||||
</div>
|
})}
|
||||||
|
|
||||||
|
{onPerPageChange && (
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label className="block text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">
|
||||||
|
{t('table.perPage', 'Sahypa başyna')}
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
value={String(perPage)}
|
||||||
|
onValueChange={(val) => onPerPageChange(Number(val))}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-8 w-full text-sm">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent position="popper" sideOffset={4} className='p-1'>
|
||||||
|
{perPageOptions.map((n) => (
|
||||||
|
<SelectItem key={n} value={String(n)}>
|
||||||
|
{n}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Reset — tüm filtreler, sadece aktif filter varsa göster */}
|
||||||
|
{hasActive && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onFilterReset}
|
||||||
|
className={cn(
|
||||||
|
'w-full cursor-pointer flex items-center justify-center gap-1.5 h-8 rounded-md text-xs font-medium transition-colors',
|
||||||
|
'bg-destructive/10 text-destructive border border-destructive/20',
|
||||||
|
'hover:bg-destructive/30 hover:text-destructive-foreground'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<X size={11} />
|
||||||
|
{t('table.reset', 'Reset')} ({activeCount})
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</PopoverContent>
|
||||||
</div>
|
</Popover>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,9 +397,10 @@ export function DataTableToolbar({
|
|||||||
onAction,
|
onAction,
|
||||||
hideSearch = false,
|
hideSearch = false,
|
||||||
hideAction = false,
|
hideAction = false,
|
||||||
|
extraActions,
|
||||||
}: DataTableToolbarProps) {
|
}: DataTableToolbarProps) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex items-center gap-3 mb-3", hideSearch ? "justify-end" : "justify-between")}>
|
<div className={cn('flex items-center gap-3 mb-3', hideSearch ? 'justify-end' : 'justify-between')}>
|
||||||
{!hideSearch && (
|
{!hideSearch && (
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={searchValue}
|
value={searchValue}
|
||||||
@@ -384,6 +432,8 @@ export function DataTableToolbar({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{extraActions}
|
||||||
|
|
||||||
{!hideAction && actionLabel && onAction && (
|
{!hideAction && actionLabel && onAction && (
|
||||||
<TableActionButton label={actionLabel} onClick={onAction} />
|
<TableActionButton label={actionLabel} onClick={onAction} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { Calendar, X } from 'lucide-react'
|
||||||
|
import { cn } from '@/lib/utils'
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
|
||||||
|
// ─── Month data ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export const MONTHS = [
|
||||||
|
{ value: '01', label: 'Ýanwar' },
|
||||||
|
{ value: '02', label: 'Fewral' },
|
||||||
|
{ value: '03', label: 'Mart' },
|
||||||
|
{ value: '04', label: 'Aprel' },
|
||||||
|
{ value: '05', label: 'Maý' },
|
||||||
|
{ value: '06', label: 'Iýun' },
|
||||||
|
{ value: '07', label: 'Iýul' },
|
||||||
|
{ value: '08', label: 'Awgust' },
|
||||||
|
{ value: '09', label: 'Sentýabr' },
|
||||||
|
{ value: '10', label: 'Oktýabr' },
|
||||||
|
{ value: '11', label: 'Noýabr' },
|
||||||
|
{ value: '12', label: 'Dekabr' },
|
||||||
|
]
|
||||||
|
|
||||||
|
// ─── MonthSelect ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
interface MonthSelectProps {
|
||||||
|
value: string
|
||||||
|
onChange: (value: string) => void
|
||||||
|
placeholder?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MonthSelect({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}: MonthSelectProps) {
|
||||||
|
const isActive = Boolean(value)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Select value={value || undefined} onValueChange={onChange}>
|
||||||
|
<SelectTrigger
|
||||||
|
className={cn(
|
||||||
|
'h-9 w-[135px] gap-1.5 text-sm cursor-pointer transition-colors',
|
||||||
|
isActive
|
||||||
|
? 'border-primary text-primary font-medium [&>svg:last-child]:text-primary'
|
||||||
|
: 'text-muted-foreground hover:text-foreground',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Calendar size={14} className="shrink-0 opacity-80" />
|
||||||
|
<span className="flex-1 text-left truncate">
|
||||||
|
{isActive ? MONTHS.find(m => m.value === value)?.label : "—"}
|
||||||
|
</span>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent position="popper" sideOffset={4} className='p-1'>
|
||||||
|
{MONTHS.map((m) => (
|
||||||
|
<SelectItem key={m.value} value={m.value}>
|
||||||
|
{m.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
{isActive && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => onChange('')}
|
||||||
|
className="h-6 w-6 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors"
|
||||||
|
aria-label="Aý filtri aýyr"
|
||||||
|
>
|
||||||
|
<X size={11} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import { cva } from "class-variance-authority"
|
|
||||||
|
|
||||||
export const buttonVariants = cva(
|
|
||||||
"group/button inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
||||||
outline:
|
|
||||||
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
||||||
secondary:
|
|
||||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
||||||
ghost:
|
|
||||||
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
||||||
destructive:
|
|
||||||
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
||||||
link: "text-primary underline-offset-4 hover:underline",
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
default:
|
|
||||||
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
||||||
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
||||||
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
||||||
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
||||||
icon: "size-8",
|
|
||||||
"icon-xs":
|
|
||||||
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
||||||
"icon-sm":
|
|
||||||
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
||||||
"icon-lg": "size-9",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
size: "default",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@@ -9,7 +9,7 @@ const buttonVariants = cva(
|
|||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
default: "bg-[#005f78] dark:bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||||
outline:
|
outline:
|
||||||
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
||||||
secondary:
|
secondary:
|
||||||
|
|||||||
@@ -7,19 +7,12 @@ import { useNavigate } from 'react-router-dom'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { DataTable } from '@/components/dataTable'
|
import { DataTable } from '@/components/dataTable'
|
||||||
import { DataTableToolbar, type ColumnMeta, type FilterField, type ActiveFilter } from '@/components/dataTableToolbar'
|
import { DataTableToolbar, type ColumnMeta, type FilterField, type ActiveFilter } from '@/components/dataTableToolbar'
|
||||||
|
import { MonthSelect } from '@/components/monthSelect'
|
||||||
import { useSberPaymentOrders, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments'
|
import { useSberPaymentOrders, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments'
|
||||||
import { type SberPaymentOrder, WELAYATLAR, STATUSES, type PaymentStatus, type PaymentPaidStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
import { type SberPaymentOrder, WELAYATLAR, STATUSES, type PaymentStatus, type PaymentPaidStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||||
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select'
|
|
||||||
|
|
||||||
|
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -73,7 +66,6 @@ function PaymentStatusBadge({ status, t }: { status: PaymentStatus; t: (key: str
|
|||||||
// ─── Column Definitions ───────────────────────────────────────────────────────
|
// ─── Column Definitions ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ─── Column Meta for Toolbar ──────────────────────────────────────────────────
|
// ─── Column Meta for Toolbar ──────────────────────────────────────────────────
|
||||||
|
|
||||||
function getColumnMeta(t: (key: string, fallback?: string) => string): ColumnMeta[] {
|
function getColumnMeta(t: (key: string, fallback?: string) => string): ColumnMeta[] {
|
||||||
@@ -302,32 +294,6 @@ export default function SberPaymentsListPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{/* Month Filter Card */}
|
|
||||||
<div className="bg-card border border-border rounded-lg p-4 max-w-xs">
|
|
||||||
<label className="block text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2">
|
|
||||||
{t('sberPayments.list.monthLabel', 'Aý tölegi')}
|
|
||||||
</label>
|
|
||||||
<Select value={selectedMonth} onValueChange={setSelectedMonth}>
|
|
||||||
<SelectTrigger className="w-full">
|
|
||||||
<SelectValue placeholder="--" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="01">{t('months.january', 'Ýanwar')}</SelectItem>
|
|
||||||
<SelectItem value="02">{t('months.february', 'Fewral')}</SelectItem>
|
|
||||||
<SelectItem value="03">{t('months.march', 'Mart')}</SelectItem>
|
|
||||||
<SelectItem value="04">{t('months.april', 'Aprel')}</SelectItem>
|
|
||||||
<SelectItem value="05">{t('months.may', 'Maý')}</SelectItem>
|
|
||||||
<SelectItem value="06">{t('months.june', 'Iýun')}</SelectItem>
|
|
||||||
<SelectItem value="07">{t('months.july', 'Iýul')}</SelectItem>
|
|
||||||
<SelectItem value="08">{t('months.august', 'Awgust')}</SelectItem>
|
|
||||||
<SelectItem value="09">{t('months.september', 'Sentýabr')}</SelectItem>
|
|
||||||
<SelectItem value="10">{t('months.october', 'Oktýabr')}</SelectItem>
|
|
||||||
<SelectItem value="11">{t('months.november', 'Noýabr')}</SelectItem>
|
|
||||||
<SelectItem value="12">{t('months.december', 'Dekabr')}</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Page Title */}
|
{/* Page Title */}
|
||||||
<h1 className="text-xl font-semibold text-foreground">
|
<h1 className="text-xl font-semibold text-foreground">
|
||||||
{t('sberPayments.list.title', 'Sber tölegler (talyplar üçin)')}
|
{t('sberPayments.list.title', 'Sber tölegler (talyplar üçin)')}
|
||||||
@@ -358,6 +324,12 @@ export default function SberPaymentsListPage() {
|
|||||||
}}
|
}}
|
||||||
actionLabel={t('sberPayments.list.actionLabel', 'Sber töleg (talyplar üçin) dörediň')}
|
actionLabel={t('sberPayments.list.actionLabel', 'Sber töleg (talyplar üçin) dörediň')}
|
||||||
onAction={() => navigate('/sber-payments/create')}
|
onAction={() => navigate('/sber-payments/create')}
|
||||||
|
extraActions={
|
||||||
|
<MonthSelect
|
||||||
|
value={selectedMonth}
|
||||||
|
onChange={(v) => { setSelectedMonth(v); setPage(1) }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Data Table */}
|
{/* Data Table */}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import { DataTableToolbar } from '@/components/dataTableToolbar'
|
|||||||
import { useIntlPayments, useDeleteIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
import { useIntlPayments, useDeleteIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
||||||
import type { IntlPaymentItem, IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
import type { IntlPaymentItem, IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Eye, Pencil, Trash2, ChevronDown } from 'lucide-react'
|
import { Eye, Pencil, Trash2 } from 'lucide-react'
|
||||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||||
import { cn } from '@/lib/utils'
|
import { MonthSelect } from '@/components/monthSelect'
|
||||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
@@ -38,51 +38,6 @@ function IntlPaymentStatusStatusBadge({ status }: { status: IntlPaymentStatus })
|
|||||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Month selector (AÝ TOLEGI) ───────────────────────────────────────────────
|
|
||||||
|
|
||||||
const MONTHS = [
|
|
||||||
{ value: '01', label: 'Ýanwar' },
|
|
||||||
{ value: '02', label: 'Fewral' },
|
|
||||||
{ value: '03', label: 'Mart' },
|
|
||||||
{ value: '04', label: 'Aprel' },
|
|
||||||
{ value: '05', label: 'Maý' },
|
|
||||||
{ value: '06', label: 'Iýun' },
|
|
||||||
{ value: '07', label: 'Iýul' },
|
|
||||||
{ value: '08', label: 'Awgust' },
|
|
||||||
{ value: '09', label: 'Sentýabr' },
|
|
||||||
{ value: '10', label: 'Oktýabr' },
|
|
||||||
{ value: '11', label: 'Noýabr' },
|
|
||||||
{ value: '12', label: 'Dekabr' },
|
|
||||||
]
|
|
||||||
|
|
||||||
function MonthSelector({ value, onChange }: { value: string; onChange: (v: string) => void }) {
|
|
||||||
const { t } = useTranslation()
|
|
||||||
return (
|
|
||||||
<div className="bg-card border border-border rounded-lg p-4 mb-4 inline-flex flex-col gap-2">
|
|
||||||
<span className="text-xs font-bold uppercase tracking-wider text-muted-foreground">
|
|
||||||
{t('intlPayment.monthFilter', 'AÝ TÖLEGI')}
|
|
||||||
</span>
|
|
||||||
<div className="relative">
|
|
||||||
<select
|
|
||||||
value={value}
|
|
||||||
onChange={(e) => onChange(e.target.value)}
|
|
||||||
className={cn(
|
|
||||||
'h-9 pl-3 pr-8 rounded-md border border-border bg-background',
|
|
||||||
'text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring',
|
|
||||||
'appearance-none cursor-pointer min-w-[120px]',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<option value="">—</option>
|
|
||||||
{MONTHS.map((m) => (
|
|
||||||
<option key={m.value} value={m.value}>{m.label}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
<ChevronDown size={13} className="absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function IntlPaymentsPage() {
|
export default function IntlPaymentsPage() {
|
||||||
@@ -205,7 +160,6 @@ export default function IntlPaymentsPage() {
|
|||||||
{t("intlPayment.title", "Halkara tölegler (Visa/Mastercard)")}
|
{t("intlPayment.title", "Halkara tölegler (Visa/Mastercard)")}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<MonthSelector value={month} onChange={(v) => { setMonth(v); setPage(1) }} />
|
|
||||||
<div className="bg-card border border-border rounded-xl p-4">
|
<div className="bg-card border border-border rounded-xl p-4">
|
||||||
|
|
||||||
<DataTableToolbar
|
<DataTableToolbar
|
||||||
@@ -238,6 +192,12 @@ export default function IntlPaymentsPage() {
|
|||||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
||||||
actionLabel={t('intlPayment.createBtn', 'Visa/Master tölegler (talyplar üçin) dörediň')}
|
actionLabel={t('intlPayment.createBtn', 'Visa/Master tölegler (talyplar üçin) dörediň')}
|
||||||
onAction={() => navigate('/visa-master/create')}
|
onAction={() => navigate('/visa-master/create')}
|
||||||
|
extraActions={
|
||||||
|
<MonthSelect
|
||||||
|
value={month}
|
||||||
|
onChange={(v) => { setMonth(v); setPage(1) }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
|
|||||||
Reference in new issue
Block a user