fixed some params and ui

This commit is contained in:
Jelaletdin12 committed 2026-08-25 22:58:08 +05:00
1 parent f00d2abcac
commit f293806d96
25 files changed
+547 -87

No files matched your search

+105 -19
View File
@@ -14,9 +14,9 @@ import { DeleteDialog } from "@/components/deleteDialog";
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
import { useCards, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
import type { CardOrder } from "@/features/orderNewCard/api/orderNewCardApi";
import { useBranches } from "@/features/branches/hooks/useBranches";
import { useDistricts } from "@/features/districts/hooks/useDistricts";
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { useInfiniteDistricts } from "@/features/districts/hooks/useDistricts";
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
const PER_PAGE = 25;
@@ -64,9 +64,33 @@ export default function CardOrdersPage() {
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>(INITIAL_FILTERS);
// ── Dropdown data ──────────────────────────────────────────────────────────
const { data: branchesData } = useBranches({ page, limit: 25 });
const { data: districtsData } = useDistricts({ page, limit: 25 });
const { data: cardTypesData } = useCardTypes({ page, limit: 25 });
const [branchSearch, setBranchSearch] = useState("");
const [districtSearch, setDistrictSearch] = useState("");
const [cardTypeSearch, setCardTypeSearch] = useState("");
const {
data: branchesInfiniteData,
fetchNextPage: fetchNextBranches,
hasNextPage: hasNextBranches,
isFetchingNextPage: isFetchingNextBranches,
isLoading: isBranchesLoading,
} = useInfiniteBranches(branchSearch);
const {
data: districtsInfiniteData,
fetchNextPage: fetchNextDistricts,
hasNextPage: hasNextDistricts,
isFetchingNextPage: isFetchingNextDistricts,
isLoading: isDistrictsLoading,
} = useInfiniteDistricts(districtSearch);
const {
data: cardTypesInfiniteData,
fetchNextPage: fetchNextCardTypes,
hasNextPage: hasNextCardTypes,
isFetchingNextPage: isFetchingNextCardTypes,
isLoading: isCardTypesLoading,
} = useInfiniteCardTypes(cardTypeSearch);
// ── Query ──────────────────────────────────────────────────────────────────
const getFilter = useCallback((id: FilterId) => activeFilters.find((f) => f.fieldId === id)?.value ?? "", [activeFilters]);
@@ -183,6 +207,39 @@ export default function CardOrdersPage() {
const total = data?.count ?? 0;
const totalPages = Math.ceil(total / perPage);
const branchOptions = useMemo(
() =>
(branchesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
})),
),
[branchesInfiniteData, lang],
);
const districtOptions = useMemo(
() =>
(districtsInfiniteData?.pages ?? []).flatMap((page) =>
(page?.provinces ?? []).map((d) => ({
value: d.region?.tm || d.name.tm,
label: d.name[lang] || d.name.tm,
})),
),
[districtsInfiniteData, lang],
);
const cardTypeOptions = useMemo(
() =>
(cardTypesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.paymentCards ?? []).map((ct) => ({
value: String(ct.id),
label: ct.title[lang] || ct.title.tm,
})),
),
[cardTypesInfiniteData, lang],
);
// ── Filter fields ──────────────────────────────────────────────────────────
const filterFields = useMemo<FilterField[]>(
() => [
@@ -194,18 +251,26 @@ export default function CardOrdersPage() {
{
id: "branch_id",
label: t("cardOrder.filter.branch", "Şahamça"),
options: (branchesData?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
})),
type: "infinite-select",
options: branchOptions,
loading: isBranchesLoading,
isLoadingMore: isFetchingNextBranches,
hasNextPage: hasNextBranches,
onLoadMore: fetchNextBranches,
searchValue: branchSearch,
onSearchChange: setBranchSearch,
},
{
id: "region",
label: t("cardOrder.filter.region", "Sebit"),
options: (districtsData?.provinces ?? []).map((d) => ({
value: d.region?.tm || d.name.tm,
label: d.name[lang] || d.name.tm,
})),
type: "infinite-select",
options: districtOptions,
loading: isDistrictsLoading,
isLoadingMore: isFetchingNextDistricts,
hasNextPage: hasNextDistricts,
onLoadMore: fetchNextDistricts,
searchValue: districtSearch,
onSearchChange: setDistrictSearch,
},
{
id: "user_id",
@@ -220,13 +285,34 @@ export default function CardOrdersPage() {
{
id: "card_type_id",
label: t("cardOrder.filter.cardTypeId", "Kart görnüşi"),
options: (cardTypesData?.paymentCards ?? []).map((ct) => ({
value: String(ct.id),
label: ct.title[lang] || ct.title.tm,
})),
type: "infinite-select",
options: cardTypeOptions,
loading: isCardTypesLoading,
isLoadingMore: isFetchingNextCardTypes,
hasNextPage: hasNextCardTypes,
onLoadMore: fetchNextCardTypes,
searchValue: cardTypeSearch,
onSearchChange: setCardTypeSearch,
},
],
[t, lang, branchesData, districtsData, cardTypesData],
[
t,
branchOptions,
isBranchesLoading,
isFetchingNextBranches,
hasNextBranches,
branchSearch,
districtOptions,
isDistrictsLoading,
isFetchingNextDistricts,
hasNextDistricts,
districtSearch,
cardTypeOptions,
isCardTypesLoading,
isFetchingNextCardTypes,
hasNextCardTypes,
cardTypeSearch,
],
);
const handleFilterChange = useCallback((fieldId: string, value: string) => {
@@ -15,7 +15,7 @@ import {
} from "@/components/ui/alert-dialog";
import { Skeleton } from "@/components/ui/skeleton";
import { useCardById, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
@@ -188,10 +188,10 @@ export default function CardOrderDetailPage() {
</BentoCard>
<BentoCard title={t("cardOrder.section.passportParts", "Pasport bölekleri")}>
<InfoRow label={t("cardOrder.field.passportOne", "Pasport 1")} value={order.passportOne || "—"} />
<InfoRow label={t("cardOrder.field.passportTwo", "Pasport 2")} value={order.passportTwo || "—"} />
<InfoRow label={t("cardOrder.field.passportThree", "Pasport 3")} value={order.passportThree || "—"} />
<InfoRow label={t("cardOrder.field.passportFour", "Pasport 4")} value={order.passportFour || "—"} />
<PassportImage label={t("cardOrder.field.passportOne", "Pasport 1")} src={order.passportOne || "—"} />
<PassportImage label={t("cardOrder.field.passportTwo", "Pasport 2")} src={order.passportTwo || "—"} />
<PassportImage label={t("cardOrder.field.passportThree", "Pasport 3")} src={order.passportThree || "—"} />
<PassportImage label={t("cardOrder.field.passportFour", "Pasport 4")} src={order.passportFour || "—"} />
<InfoRow
label={t("cardOrder.field.updatedAt", "Täzelenen wagty")}
value={order.updatedAt ? new Date(order.updatedAt).toLocaleString() : "—"}