fixed some statuses and filters
This commit is contained in:
1 parent
34e8fef9b6
commit
edf503e329
20 files changed
+355
-214
No files matched your search
@@ -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