fixed some statuses and filters

This commit is contained in:
Jelaletdin12
2026-09-10 15:59:05 +05:00
parent 34e8fef9b6
commit edf503e329
20 changed files with 355 additions and 214 deletions

View File

@@ -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;

View File

@@ -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,
});
}

View File

@@ -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,

View File

@@ -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"));
},
})
});
}