From c4d3ee0191e8f3aa1e0a6fe16ab832e31076f4a6 Mon Sep 17 00:00:00 2001 From: Jelaletdin12 Date: Sun, 24 May 2026 22:36:29 +0500 Subject: [PATCH] fixed button color, some select components --- src/components/dataTable.tsx | 9 + src/components/dataTableToolbar.tsx | 236 +++++++++++------- src/components/monthSelect.tsx | 78 ++++++ src/components/ui/button-variants.ts | 38 --- src/components/ui/button.tsx | 2 +- .../sberPayments/index.tsx | 42 +--- .../visaMasterPayments/index.tsx | 56 +---- 7 files changed, 246 insertions(+), 215 deletions(-) create mode 100644 src/components/monthSelect.tsx delete mode 100644 src/components/ui/button-variants.ts diff --git a/src/components/dataTable.tsx b/src/components/dataTable.tsx index 9fd4319..a8b4a0c 100644 --- a/src/components/dataTable.tsx +++ b/src/components/dataTable.tsx @@ -243,6 +243,9 @@ interface DataTableProps { totalPages?: number totalCount?: number onPageChange?: (page: number) => void + + // Optional content rendered above the table (e.g. month selector) + headerContent?: React.ReactNode } export function DataTable({ @@ -260,6 +263,7 @@ export function DataTable({ totalPages = 1, totalCount, onPageChange, + headerContent, }: DataTableProps) { const [sorting, setSorting] = useState([]) const [rowSelection, setRowSelection] = useState({}) @@ -394,6 +398,11 @@ export function DataTable({ return (
+ {/* Header content (e.g. month selector) */} + {headerContent && ( +
{headerContent}
+ )} + {/* Selection banner */} {showBanner && (
diff --git a/src/components/dataTableToolbar.tsx b/src/components/dataTableToolbar.tsx index 361e28b..d8d364b 100644 --- a/src/components/dataTableToolbar.tsx +++ b/src/components/dataTableToolbar.tsx @@ -6,6 +6,18 @@ import { useOutsideClick } from '@/lib/hooks/useOutsideClick' import { cn } from '@/lib/utils' import { TableSearchInput } from '@/components/tableSearch' import { TableActionButton } from '@/components/tableButton' +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover' +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select' // ─── Types ──────────────────────────────────────────────────────────────────── @@ -50,6 +62,8 @@ interface DataTableToolbarProps { hideSearch?: boolean hideAction?: boolean + + extraActions?: React.ReactNode } // ─── Toggle Columns Dropdown ────────────────────────────────────────────────── @@ -84,7 +98,6 @@ function ToggleColumnsDropdown({ onColumnVisibilityChange({ ...columnVisibility, [id]: !isVisible(id) }) } - // columnOrder'a göre sırala; columnOrder'da olmayan kolonları sona at const orderedColumns = [...columns].sort((a, b) => { const ai = columnOrder.indexOf(a.id) const bi = columnOrder.indexOf(b.id) @@ -94,9 +107,7 @@ function ToggleColumnsDropdown({ return ai - bi }) - const handleDragStart = (id: string) => { - dragIdRef.current = id - } + const handleDragStart = (id: string) => { dragIdRef.current = id } const handleDragOver = (e: React.DragEvent, id: string) => { e.preventDefault() @@ -106,19 +117,14 @@ function ToggleColumnsDropdown({ const handleDrop = (targetId: string) => { const sourceId = dragIdRef.current if (!sourceId || sourceId === targetId) return - const next = [...columnOrder] const from = next.indexOf(sourceId) const to = next.indexOf(targetId) - - // columnOrder'da yoksa ekle const safeFrom = from === -1 ? next.length : from const safeTo = to === -1 ? next.length : to - next.splice(safeFrom, 1) next.splice(safeTo, 0, sourceId) onColumnOrderChange(next) - dragIdRef.current = null setDragOverId(null) } @@ -226,8 +232,6 @@ function FilterDropdown({ }: FilterDropdownProps) { const { t } = useTranslation() const [open, setOpen] = useState(false) - const ref = useRef(null) - useOutsideClick(ref, () => setOpen(false)) const activeCount = activeFilters.filter((f) => f.value !== '').length const hasActive = activeCount > 0 @@ -236,95 +240,138 @@ function FilterDropdown({ activeFilters.find((f) => f.fieldId === fieldId)?.value ?? '' return ( -
- + + + + - {open && ( -
-
-

- {t('table.filters', 'Filters')} -

- {hasActive && ( - - )} -
+ + {/* Header */} +
+

+ {t('table.filters', 'Filters')} +

+
-
- {filterFields.map((field) => ( -
-
+ ) + })} + + {onPerPageChange && ( +
+ + +
+ )} + + {/* Reset — tüm filtreler, sadece aktif filter varsa göster */} + {hasActive && ( + + )}
- )} -
+ +
) } @@ -350,9 +397,10 @@ export function DataTableToolbar({ onAction, hideSearch = false, hideAction = false, + extraActions, }: DataTableToolbarProps) { return ( -
+
{!hideSearch && ( )} + {extraActions} + {!hideAction && actionLabel && onAction && ( )} diff --git a/src/components/monthSelect.tsx b/src/components/monthSelect.tsx new file mode 100644 index 0000000..f299f77 --- /dev/null +++ b/src/components/monthSelect.tsx @@ -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 ( +
+ + + {isActive && ( + + )} +
+ ) +} diff --git a/src/components/ui/button-variants.ts b/src/components/ui/button-variants.ts deleted file mode 100644 index 5ac3ffa..0000000 --- a/src/components/ui/button-variants.ts +++ /dev/null @@ -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", - }, - } -) \ No newline at end of file diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 375f094..e952e77 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -9,7 +9,7 @@ const buttonVariants = cva( { variants: { 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: "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: diff --git a/src/pages/internationalPayments/sberPayments/index.tsx b/src/pages/internationalPayments/sberPayments/index.tsx index 400b6d6..da15f0a 100644 --- a/src/pages/internationalPayments/sberPayments/index.tsx +++ b/src/pages/internationalPayments/sberPayments/index.tsx @@ -7,19 +7,12 @@ import { useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { DataTable } from '@/components/dataTable' 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 { type SberPaymentOrder, WELAYATLAR, STATUSES, type PaymentStatus, type PaymentPaidStatus } from '@/features/sberPayments/api/sberPaymentsApi' import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge' import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react' -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select' - // ─── Status badge ───────────────────────────────────────────────────────────── @@ -73,7 +66,6 @@ function PaymentStatusBadge({ status, t }: { status: PaymentStatus; t: (key: str // ─── Column Definitions ─────────────────────────────────────────────────────── - // ─── Column Meta for Toolbar ────────────────────────────────────────────────── function getColumnMeta(t: (key: string, fallback?: string) => string): ColumnMeta[] { @@ -302,32 +294,6 @@ export default function SberPaymentsListPage() { return (
- {/* Month Filter Card */} -
- - -
- {/* Page Title */}

{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ň')} onAction={() => navigate('/sber-payments/create')} + extraActions={ + { setSelectedMonth(v); setPage(1) }} + /> + } /> {/* Data Table */} diff --git a/src/pages/internationalPayments/visaMasterPayments/index.tsx b/src/pages/internationalPayments/visaMasterPayments/index.tsx index 40e2882..a4b2691 100644 --- a/src/pages/internationalPayments/visaMasterPayments/index.tsx +++ b/src/pages/internationalPayments/visaMasterPayments/index.tsx @@ -7,9 +7,9 @@ import { DataTableToolbar } from '@/components/dataTableToolbar' import { useIntlPayments, useDeleteIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments' import type { IntlPaymentItem, IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi' 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 { cn } from '@/lib/utils' +import { MonthSelect } from '@/components/monthSelect' import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge' import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react' // ─── Status badge ───────────────────────────────────────────────────────────── @@ -38,51 +38,6 @@ function IntlPaymentStatusStatusBadge({ status }: { status: IntlPaymentStatus }) return } -// ─── 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 ( -
- - {t('intlPayment.monthFilter', 'AÝ TÖLEGI')} - -
- - -
-
- ) -} - // ─── Page ───────────────────────────────────────────────────────────────────── export default function IntlPaymentsPage() { @@ -205,7 +160,6 @@ export default function IntlPaymentsPage() { {t("intlPayment.title", "Halkara tölegler (Visa/Mastercard)")}

- { setMonth(v); setPage(1) }} />
{ setPerPage(v); setPage(1) }} actionLabel={t('intlPayment.createBtn', 'Visa/Master tölegler (talyplar üçin) dörediň')} onAction={() => navigate('/visa-master/create')} + extraActions={ + { setMonth(v); setPage(1) }} + /> + } />