fixed some statuses and filters
This commit is contained in:
@@ -241,14 +241,14 @@ function FilterDropdown({
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
|
||||
<PopoverContent align="end" sideOffset={4} className="w-64 p-0">
|
||||
<PopoverContent align="end" sideOffset={4} className="w-64 p-0 max-h-(--radix-popover-content-available-height) flex flex-col">
|
||||
{/* Header */}
|
||||
<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">{t("table.filters", "Filters")}</p>
|
||||
</div>
|
||||
|
||||
{/* Fields */}
|
||||
<div className="px-3 py-3 space-y-3">
|
||||
<div className="px-3 py-3 space-y-3 overflow-y-auto">
|
||||
{filterFields.map((field) => {
|
||||
const current = getActiveValue(field.id);
|
||||
const isFieldActive = current !== "";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { useState, useRef, useEffect, useMemo } from "react";
|
||||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
||||
import { Check, ChevronsUpDown, Search, X, Eye, EyeOff, Upload, Hash, CreditCard } from "lucide-react";
|
||||
|
||||
@@ -257,7 +257,7 @@ function PhoneInput({
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-8 w-full rounded-md border bg-background overflow-hidden",
|
||||
"flex h-8 w-full rounded-md border border-input bg-transparent dark:bg-input/30 overflow-hidden",
|
||||
"ring-offset-background transition-colors duration-150",
|
||||
"focus-within:outline-none focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-0",
|
||||
error ? "border-destructive focus-within:ring-destructive/30" : "border-input",
|
||||
@@ -273,7 +273,7 @@ function PhoneInput({
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
className="flex-1 h-full px-3 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none disabled:cursor-not-allowed"
|
||||
className="flex-1 h-full px-3 bg-transparent text-sm text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -491,12 +491,12 @@ function DateInput({ value = "", onChange, error, disabled, required, label, cla
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
error ? "border-destructive" : "border-input",
|
||||
!selected && "text-muted-foreground/60",
|
||||
!selected && "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<span>{selected ? format(selected, "dd.MM.yyyy") : placeholder}</span>
|
||||
@@ -539,7 +539,16 @@ function SelectInput({
|
||||
}: FormInputProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const selected = options.find((o) => o.value === value);
|
||||
const uniqueOptions = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
return options.filter((opt) => {
|
||||
if (seen.has(opt.value)) return false;
|
||||
seen.add(opt.value);
|
||||
return true;
|
||||
});
|
||||
}, [options]);
|
||||
|
||||
const selected = uniqueOptions.find((o) => o.value === value);
|
||||
|
||||
const handleSelect = (val: string) => {
|
||||
onChange?.(val);
|
||||
@@ -561,7 +570,7 @@ function SelectInput({
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
@@ -569,7 +578,7 @@ function SelectInput({
|
||||
open && !error && "ring-2 ring-ring ring-offset-0 border-transparent",
|
||||
)}
|
||||
>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground/60")}>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground")}>
|
||||
{selected ? selected.label : placeholder}
|
||||
</span>
|
||||
<ChevronsUpDown
|
||||
@@ -583,7 +592,7 @@ function SelectInput({
|
||||
className={cn("absolute z-50 top-full left-0 right-0 mt-1", "rounded-md border border-border bg-card shadow-lg overflow-hidden")}
|
||||
>
|
||||
<div className="max-h-52 overflow-y-auto scrollbar-thin py-1">
|
||||
{options.map((opt) => {
|
||||
{uniqueOptions.map((opt) => {
|
||||
const isSelected = opt.value === value;
|
||||
return (
|
||||
<button
|
||||
@@ -633,8 +642,17 @@ function SearchableSelect({
|
||||
const [query, setQuery] = useState("");
|
||||
const searchRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const selected = options.find((o) => o.value === value);
|
||||
const filtered = query.trim() ? options.filter((o) => o.label.toLowerCase().includes(query.toLowerCase())) : options;
|
||||
const uniqueOptions = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
return options.filter((opt) => {
|
||||
if (seen.has(opt.value)) return false;
|
||||
seen.add(opt.value);
|
||||
return true;
|
||||
});
|
||||
}, [options]);
|
||||
|
||||
const selected = uniqueOptions.find((o) => o.value === value);
|
||||
const filtered = query.trim() ? uniqueOptions.filter((o) => o.label.toLowerCase().includes(query.toLowerCase())) : uniqueOptions;
|
||||
|
||||
const openDropdown = () => {
|
||||
setOpen(true);
|
||||
@@ -680,7 +698,7 @@ function SearchableSelect({
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
@@ -688,7 +706,7 @@ function SearchableSelect({
|
||||
open && !error && "ring-2 ring-ring ring-offset-0 border-transparent",
|
||||
)}
|
||||
>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground/60")}>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground")}>
|
||||
{selected ? selected.label : placeholder}
|
||||
</span>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
||||
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
||||
import { Check, ChevronsUpDown, Search, X, Loader2 } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
@@ -20,25 +20,14 @@ export interface InfiniteSelectProps {
|
||||
required?: boolean;
|
||||
error?: string;
|
||||
disabled?: boolean;
|
||||
/** True while the first page is being fetched. */
|
||||
loading?: boolean;
|
||||
/** True while the next page is being fetched. */
|
||||
isLoadingMore?: boolean;
|
||||
/** Whether more pages are available to load. */
|
||||
hasNextPage?: boolean;
|
||||
/** Called when the user scrolls to the bottom of the list. */
|
||||
onLoadMore?: () => void;
|
||||
/** Controlled search text; drives server-side search + page reset. */
|
||||
searchValue?: string;
|
||||
onSearchChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
// ─── Collapsible aliases ──────────────────────────────────────────────────────
|
||||
|
||||
const Collapsible = CollapsiblePrimitive.Root;
|
||||
const CollapsibleTrigger = CollapsiblePrimitive.Trigger;
|
||||
const CollapsibleContent = CollapsiblePrimitive.Content;
|
||||
|
||||
/**
|
||||
* Searchable select with infinite scroll.
|
||||
*
|
||||
@@ -81,14 +70,12 @@ export function InfiniteSelect({
|
||||
|
||||
const loadingRef = useRef(false);
|
||||
|
||||
// Reset loading ref when the query transitions out of loading state
|
||||
useEffect(() => {
|
||||
if (!isLoadingMore) {
|
||||
loadingRef.current = false;
|
||||
}
|
||||
}, [isLoadingMore]);
|
||||
|
||||
// ── Infinite scroll: load more when the sentinel becomes visible ──
|
||||
useEffect(() => {
|
||||
if (!open || !sentinelRef.current || !hasNextPage || isLoadingMore) return;
|
||||
const el = sentinelRef.current;
|
||||
@@ -114,18 +101,18 @@ export function InfiniteSelect({
|
||||
</label>
|
||||
)}
|
||||
|
||||
<Collapsible
|
||||
<PopoverPrimitive.Root
|
||||
open={open}
|
||||
onOpenChange={(next) => {
|
||||
if (!disabled) setOpen(next);
|
||||
}}
|
||||
>
|
||||
<CollapsibleTrigger asChild>
|
||||
<PopoverPrimitive.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2",
|
||||
"flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent dark:bg-input/30 px-3 py-2",
|
||||
"text-sm ring-offset-background transition-colors duration-150",
|
||||
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
@@ -133,7 +120,7 @@ export function InfiniteSelect({
|
||||
open && !error && "ring-2 ring-ring ring-offset-0 border-transparent",
|
||||
)}
|
||||
>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground/60")}>
|
||||
<span className={cn("truncate text-left", !selected && "text-muted-foreground")}>
|
||||
{selected ? selected.label : placeholder}
|
||||
</span>
|
||||
|
||||
@@ -154,75 +141,85 @@ export function InfiniteSelect({
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
</CollapsibleTrigger>
|
||||
</PopoverPrimitive.Trigger>
|
||||
|
||||
<CollapsibleContent className="absolute z-50 top-full left-0 right-0 mt-1 rounded-md border border-border bg-card shadow-lg overflow-hidden">
|
||||
{onSearchChange && (
|
||||
<div className="flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/20">
|
||||
<Search size={13} className="text-muted-foreground shrink-0" />
|
||||
<input
|
||||
type="text"
|
||||
value={searchValue ?? ""}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
placeholder={searchPlaceholder}
|
||||
className="flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none"
|
||||
/>
|
||||
{searchValue && (
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
onMouseDown={() => onSearchChange?.("")}
|
||||
className="text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<X size={12} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="max-h-60 overflow-y-auto scrollbar-thin py-1">
|
||||
{loading && options.length === 0 ? (
|
||||
<p className="px-3 py-4 text-sm text-muted-foreground text-center flex items-center justify-center gap-2">
|
||||
<Loader2 size={14} className="animate-spin" /> Loading...
|
||||
</p>
|
||||
) : options.length === 0 ? (
|
||||
<p className="px-3 py-4 text-sm text-muted-foreground text-center">Netije tapylmady</p>
|
||||
) : (
|
||||
options.map((opt) => {
|
||||
const isSelected = opt.value === value;
|
||||
return (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Content
|
||||
align="start"
|
||||
side="bottom"
|
||||
sideOffset={4}
|
||||
collisionPadding={16}
|
||||
avoidCollisions
|
||||
style={{ width: "var(--radix-popover-trigger-width)" }}
|
||||
className="z-50 rounded-md border border-border bg-card shadow-lg overflow-hidden max-h-[var(--radix-popover-content-available-height)] flex flex-col"
|
||||
>
|
||||
{onSearchChange && (
|
||||
<div className="flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/20 shrink-0">
|
||||
<Search size={13} className="text-muted-foreground shrink-0" />
|
||||
<input
|
||||
type="text"
|
||||
value={searchValue ?? ""}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
placeholder={searchPlaceholder}
|
||||
className="flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none"
|
||||
/>
|
||||
{searchValue && (
|
||||
<button
|
||||
key={opt.value}
|
||||
type="button"
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault();
|
||||
handleSelect(opt.value);
|
||||
}}
|
||||
className={cn(
|
||||
"flex items-center justify-between w-full text-left px-3 py-2 text-sm transition-colors",
|
||||
"hover:bg-accent hover:text-accent-foreground",
|
||||
isSelected && "text-primary font-medium bg-primary/10",
|
||||
)}
|
||||
tabIndex={-1}
|
||||
onMouseDown={() => onSearchChange?.("")}
|
||||
className="text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<span>{opt.label}</span>
|
||||
{isSelected && <Check size={13} className="text-primary shrink-0" />}
|
||||
<X size={12} />
|
||||
</button>
|
||||
);
|
||||
})
|
||||
)}
|
||||
|
||||
{hasNextPage && (
|
||||
<div ref={sentinelRef} className="px-3 py-2 text-xs text-muted-foreground text-center">
|
||||
{isLoadingMore && (
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<Loader2 size={12} className="animate-spin" /> Loading...
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
||||
<div className="max-h-60 overflow-y-auto scrollbar-thin py-1">
|
||||
{loading && options.length === 0 ? (
|
||||
<p className="px-3 py-4 text-sm text-muted-foreground text-center flex items-center justify-center gap-2">
|
||||
<Loader2 size={14} className="animate-spin" /> Loading...
|
||||
</p>
|
||||
) : options.length === 0 ? (
|
||||
<p className="px-3 py-4 text-sm text-muted-foreground text-center">Netije tapylmady</p>
|
||||
) : (
|
||||
options.map((opt) => {
|
||||
const isSelected = opt.value === value;
|
||||
return (
|
||||
<button
|
||||
key={opt.value}
|
||||
type="button"
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault();
|
||||
handleSelect(opt.value);
|
||||
}}
|
||||
className={cn(
|
||||
"flex items-center justify-between w-full text-left px-3 py-2 text-sm transition-colors",
|
||||
"hover:bg-accent hover:text-accent-foreground",
|
||||
isSelected && "text-primary font-medium bg-primary/10",
|
||||
)}
|
||||
>
|
||||
<span>{opt.label}</span>
|
||||
{isSelected && <Check size={13} className="text-primary shrink-0" />}
|
||||
</button>
|
||||
);
|
||||
})
|
||||
)}
|
||||
|
||||
{hasNextPage && (
|
||||
<div ref={sentinelRef} className="px-3 py-2 text-xs text-muted-foreground text-center">
|
||||
{isLoadingMore && (
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<Loader2 size={12} className="animate-spin" /> Loading...
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</PopoverPrimitive.Content>
|
||||
</PopoverPrimitive.Portal>
|
||||
</PopoverPrimitive.Root>
|
||||
|
||||
{error && (
|
||||
<p className="mt-1.5 text-xs text-destructive font-medium flex items-center gap-1.5">
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Clock, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { STATUS_BADGE_VARIANTS, isStatusValue, getStatusLabel, type StatusValue } from "@/constants/statusOptions";
|
||||
|
||||
export const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: Clock,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
satisfied: CheckCircle2,
|
||||
processing: Clock,
|
||||
cancelled: XCircle,
|
||||
registered: CheckCircle2,
|
||||
};
|
||||
import { STATUS_ICONS, STATUS_BADGE_VARIANTS, isStatusValue, getStatusLabel } from "@/constants/statusOptions";
|
||||
|
||||
interface StatusCellProps {
|
||||
status: string;
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import type { ComponentType } from "react";
|
||||
import { Clock, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { SelectOption } from "@/components/formInput";
|
||||
import type { StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
export const STATUS_ICONS: Record<StatusValue, ComponentType> = {
|
||||
pending: Clock,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
// satisfied: CheckCircle2,
|
||||
// processing: Clock,
|
||||
// cancelled: XCircle,
|
||||
// registered: CheckCircle2,
|
||||
};
|
||||
|
||||
export const DEFAULT_STATUS_VALUES = ["pending", "approved", "rejected", "completed"] as const;
|
||||
|
||||
export const STATUS_VALUES = [
|
||||
"pending",
|
||||
"approved",
|
||||
"rejected",
|
||||
"completed",
|
||||
"satisfied",
|
||||
"processing",
|
||||
"cancelled",
|
||||
"registered",
|
||||
// "satisfied",
|
||||
// "processing",
|
||||
// "cancelled",
|
||||
// "registered",
|
||||
] as const;
|
||||
|
||||
export type StatusValue = (typeof STATUS_VALUES)[number];
|
||||
@@ -20,18 +35,23 @@ export const STATUS_OPTIONS: SelectOption[] = [
|
||||
{ value: "approved", label: "Approved" },
|
||||
{ value: "rejected", label: "Rejected" },
|
||||
{ value: "completed", label: "Completed" },
|
||||
{ value: "satisfied", label: "Satisfied" },
|
||||
{ value: "processing", label: "Processing" },
|
||||
{ value: "cancelled", label: "Cancelled" },
|
||||
{ value: "registered", label: "Registered" },
|
||||
];
|
||||
|
||||
type TranslateFn = TFunction | ((key: string, fallback?: string) => string);
|
||||
|
||||
export function getStatusOptions(t?: TranslateFn, prefix = "status"): SelectOption[] {
|
||||
if (!t) return STATUS_OPTIONS;
|
||||
export function getStatusOptions(
|
||||
t?: TranslateFn,
|
||||
prefix = "status",
|
||||
values: readonly StatusValue[] = DEFAULT_STATUS_VALUES,
|
||||
): SelectOption[] {
|
||||
if (!t) {
|
||||
return values.map((val) => ({
|
||||
value: val,
|
||||
label: STATUS_LABEL_FALLBACKS[val] ?? val,
|
||||
}));
|
||||
}
|
||||
|
||||
return STATUS_VALUES.map((val) => ({
|
||||
return values.map((val) => ({
|
||||
value: val,
|
||||
label: t(`${prefix}.${val}`, STATUS_LABEL_FALLBACKS[val] ?? val),
|
||||
}));
|
||||
@@ -42,10 +62,10 @@ export const STATUS_BADGE_VARIANTS: Record<StatusValue, StatusBadgeVariant> = {
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
completed: "info",
|
||||
satisfied: "success",
|
||||
processing: "info",
|
||||
cancelled: "error",
|
||||
registered: "default",
|
||||
// satisfied: "success",
|
||||
// processing: "info",
|
||||
// cancelled: "error",
|
||||
// registered: "default",
|
||||
};
|
||||
|
||||
export const STATUS_LABEL_FALLBACKS: Record<StatusValue, string> = {
|
||||
@@ -53,10 +73,10 @@ export const STATUS_LABEL_FALLBACKS: Record<StatusValue, string> = {
|
||||
approved: "Approved",
|
||||
rejected: "Rejected",
|
||||
completed: "Completed",
|
||||
satisfied: "Satisfied",
|
||||
processing: "Processing",
|
||||
cancelled: "Cancelled",
|
||||
registered: "Registered",
|
||||
// satisfied: "Satisfied",
|
||||
// processing: "Processing",
|
||||
// cancelled: "Cancelled",
|
||||
// registered: "Registered",
|
||||
};
|
||||
|
||||
export function isStatusValue(value: string): value is StatusValue {
|
||||
|
||||
@@ -46,6 +46,8 @@ export interface CardListParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
search?: string;
|
||||
user_id?: number;
|
||||
type?: number;
|
||||
}
|
||||
|
||||
// ─── API functions ────────────────────────────────────────────────────────────
|
||||
@@ -53,9 +55,9 @@ export interface CardListParams {
|
||||
export const cardTransactionsApi = {
|
||||
/** GET /cards */
|
||||
getAll: async (params: CardListParams = {}, signal?: AbortSignal): Promise<CardListResponse> => {
|
||||
const { page, limit, search } = params;
|
||||
const { page, limit, search, user_id, type } = params;
|
||||
const { data } = await apiClient.get<CardListResponse>("/cards", {
|
||||
params: { page, limit, search },
|
||||
params: { page, limit, search, user_id, type },
|
||||
signal,
|
||||
});
|
||||
return data;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useDebouncedValue, normalizeSearch } from "@/hooks/useDebouncedSearch";
|
||||
import {
|
||||
currencyRatesApi,
|
||||
type CurrencyRateListParams,
|
||||
@@ -21,9 +22,13 @@ export const currencyRateKeys = {
|
||||
// ─── List ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export function useGetCurrencyRates(params: CurrencyRateListParams = {}) {
|
||||
const debouncedSearch = useDebouncedValue(params.search ?? "");
|
||||
const normalized = normalizeSearch(debouncedSearch);
|
||||
const queryParams: CurrencyRateListParams = { ...params, search: normalized || undefined };
|
||||
|
||||
return useQuery({
|
||||
queryKey: currencyRateKeys.list(params),
|
||||
queryFn: ({ signal }) => currencyRatesApi.getList(params, signal),
|
||||
queryKey: currencyRateKeys.list(queryParams),
|
||||
queryFn: ({ signal }) => currencyRatesApi.getList(queryParams, signal),
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ export async function fetchLoanPaidOffLetters(
|
||||
params: {
|
||||
page,
|
||||
limit,
|
||||
customer_name: search || undefined,
|
||||
name: search || undefined,
|
||||
passport_id: passport_id || undefined,
|
||||
status: status || undefined,
|
||||
branch_id: branch_id || undefined,
|
||||
|
||||
@@ -1,69 +1,74 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useDebouncedValue, normalizeSearch } from "@/hooks/useDebouncedSearch";
|
||||
import {
|
||||
intlPaymentApi,
|
||||
type IntlPaymentListParams,
|
||||
type IntlPaymentCreatePayload,
|
||||
type IntlPaymentUpdatePayload,
|
||||
} from '../api/visaMasterPaymentsApi'
|
||||
} from "../api/visaMasterPaymentsApi";
|
||||
|
||||
export const INTL_PAYMENT_KEYS = {
|
||||
all: ['intl-payments-visa'] as const,
|
||||
lists: () => [...INTL_PAYMENT_KEYS.all, 'list'] as const,
|
||||
list: (p: IntlPaymentListParams) => [...INTL_PAYMENT_KEYS.lists(), p] as const,
|
||||
detail: (id: string) => [...INTL_PAYMENT_KEYS.all, 'detail', id] as const,
|
||||
}
|
||||
all: ["intl-payments-visa"] as const,
|
||||
lists: () => [...INTL_PAYMENT_KEYS.all, "list"] as const,
|
||||
list: (p: IntlPaymentListParams) => [...INTL_PAYMENT_KEYS.lists(), p] as const,
|
||||
detail: (id: string) => [...INTL_PAYMENT_KEYS.all, "detail", id] as const,
|
||||
};
|
||||
|
||||
export function useIntlPayments(params: IntlPaymentListParams) {
|
||||
const debouncedSearch = useDebouncedValue(params.search ?? "");
|
||||
const normalized = normalizeSearch(debouncedSearch);
|
||||
const queryParams: IntlPaymentListParams = { ...params, search: normalized || undefined };
|
||||
|
||||
return useQuery({
|
||||
queryKey: INTL_PAYMENT_KEYS.list(params),
|
||||
queryFn: () => intlPaymentApi.list(params),
|
||||
queryKey: INTL_PAYMENT_KEYS.list(queryParams),
|
||||
queryFn: () => intlPaymentApi.list(queryParams),
|
||||
placeholderData: (prev) => prev,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function useIntlPayment(id: string) {
|
||||
return useQuery({
|
||||
queryKey: INTL_PAYMENT_KEYS.detail(id),
|
||||
queryFn: () => intlPaymentApi.getById(id),
|
||||
enabled: !!id,
|
||||
})
|
||||
queryFn: () => intlPaymentApi.getById(id),
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateIntlPayment() {
|
||||
const qc = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
const qc = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
return useMutation({
|
||||
mutationFn: (payload: IntlPaymentCreatePayload) => intlPaymentApi.create(payload),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
toast.success(t('intlPayment.createSuccess', 'Töleg döredildi'))
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() });
|
||||
toast.success(t("intlPayment.createSuccess", "Töleg döredildi"));
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateIntlPayment(id: string) {
|
||||
const qc = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
const qc = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
return useMutation({
|
||||
mutationFn: (payload: IntlPaymentUpdatePayload) => intlPaymentApi.update(id, payload),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.detail(id) })
|
||||
toast.success(t('intlPayment.updateSuccess', 'Töleg üýtgedildi'))
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() });
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.detail(id) });
|
||||
toast.success(t("intlPayment.updateSuccess", "Töleg üýtgedildi"));
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteIntlPayment() {
|
||||
const qc = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
const qc = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => intlPaymentApi.delete(id),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
toast.success(t('intlPayment.deleteSuccess', 'Töleg pozuldy'))
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() });
|
||||
toast.success(t("intlPayment.deleteSuccess", "Töleg pozuldy"));
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ function NavSubGroup({ subItem, pathname }: { subItem: NavSubItem; pathname: str
|
||||
<CollapsibleTrigger asChild>
|
||||
<button
|
||||
className={cn(
|
||||
"flex w-full items-center justify-between px-2 py-1 mt-1",
|
||||
"flex w-full items-center justify-between px-2 py-1 mt-1 cursor-pointer",
|
||||
"text-[10px] font-semibold uppercase tracking-widest select-none",
|
||||
"text-sidebar-foreground/40 hover:text-sidebar-foreground/60 transition-colors duration-150 rounded-sm",
|
||||
)}
|
||||
@@ -158,7 +158,7 @@ function NavGroupItem({ item }: { item: NavItem }) {
|
||||
isActive={active}
|
||||
tooltip={item.title}
|
||||
className={cn(
|
||||
"group/btn rounded-md font-medium",
|
||||
"group/btn rounded-md font-medium cursor-pointer",
|
||||
"text-sidebar-foreground/70 hover:text-sidebar-foreground hover:bg-sidebar-accent/70",
|
||||
"data-[active=true]:text-sidebar-foreground data-[active=true]:bg-sidebar-accent",
|
||||
)}
|
||||
|
||||
@@ -65,7 +65,7 @@ export default function CardBalancesPage() {
|
||||
return {
|
||||
page,
|
||||
limit: perPage,
|
||||
search: search || undefined,
|
||||
passport_number: search || undefined,
|
||||
status: filterMap.status || undefined,
|
||||
created_by: filterMap.created_by ? Number(filterMap.created_by) : undefined,
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
// import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
@@ -214,15 +214,15 @@ export default function CardPinsPage() {
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("Card pins", "Kart pin bukjalary")}</h1>
|
||||
</div>
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput
|
||||
<div className="flex items-center gap-3 justify-end">
|
||||
{/* <TableSearchInput
|
||||
value={search}
|
||||
onChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
placeholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
/> */}
|
||||
<CreateButton label={t("cardPin.createBtn", "Kart pin bukja dörediň")} onClick={() => navigate("/card-pins/create")} />
|
||||
</div>
|
||||
<div className="bg-card border border-border rounded-xl p-4">
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
// import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
|
||||
@@ -336,15 +336,15 @@ export default function CardRequisitesPage() {
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("cardRequisites.title", "Kart rekwizitler")}</h1>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput
|
||||
<div className="flex items-center gap-3 justify-end">
|
||||
{/* <TableSearchInput
|
||||
value={search}
|
||||
onChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
placeholder={t("cardRequisites.searchPlaceholder", "Gözlemek")}
|
||||
/>
|
||||
/> */}
|
||||
<CreateButton
|
||||
label={t("cardRequisites.createTitle", "Kart rekwiziti üçin sargyt dörediň")}
|
||||
onClick={() => navigate("/card-requisites/create")}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { useState } from "react";
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { DataTableToolbar, type ColumnMeta, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
import { useCardTransactions, useDeleteCardTransaction } from "@/features/cardTransactions/hooks/useCardTransactions";
|
||||
import type { Card } from "@/features/cardTransactions/api/cardTransactionsApi";
|
||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -27,9 +28,121 @@ export default function CardTransactionsPage() {
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([]);
|
||||
|
||||
const { data, isLoading } = useCardTransactions({ page, limit: perPage, search });
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
|
||||
{ fieldId: "user_id", value: "" },
|
||||
{ fieldId: "type", value: "" },
|
||||
]);
|
||||
|
||||
// ── Filter option sources ───────────────────────────────────────────────────
|
||||
const [userSearch, setUserSearch] = useState("");
|
||||
const {
|
||||
data: usersData,
|
||||
fetchNextPage: fetchNextUsers,
|
||||
hasNextPage: hasNextUsers,
|
||||
isFetchingNextPage: isFetchingNextUsers,
|
||||
isLoading: isUsersLoading,
|
||||
} = useInfiniteClients(userSearch);
|
||||
|
||||
const userOptions = useMemo(
|
||||
() =>
|
||||
(usersData?.pages ?? []).flatMap((page) =>
|
||||
(page?.users ?? []).map((u) => ({
|
||||
value: String(u.id),
|
||||
label: u.name || u.username || String(u.id),
|
||||
})),
|
||||
),
|
||||
[usersData],
|
||||
);
|
||||
|
||||
const [typeSearch, setTypeSearch] = useState("");
|
||||
const {
|
||||
data: cardTypesData,
|
||||
fetchNextPage: fetchNextCardTypes,
|
||||
hasNextPage: hasNextCardTypes,
|
||||
isFetchingNextPage: isFetchingNextCardTypes,
|
||||
isLoading: isCardTypesLoading,
|
||||
} = useInfiniteCardTypes(typeSearch);
|
||||
|
||||
const cardTypeOptions = useMemo(() => {
|
||||
const langKey = i18n.language as "tm" | "ru" | "en";
|
||||
return (cardTypesData?.pages ?? []).flatMap((p) =>
|
||||
(p?.paymentCards ?? []).map((c) => ({
|
||||
value: String(c.id),
|
||||
label: c.title?.[langKey] || c.title?.tm || c.title?.en || String(c.id),
|
||||
})),
|
||||
);
|
||||
}, [cardTypesData, i18n.language]);
|
||||
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
const queryParams = useMemo(() => {
|
||||
const filterMap = Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value]));
|
||||
return {
|
||||
search: search || undefined,
|
||||
user_id: filterMap.user_id ? Number(filterMap.user_id) : undefined,
|
||||
type: filterMap.type ? Number(filterMap.type) : undefined,
|
||||
page,
|
||||
limit: perPage,
|
||||
};
|
||||
}, [search, activeFilters, page, perPage]);
|
||||
|
||||
const { data, isLoading } = useCardTransactions(queryParams);
|
||||
const deleteMutation = useDeleteCardTransaction();
|
||||
|
||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
||||
setPage(1);
|
||||
}, []);
|
||||
|
||||
const handleFilterReset = useCallback(() => {
|
||||
setActiveFilters((prev) => prev.map((f) => ({ ...f, value: "" })));
|
||||
setPage(1);
|
||||
}, []);
|
||||
|
||||
// ── Filter fields ───────────────────────────────────────────────────────────
|
||||
const filterFields = useMemo<FilterField[]>(
|
||||
() => [
|
||||
{
|
||||
id: "user_id",
|
||||
label: t("User", "ULANYJY"),
|
||||
type: "infinite-select",
|
||||
options: userOptions,
|
||||
loading: isUsersLoading,
|
||||
isLoadingMore: isFetchingNextUsers,
|
||||
hasNextPage: hasNextUsers,
|
||||
onLoadMore: fetchNextUsers,
|
||||
searchValue: userSearch,
|
||||
onSearchChange: setUserSearch,
|
||||
},
|
||||
{
|
||||
id: "type",
|
||||
label: t("Card type", "KART GÖRNÜŞI"),
|
||||
type: "infinite-select",
|
||||
options: cardTypeOptions,
|
||||
loading: isCardTypesLoading,
|
||||
isLoadingMore: isFetchingNextCardTypes,
|
||||
hasNextPage: hasNextCardTypes,
|
||||
onLoadMore: fetchNextCardTypes,
|
||||
searchValue: typeSearch,
|
||||
onSearchChange: setTypeSearch,
|
||||
},
|
||||
],
|
||||
[
|
||||
t,
|
||||
userOptions,
|
||||
isUsersLoading,
|
||||
isFetchingNextUsers,
|
||||
hasNextUsers,
|
||||
userSearch,
|
||||
fetchNextUsers,
|
||||
cardTypeOptions,
|
||||
isCardTypesLoading,
|
||||
isFetchingNextCardTypes,
|
||||
hasNextCardTypes,
|
||||
typeSearch,
|
||||
fetchNextCardTypes,
|
||||
],
|
||||
);
|
||||
|
||||
// ── Columns ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const columns: ColumnDef<Card>[] = [
|
||||
@@ -152,15 +265,15 @@ export default function CardTransactionsPage() {
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("Card transactions", "Kartlar")}</h1>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput
|
||||
<div className="flex items-center gap-3 justify-end">
|
||||
{/* <TableSearchInput
|
||||
value={search}
|
||||
onChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
placeholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
/> */}
|
||||
<CreateButton label={t("Create card", "Kart dörediň")} onClick={() => navigate("/card-transactions/create")} />
|
||||
</div>
|
||||
|
||||
@@ -180,6 +293,10 @@ export default function CardTransactionsPage() {
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
hideSearch
|
||||
hideAction
|
||||
filterFields={filterFields}
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(v) => {
|
||||
|
||||
@@ -173,7 +173,11 @@ export default function CurrencyRatesPage() {
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("currencyRates.title", "Walýuta kurslary")}</h1>
|
||||
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("common.search", "Gözlemek")} />
|
||||
<TableSearchInput
|
||||
value={search}
|
||||
onChange={handleSearchChange}
|
||||
placeholder={t("currencyRates.searchPlaceholder", "Walýuta boýunça gözle (möw. CNY → TMT)")}
|
||||
/>
|
||||
<CreateButton
|
||||
label={t("currencyRates.actions.create", "Walýuta kursy dörediň")}
|
||||
onClick={() => navigate("/currency-rates/create")}
|
||||
@@ -186,7 +190,7 @@ export default function CurrencyRatesPage() {
|
||||
hideAction
|
||||
searchValue={search}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
searchPlaceholder={t("currencyRates.searchPlaceholder", "Walýuta boýunça gözle (möw. CNY → TMT)")}
|
||||
columns={toggleableColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
|
||||
@@ -379,12 +379,12 @@ export default function DashboardPage({ isLoading: propLoading = false }: { isLo
|
||||
|
||||
<div className="flex items-center gap-2 self-start sm:self-auto">
|
||||
<Select value={String(selectedYear)} onValueChange={(val) => setSelectedYear(Number(val))}>
|
||||
<SelectTrigger className="w-[120px] h-9">
|
||||
<SelectTrigger className="w-[120px] h-9 cursor-pointer">
|
||||
<SelectValue placeholder={String(selectedYear)} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{yearOptions.map((y) => (
|
||||
<SelectItem key={y} value={String(y)}>
|
||||
<SelectItem key={y} value={String(y)} className="cursor-pointer">
|
||||
{y} {t("common.year", "ýyl")}
|
||||
</SelectItem>
|
||||
))}
|
||||
@@ -397,7 +397,7 @@ export default function DashboardPage({ isLoading: propLoading = false }: { isLo
|
||||
onClick={() => refetch()}
|
||||
disabled={isFetching}
|
||||
title={t("common.refresh", "Täzele")}
|
||||
className="h-9 w-9"
|
||||
className="h-9 w-9 cursor-pointer"
|
||||
>
|
||||
<RefreshCw className={cn("h-4 w-4", isFetching && "animate-spin")} />
|
||||
</Button>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { MonthSelect } from "@/components/monthSelect";
|
||||
// import { MonthSelect } from "@/components/monthSelect";
|
||||
import { InfiniteSelect } from "@/components/infiniteSelect";
|
||||
import { REGION_CODES, REGION_LABELS, StatusCell } from "@/constants";
|
||||
import { useIntlPayments, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
@@ -36,7 +36,7 @@ export default function IntlPaymentsPage() {
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
const [search, setSearch] = useState("");
|
||||
const [month, setMonth] = useState("");
|
||||
const [month] = useState("");
|
||||
const [statusFilter, setStatusFilter] = useState<IntlPaymentStatus | "">("");
|
||||
const [regionFilter, setRegionFilter] = useState("");
|
||||
const [branchFilter, setBranchFilter] = useState("");
|
||||
@@ -263,13 +263,13 @@ export default function IntlPaymentsPage() {
|
||||
placeholder={t("intlPayment.client", "Ulanyjy")}
|
||||
/>
|
||||
</div>
|
||||
<MonthSelect
|
||||
{/* <MonthSelect
|
||||
value={month}
|
||||
onChange={(v) => {
|
||||
setMonth(v);
|
||||
setPage(1);
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
// import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
@@ -227,15 +227,15 @@ export default function LoanOrderMobilesPage() {
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("loanOrderMobiles.title", "Karz sargytlary (Mobile)")}</h1>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput
|
||||
<div className="flex items-center gap-3 justify-end">
|
||||
{/* <TableSearchInput
|
||||
value={search}
|
||||
onChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
placeholder={t("loanOrderMobiles.searchPlaceholder", "Gözlemek")}
|
||||
/>
|
||||
/> */}
|
||||
<CreateButton
|
||||
label={t("loanOrderMobiles.createButton", "Karz sargyt dörediñ")}
|
||||
onClick={() => navigate("/loan-order-mobiles/create")}
|
||||
|
||||
@@ -5,7 +5,6 @@ import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { useLoanOrders, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
@@ -49,7 +48,6 @@ export default function LoanOrdersPage() {
|
||||
[branchesInfiniteData, lang],
|
||||
);
|
||||
|
||||
const [search, setSearch] = useState("");
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
@@ -63,14 +61,13 @@ export default function LoanOrdersPage() {
|
||||
const queryParams = useMemo(() => {
|
||||
const filterMap = Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value]));
|
||||
return {
|
||||
search: search || undefined,
|
||||
region: filterMap.region || undefined,
|
||||
status: (filterMap.status as LoanOrderStatus) || undefined,
|
||||
branch: filterMap.branch || undefined,
|
||||
page,
|
||||
perPage,
|
||||
};
|
||||
}, [search, activeFilters, page, perPage]);
|
||||
}, [activeFilters, page, perPage]);
|
||||
|
||||
const { data, isLoading } = useLoanOrders(queryParams);
|
||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1;
|
||||
@@ -216,16 +213,7 @@ export default function LoanOrdersPage() {
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("loanOrders.title", "Karz sargytlary")}</h1>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput
|
||||
value={search}
|
||||
onChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
placeholder={t("loanOrderMobiles.searchPlaceholder", "Gözlemek")}
|
||||
/>
|
||||
<div className="flex items-center gap-3 justify-end">
|
||||
<CreateButton label={t("loanOrderMobiles.createButton", "Karz sargyt dörediñ")} onClick={() => navigate("/loan-orders/create")} />
|
||||
</div>
|
||||
|
||||
@@ -233,12 +221,8 @@ export default function LoanOrdersPage() {
|
||||
<DataTableToolbar
|
||||
hideSearch
|
||||
hideAction
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("loanOrderMobiles.searchPlaceholder", "Gözlemek")}
|
||||
searchValue=""
|
||||
onSearchChange={() => {}}
|
||||
columns={toggleableColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
|
||||
@@ -135,7 +135,7 @@ export default function LoanRemainingPage() {
|
||||
setSearch(v);
|
||||
setPage(1);
|
||||
}}
|
||||
placeholder={t("common.search", "Gözlemek")}
|
||||
placeholder={t("loanRemaining.searchPlaceholder", "Passport series")}
|
||||
/>
|
||||
<CreateButton
|
||||
label={t("loanRemaining.createButton", "Karzyň galyndysy dörediň")}
|
||||
|
||||
Reference in New Issue
Block a user