added payment history, setting pages
This commit is contained in:
@@ -36,7 +36,8 @@ export default function CardBalancesPage() {
|
||||
{ fieldId: "created_by", value: "" },
|
||||
]);
|
||||
|
||||
// ── Infinite user dropdown for created_by filter ────────────────────────────
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const isUserFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "created_by")?.value);
|
||||
|
||||
const [userSearch, setUserSearch] = useState("");
|
||||
const {
|
||||
@@ -45,7 +46,7 @@ export default function CardBalancesPage() {
|
||||
hasNextPage: hasNextUsers,
|
||||
isFetchingNextPage: isFetchingNextUsers,
|
||||
isLoading: isUsersLoading,
|
||||
} = useInfiniteUsers(userSearch);
|
||||
} = useInfiniteUsers(userSearch, isUserFilterEnabled);
|
||||
|
||||
const userOptions = useMemo(
|
||||
() =>
|
||||
@@ -286,6 +287,9 @@ export default function CardBalancesPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -48,6 +48,11 @@ export default function CardRequisitesPage() {
|
||||
|
||||
// ── Infinite dropdown hooks ─────────────────────────────────────────────────
|
||||
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const isBranchFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "branch_id")?.value);
|
||||
const isCardTypeFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "card_type_id")?.value);
|
||||
const isUserFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "user_id")?.value);
|
||||
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const {
|
||||
data: branchesInfiniteData,
|
||||
@@ -55,7 +60,7 @@ export default function CardRequisitesPage() {
|
||||
hasNextPage: hasNextBranches,
|
||||
isFetchingNextPage: isFetchingNextBranches,
|
||||
isLoading: isBranchesLoading,
|
||||
} = useInfiniteBranches(branchSearch);
|
||||
} = useInfiniteBranches(branchSearch, isBranchFilterEnabled);
|
||||
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
@@ -75,7 +80,7 @@ export default function CardRequisitesPage() {
|
||||
hasNextPage: hasNextCardTypes,
|
||||
isFetchingNextPage: isFetchingNextCardTypes,
|
||||
isLoading: isCardTypesLoading,
|
||||
} = useInfiniteCardTypes(cardTypeSearch);
|
||||
} = useInfiniteCardTypes(cardTypeSearch, isCardTypeFilterEnabled);
|
||||
|
||||
const cardTypeOptions = useMemo(
|
||||
() =>
|
||||
@@ -95,7 +100,7 @@ export default function CardRequisitesPage() {
|
||||
hasNextPage: hasNextClients,
|
||||
isFetchingNextPage: isFetchingNextClients,
|
||||
isLoading: isClientsLoading,
|
||||
} = useInfiniteClients(userSearch);
|
||||
} = useInfiniteClients(userSearch, isUserFilterEnabled);
|
||||
|
||||
const clientOptions = useMemo(
|
||||
() =>
|
||||
@@ -390,6 +395,9 @@ export default function CardRequisitesPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -34,6 +34,10 @@ export default function CardTransactionsPage() {
|
||||
]);
|
||||
|
||||
// ── Filter option sources ───────────────────────────────────────────────────
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const isUserFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "user_id")?.value);
|
||||
const isCardTypeFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "type")?.value);
|
||||
|
||||
const [userSearch, setUserSearch] = useState("");
|
||||
const {
|
||||
data: usersData,
|
||||
@@ -41,7 +45,7 @@ export default function CardTransactionsPage() {
|
||||
hasNextPage: hasNextUsers,
|
||||
isFetchingNextPage: isFetchingNextUsers,
|
||||
isLoading: isUsersLoading,
|
||||
} = useInfiniteClients(userSearch);
|
||||
} = useInfiniteClients(userSearch, isUserFilterEnabled);
|
||||
|
||||
const userOptions = useMemo(
|
||||
() =>
|
||||
@@ -61,7 +65,7 @@ export default function CardTransactionsPage() {
|
||||
hasNextPage: hasNextCardTypes,
|
||||
isFetchingNextPage: isFetchingNextCardTypes,
|
||||
isLoading: isCardTypesLoading,
|
||||
} = useInfiniteCardTypes(typeSearch);
|
||||
} = useInfiniteCardTypes(typeSearch, isCardTypeFilterEnabled);
|
||||
|
||||
const cardTypeOptions = useMemo(() => {
|
||||
const langKey = i18n.language as "tm" | "ru" | "en";
|
||||
@@ -316,6 +320,9 @@ export default function CardTransactionsPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -48,17 +48,24 @@ export default function CardOrdersPage() {
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([]);
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>(INITIAL_FILTERS);
|
||||
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
const getFilter = useCallback((id: FilterId) => activeFilters.find((f) => f.fieldId === id)?.value ?? "", [activeFilters]);
|
||||
|
||||
// ── Dropdown data ──────────────────────────────────────────────────────────
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [cardTypeSearch, setCardTypeSearch] = useState("");
|
||||
|
||||
const isBranchFilterEnabled = filterEnabled || Boolean(getFilter("branch_id"));
|
||||
const isCardTypeFilterEnabled = filterEnabled || Boolean(getFilter("card_type_id"));
|
||||
|
||||
const {
|
||||
data: branchesInfiniteData,
|
||||
fetchNextPage: fetchNextBranches,
|
||||
hasNextPage: hasNextBranches,
|
||||
isFetchingNextPage: isFetchingNextBranches,
|
||||
isLoading: isBranchesLoading,
|
||||
} = useInfiniteBranches(branchSearch);
|
||||
} = useInfiniteBranches(branchSearch, isBranchFilterEnabled);
|
||||
|
||||
const {
|
||||
data: cardTypesInfiniteData,
|
||||
@@ -66,10 +73,7 @@ export default function CardOrdersPage() {
|
||||
hasNextPage: hasNextCardTypes,
|
||||
isFetchingNextPage: isFetchingNextCardTypes,
|
||||
isLoading: isCardTypesLoading,
|
||||
} = useInfiniteCardTypes(cardTypeSearch);
|
||||
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
const getFilter = useCallback((id: FilterId) => activeFilters.find((f) => f.fieldId === id)?.value ?? "", [activeFilters]);
|
||||
} = useInfiniteCardTypes(cardTypeSearch, isCardTypeFilterEnabled);
|
||||
|
||||
const queryParams = useMemo(
|
||||
() => ({
|
||||
@@ -384,6 +388,9 @@ export default function CardOrdersPage() {
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// pages/VisaMasterSettingsPage.tsx
|
||||
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -13,12 +11,8 @@ import { CreateButton } from "@/components/createButton";
|
||||
import { useGetVisaMasterSettings, useDeleteVisaMasterSetting } from "@/features/visaMasterSberSettings/hooks/useVisaMasterSettings";
|
||||
import type { VisaMasterSetting } from "@/features/visaMasterSberSettings/api/visaMasterSberSettingsApi";
|
||||
|
||||
// ─── Column defaults ──────────────────────────────────────────────────────────
|
||||
|
||||
const DEFAULT_VISIBILITY = { id: true, kod: true, ady: true, yazgy: true };
|
||||
const DEFAULT_ORDER = ["id", "kod", "ady", "yazgy", "actions"];
|
||||
|
||||
// ─── VisaMasterSettingsPage ───────────────────────────────────────────────────
|
||||
const DEFAULT_VISIBILITY = { code: true, name: true, text: true, isActive: true, updatedAt: true, updatedByName: true };
|
||||
const DEFAULT_ORDER = ["code", "name", "text", "isActive", "updatedAt", "updatedByName", "actions"];
|
||||
|
||||
export default function VisaMasterSettingsPage() {
|
||||
const { t } = useTranslation();
|
||||
@@ -29,15 +23,19 @@ export default function VisaMasterSettingsPage() {
|
||||
const [search, setSearch] = useState("");
|
||||
const [columnVisibility, setColumnVisibility] = useState<Record<string, boolean>>(DEFAULT_VISIBILITY);
|
||||
const [columnOrder, setColumnOrder] = useState(DEFAULT_ORDER);
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null);
|
||||
const [deleteCode, setDeleteCode] = useState<string | null>(null);
|
||||
|
||||
const { data, isLoading } = useGetVisaMasterSettings({ page, perPage, search });
|
||||
const deleteMutation = useDeleteVisaMasterSetting();
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (deleteId === null) return;
|
||||
await deleteMutation.mutateAsync(deleteId);
|
||||
setDeleteId(null);
|
||||
if (deleteCode === null) return;
|
||||
try {
|
||||
await deleteMutation.mutateAsync(deleteCode);
|
||||
setDeleteCode(null);
|
||||
} catch {
|
||||
// error toast handled in hook
|
||||
}
|
||||
};
|
||||
|
||||
const handleSearchChange = (val: string) => {
|
||||
@@ -45,29 +43,43 @@ export default function VisaMasterSettingsPage() {
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
// ─── Columns ──────────────────────────────────────────────────────────────
|
||||
|
||||
const columns: ColumnDef<VisaMasterSetting>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "ID",
|
||||
cell: ({ row }) => <span className="text-primary font-semibold">{row.original.id}</span>,
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
accessorKey: "kod",
|
||||
accessorKey: "code",
|
||||
header: t("visaMasterSettings.columns.kod", "KOD"),
|
||||
cell: ({ row }) => <span className="font-medium text-foreground font-mono text-xs">{row.original.kod}</span>,
|
||||
cell: ({ row }) => <span className="font-medium text-primary font-mono text-xs">{row.original.code}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "ady",
|
||||
accessorKey: "name",
|
||||
header: t("visaMasterSettings.columns.ady", "ADY"),
|
||||
cell: ({ row }) => <span className="text-foreground">{row.original.ady}</span>,
|
||||
cell: ({ row }) => <span className="text-foreground">{row.original.name}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "yazgy",
|
||||
id: "text",
|
||||
accessorFn: (row) => row.text?.tm ?? "",
|
||||
header: t("visaMasterSettings.columns.yazgy", "YAZGY"),
|
||||
cell: ({ row }) => <span className="text-foreground line-clamp-1 max-w-xs">{row.original.yazgy}</span>,
|
||||
cell: ({ row }) => <span className="text-foreground line-clamp-1 max-w-xs">{row.original.text?.tm}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "isActive",
|
||||
header: t("visaMasterSettings.columns.isActive", "AKTIW"),
|
||||
cell: ({ row }) => (
|
||||
<span className={row.original.isActive ? "text-green-600" : "text-muted-foreground"}>
|
||||
{row.original.isActive ? t("common.yes", "Hawa") : t("common.no", "Ýok")}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "updatedAt",
|
||||
header: t("visaMasterSettings.columns.updatedAt", "ÜÝTGEDILEN"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-foreground text-xs">{row.original.updatedAt ? new Date(row.original.updatedAt).toLocaleString() : "—"}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "updatedByName",
|
||||
header: t("visaMasterSettings.columns.updatedBy", "ÜÝTGEDEN"),
|
||||
cell: ({ row }) => <span className="text-foreground">{row.original.updatedByName || "—"}</span>,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
@@ -76,8 +88,8 @@ export default function VisaMasterSettingsPage() {
|
||||
enableHiding: false,
|
||||
cell: ({ row }) => (
|
||||
<TableActions
|
||||
onEdit={() => navigate(`/visa-master-sber-settings/${row.original.id}/edit`)}
|
||||
onDelete={() => setDeleteId(row.original.id)}
|
||||
onEdit={() => navigate(`/visa-master-sber-settings/${encodeURIComponent(row.original.code)}/edit`)}
|
||||
onDelete={() => setDeleteCode(row.original.code)}
|
||||
/>
|
||||
),
|
||||
size: 100,
|
||||
@@ -85,14 +97,12 @@ export default function VisaMasterSettingsPage() {
|
||||
];
|
||||
|
||||
const columnMeta = columns
|
||||
.filter((c) => "accessorKey" in c && c.accessorKey)
|
||||
.filter((c) => c.id !== "actions")
|
||||
.map((c) => ({
|
||||
id: String(("accessorKey" in c ? c.accessorKey : c.id) ?? ""),
|
||||
label: typeof c.header === "string" ? c.header : String(("accessorKey" in c ? c.accessorKey : "") ?? ""),
|
||||
label: typeof c.header === "string" ? c.header : String(("accessorKey" in c ? c.accessorKey : c.id) ?? ""),
|
||||
}));
|
||||
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("visaMasterSettings.title", "Visa/Master, Sber sazlamalar")}</h1>
|
||||
@@ -112,7 +122,7 @@ export default function VisaMasterSettingsPage() {
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
getRowId={(row) => row.code}
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total ?? 0}
|
||||
@@ -133,11 +143,10 @@ export default function VisaMasterSettingsPage() {
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Delete Confirmation */}
|
||||
<DeleteDialog
|
||||
open={deleteId !== null}
|
||||
open={deleteCode !== null}
|
||||
onOpenChange={(o) => {
|
||||
if (!o) setDeleteId(null);
|
||||
if (!o) setDeleteCode(null);
|
||||
}}
|
||||
title={t("visaMasterSettings.deleteDialog.title", "Pozmak isleýärsiňizmi?")}
|
||||
description={t("visaMasterSettings.deleteDialog.description", "Bu amal yzyna gaýtarylyp bilinmez. Sazlama hemişelik pozular.")}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { VisaMasterSettingForm } from '@/features/visaMasterSberSettings/components/visaMasterSberSettingsForm'
|
||||
import { VisaMasterSettingForm } from "@/features/visaMasterSberSettings/components/visaMasterSberSettingsForm";
|
||||
|
||||
export default function VisaMasterSettingCreatePage() {
|
||||
return <VisaMasterSettingForm mode="create" />
|
||||
return <VisaMasterSettingForm mode="create" />;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { VisaMasterSettingForm } from '@/features/visaMasterSberSettings/components/visaMasterSberSettingsForm'
|
||||
import { useGetVisaMasterSettingById } from '@/features/visaMasterSberSettings/hooks/useVisaMasterSettings'
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { VisaMasterSettingForm } from "@/features/visaMasterSberSettings/components/visaMasterSberSettingsForm";
|
||||
import { useGetVisaMasterSettingByCode } from "@/features/visaMasterSberSettings/hooks/useVisaMasterSettings";
|
||||
|
||||
export default function VisaMasterSettingEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
const numericId = Number(id)
|
||||
const { data: setting, isLoading } = useGetVisaMasterSettingById(numericId)
|
||||
const { t } = useTranslation();
|
||||
const { code } = useParams<{ code: string }>();
|
||||
const { data, isLoading, isError } = useGetVisaMasterSettingByCode(code);
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!setting) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
if (isLoading) {
|
||||
return <div className="text-muted-foreground">{t("common.loading", "Ýüklenýär...")}</div>;
|
||||
}
|
||||
|
||||
return <VisaMasterSettingForm mode="edit" initialData={setting} />
|
||||
if (isError || !data) {
|
||||
return <div className="text-destructive">{t("common.notFound", "Maglumat tapylmady")}</div>;
|
||||
}
|
||||
|
||||
// key forces the form to re-init if the code changes
|
||||
return <VisaMasterSettingForm key={data.code} mode="edit" initialData={data} />;
|
||||
}
|
||||
|
||||
@@ -1,245 +1,257 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { format } from "date-fns";
|
||||
import { Edit, ArrowUpDown } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta, type FilterField, type ActiveFilter } from "@/components/dataTableToolbar";
|
||||
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 { MonthSelect } from "@/components/monthSelect";
|
||||
import { useSberPaymentOrders, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import { type SberPaymentOrder, WELAYATLAR, STATUSES } from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import { InfiniteSelect } from "@/components/infiniteSelect";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { StatusCell, REGION_CODES, REGION_LABELS } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
import { useSberPayments, useDeleteSberPaymentReal } from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||
import type { SberPaymentOrderItem, SberPaymentStatus } from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
// ─── Column Definitions ───────────────────────────────────────────────────────
|
||||
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
||||
|
||||
// ─── Column Meta for Toolbar ──────────────────────────────────────────────────
|
||||
|
||||
function getColumnMeta(t: (key: string, fallback?: string) => string): ColumnMeta[] {
|
||||
return [
|
||||
{ id: "id", label: t("sberPayments.columns.id", "ID") },
|
||||
{ id: "createdAt", label: t("sberPayments.columns.createdAt", "Döredilen wagty") },
|
||||
{ id: "welayat", label: t("sberPayments.columns.welayat", "Welaýat") },
|
||||
{ id: "sahamca", label: t("sberPayments.columns.sahamca", "Şahamça") },
|
||||
{ id: "firstName", label: t("sberPayments.columns.firstName", "Ady") },
|
||||
{ id: "lastName", label: t("sberPayments.columns.lastName", "Familiýasy") },
|
||||
{ id: "phone", label: t("sberPayments.columns.phone", "Telefon") },
|
||||
{ id: "status", label: t("sberPayments.columns.status", "Status") },
|
||||
{ id: "paidStatus", label: t("sberPayments.columns.paidStatus", "Tölenen (şul aý)") },
|
||||
];
|
||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang: string): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
const key = lang === "tk" ? "tm" : lang;
|
||||
return name[key as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── Filter Fields ────────────────────────────────────────────────────────────
|
||||
const COLUMN_IDS = [
|
||||
"id",
|
||||
"uniqueId",
|
||||
"createdAt",
|
||||
"region",
|
||||
"branch",
|
||||
"passportName",
|
||||
"passportSurname",
|
||||
"phone",
|
||||
"status",
|
||||
"paid",
|
||||
] as const;
|
||||
|
||||
function getFilterFields(t: (key: string, fallback?: string) => string): FilterField[] {
|
||||
return [
|
||||
{
|
||||
id: "welayat",
|
||||
label: t("sberPayments.filters.welayat", "Welaýat"),
|
||||
options: WELAYATLAR.map((w) => ({ value: w, label: w })),
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
label: t("sberPayments.filters.status", "Status"),
|
||||
options: STATUSES,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// ─── List Page Component ──────────────────────────────────────────────────────
|
||||
// ─── Page Component ───────────────────────────────────────────────────────────
|
||||
|
||||
export default function SberPaymentsListPage() {
|
||||
const { t: _t, i18n } = useTranslation();
|
||||
const t: (key: string, fallback?: string) => string = useCallback((key, fallback) => _t(key, fallback ?? key) as string, [_t]);
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = i18n.language;
|
||||
const navigate = useNavigate();
|
||||
const [deleteTarget, setDeleteTarget] = useState<SberPaymentOrder | null>(null);
|
||||
const deleteMutation = useDeleteSberPayment();
|
||||
const deleteMutation = useDeleteSberPaymentReal();
|
||||
|
||||
const colMeta = useMemo(() => getColumnMeta(t), [i18n.language]);
|
||||
const filterFlds = useMemo(() => getFilterFields(t), [i18n.language]);
|
||||
const [deleteTarget, setDeleteTarget] = useState<SberPaymentOrderItem | null>(null);
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
const [search, setSearch] = useState("");
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([...COLUMN_IDS]);
|
||||
|
||||
const columns = useMemo<ColumnDef<SberPaymentOrder>[]>(() => {
|
||||
const colMetaLabels = getColumnMeta(t);
|
||||
const idLabel = colMetaLabels.find((c) => c.id === "id")?.label ?? "ID";
|
||||
const createdAtLabel = colMetaLabels.find((c) => c.id === "createdAt")?.label ?? "Döredilen wagty";
|
||||
const welayatLabel = colMetaLabels.find((c) => c.id === "welayat")?.label ?? "Welaýat";
|
||||
const sahamcaLabel = colMetaLabels.find((c) => c.id === "sahamca")?.label ?? "Şahamça";
|
||||
const firstNameLabel = colMetaLabels.find((c) => c.id === "firstName")?.label ?? "Ady";
|
||||
const lastNameLabel = colMetaLabels.find((c) => c.id === "lastName")?.label ?? "Familiýasy";
|
||||
const phoneLabel = colMetaLabels.find((c) => c.id === "phone")?.label ?? "Telefon";
|
||||
const statusLabel = colMetaLabels.find((c) => c.id === "status")?.label ?? "Status";
|
||||
const paidStatusLabel = colMetaLabels.find((c) => c.id === "paidStatus")?.label ?? "Tölenen (şul aý)";
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
|
||||
{ fieldId: "status", value: "" },
|
||||
{ fieldId: "region", value: "" },
|
||||
]);
|
||||
|
||||
return [
|
||||
// ── Lazy filter dropdowns ──────────────────────────────────────────────────
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const [branchFilter, setBranchFilter] = useState("");
|
||||
const [userFilter, setUserFilter] = useState("");
|
||||
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [branchSelectOpen, setBranchSelectOpen] = useState(false);
|
||||
const isBranchEnabled = filterEnabled || branchSelectOpen || Boolean(branchFilter);
|
||||
const branchQuery = useInfiniteBranches(branchSearch, isBranchEnabled);
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
(branchQuery.data?.pages ?? []).flatMap((p) =>
|
||||
(p?.branches ?? []).map((b) => ({ value: String(b.id), label: resolveLocalizedName(b.name, lang) })),
|
||||
),
|
||||
[branchQuery.data, lang],
|
||||
);
|
||||
|
||||
const [userSearch, setUserSearch] = useState("");
|
||||
const [userSelectOpen, setUserSelectOpen] = useState(false);
|
||||
const isUserEnabled = filterEnabled || userSelectOpen || Boolean(userFilter);
|
||||
const userQuery = useInfiniteUsers(userSearch, isUserEnabled);
|
||||
const userOptions = useMemo(
|
||||
() =>
|
||||
(userQuery.data?.pages ?? []).flatMap((p) =>
|
||||
(p?.users ?? []).map((u) => ({ value: String(u.id), label: u.name || u.username || String(u.id) })),
|
||||
),
|
||||
[userQuery.data],
|
||||
);
|
||||
|
||||
// ── Query params ──────────────────────────────────────────────────────────
|
||||
const getFilter = useCallback((id: string) => activeFilters.find((f) => f.fieldId === id)?.value ?? "", [activeFilters]);
|
||||
|
||||
const { data, isLoading } = useSberPayments({
|
||||
page,
|
||||
limit: perPage,
|
||||
name: search || undefined,
|
||||
status: (getFilter("status") as SberPaymentStatus) || undefined,
|
||||
region: getFilter("region") || undefined,
|
||||
branch_id: branchFilter || undefined,
|
||||
user_id: userFilter || undefined,
|
||||
});
|
||||
|
||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1;
|
||||
|
||||
// ── Filter handlers ───────────────────────────────────────────────────────
|
||||
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: "" })));
|
||||
setBranchFilter("");
|
||||
setUserFilter("");
|
||||
setPage(1);
|
||||
}, []);
|
||||
|
||||
// ── Columns ───────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<SberPaymentOrderItem>[]>(
|
||||
() => [
|
||||
{
|
||||
id: "id",
|
||||
accessorKey: "id",
|
||||
header: ({ column }) => (
|
||||
<button
|
||||
className="flex items-center gap-1 hover:text-foreground transition-colors"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
>
|
||||
{idLabel}
|
||||
<ArrowUpDown size={12} />
|
||||
</button>
|
||||
),
|
||||
cell: ({ row }) => <span className="font-medium text-foreground">{row.getValue("id")}</span>,
|
||||
header: "ID",
|
||||
cell: ({ row }) => <span className="font-mono text-xs text-muted-foreground">{row.original.id}</span>,
|
||||
size: 70,
|
||||
},
|
||||
{
|
||||
id: "uniqueId",
|
||||
accessorKey: "uniqueId",
|
||||
header: t("sberPayments.col.uniqueId", "Unikal ID"),
|
||||
cell: ({ row }) => <span className="font-mono text-xs text-primary">{row.original.uniqueId}</span>,
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
id: "createdAt",
|
||||
accessorKey: "createdAt",
|
||||
header: createdAtLabel,
|
||||
cell: ({ row }) => {
|
||||
const date = new Date(row.getValue("createdAt"));
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<div>{format(date, "HH:mm, dd.MM.yyyy")}</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "welayat",
|
||||
header: welayatLabel,
|
||||
cell: ({ row }) => <span>{row.getValue("welayat")}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "sahamca",
|
||||
header: ({ column }) => (
|
||||
<button
|
||||
className="flex items-center gap-1 hover:text-foreground transition-colors"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
>
|
||||
{sahamcaLabel}
|
||||
<ArrowUpDown size={12} />
|
||||
</button>
|
||||
header: t("sberPayments.col.createdAt", "Döredilen wagty"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-muted-foreground whitespace-nowrap">{formatFromApiDate(row.original.createdAt)}</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-primary font-medium">{row.getValue("sahamca")}</span>,
|
||||
size: 155,
|
||||
},
|
||||
{
|
||||
accessorKey: "firstName",
|
||||
header: firstNameLabel,
|
||||
cell: ({ row }) => <span>{row.getValue("firstName")}</span>,
|
||||
id: "region",
|
||||
accessorKey: "region",
|
||||
header: t("sberPayments.col.region", "Welaýat"),
|
||||
cell: ({ row }) => <span className="text-sm">{resolveLocalizedName(row.original.regionName, lang) || row.original.region}</span>,
|
||||
size: 110,
|
||||
},
|
||||
{
|
||||
accessorKey: "lastName",
|
||||
header: lastNameLabel,
|
||||
cell: ({ row }) => <span>{row.getValue("lastName")}</span>,
|
||||
id: "branch",
|
||||
accessorKey: "branch",
|
||||
header: t("sberPayments.col.branch", "Şahamça"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-emerald-500 font-medium">{resolveLocalizedName(row.original.branch?.name, lang)}</span>
|
||||
),
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
id: "passportName",
|
||||
accessorKey: "passportName",
|
||||
header: t("sberPayments.col.firstName", "Ady"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.passportName}</span>,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
id: "passportSurname",
|
||||
accessorKey: "passportSurname",
|
||||
header: t("sberPayments.col.lastName", "Familiýasy"),
|
||||
cell: ({ row }) => <span className="text-sm">{row.original.passportSurname}</span>,
|
||||
size: 110,
|
||||
},
|
||||
{
|
||||
id: "phone",
|
||||
accessorKey: "phone",
|
||||
header: phoneLabel,
|
||||
cell: ({ row }) => <span className="text-muted-foreground">{row.getValue("phone")}</span>,
|
||||
header: t("sberPayments.col.phone", "Telefon"),
|
||||
cell: ({ row }) => <span className="font-mono text-sm">{row.original.phone}</span>,
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: ({ column }) => (
|
||||
<button
|
||||
className="flex items-center gap-1 hover:text-foreground transition-colors"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
>
|
||||
{statusLabel}
|
||||
<ArrowUpDown size={12} />
|
||||
</button>
|
||||
),
|
||||
header: t("sberPayments.col.status", "Status"),
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.getValue("status") as string}
|
||||
fallbackLabels={{
|
||||
GARASYLYYAR: t("sberPayments.status.pending", "Garaşylýar"),
|
||||
KANAGATLANDYRYLAN: t("sberPayments.status.approved", "Tassyklandy"),
|
||||
RET_EDILEN: t("sberPayments.status.rejected", "Ýatyryldy"),
|
||||
}}
|
||||
fallbackVariants={{ GARASYLYYAR: "warning", KANAGATLANDYRYLAN: "success", RET_EDILEN: "error" }}
|
||||
status={row.original.status}
|
||||
prefix="intlPayment.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklandy", rejected: "Ret edildi", completed: "Tamamlandy" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error", completed: "success" }}
|
||||
/>
|
||||
),
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
accessorKey: "paidStatus",
|
||||
header: paidStatusLabel,
|
||||
id: "paid",
|
||||
accessorKey: "paid",
|
||||
header: t("sberPayments.col.paid", "Tölendi"),
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.getValue("paidStatus") as string}
|
||||
fallbackLabels={{
|
||||
Tolenmedik: t("sberPayments.paidStatus.unpaid", "Tölenmedi"),
|
||||
Tolendi: t("sberPayments.paidStatus.paid", "Tölendi"),
|
||||
}}
|
||||
fallbackVariants={{ Tolenmedik: "error", Tolendi: "success" }}
|
||||
status={row.original.paid ? "paid" : "unpaid"}
|
||||
fallbackLabels={{ paid: t("sberPayments.paid.yes", "Tölendi"), unpaid: t("sberPayments.paid.no", "Tölenmedi") }}
|
||||
fallbackVariants={{ paid: "success", unpaid: "error" }}
|
||||
/>
|
||||
),
|
||||
size: 110,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
cell: ({ row }) => {
|
||||
const order = row.original;
|
||||
|
||||
return (
|
||||
<TableActions
|
||||
onView={() => navigate(`/sber-payments/${order.id}`)}
|
||||
onEdit={() => navigate(`/sber-payments/${order.id}/edit`)}
|
||||
onDelete={() => setDeleteTarget(order)}
|
||||
isDeleting={deleteMutation.isPending}
|
||||
editIcon={Edit}
|
||||
/>
|
||||
);
|
||||
},
|
||||
enableHiding: false,
|
||||
cell: ({ row }) => (
|
||||
<TableActions
|
||||
onView={() => navigate(`/sber-payments/${row.original.id}`)}
|
||||
onEdit={() => navigate(`/sber-payments/${row.original.id}/edit`)}
|
||||
onDelete={() => setDeleteTarget(row.original)}
|
||||
isDeleting={deleteMutation.isPending}
|
||||
/>
|
||||
),
|
||||
size: 90,
|
||||
},
|
||||
];
|
||||
}, [navigate, deleteMutation, t, i18n.language]);
|
||||
],
|
||||
[t, navigate, deleteMutation.isPending, lang],
|
||||
);
|
||||
|
||||
// Pagination state
|
||||
const [page, setPage] = useState(1);
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
const toggleableColumns = useMemo(() => COLUMN_IDS.map((id) => ({ id, label: t(`sberPayments.columns.${id}`, id) })), [t]);
|
||||
|
||||
// Search state
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
// Filter state
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([]);
|
||||
|
||||
// Column visibility & order
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>(colMeta.map((c) => c.id));
|
||||
|
||||
// Month filter
|
||||
const [selectedMonth, setSelectedMonth] = useState<string>("");
|
||||
|
||||
// Get filter values
|
||||
const welayatFilter = activeFilters.find((f) => f.fieldId === "welayat")?.value ?? "";
|
||||
const statusFilter = activeFilters.find((f) => f.fieldId === "status")?.value ?? "";
|
||||
|
||||
// Fetch data
|
||||
const { data, isLoading } = useSberPaymentOrders({
|
||||
page,
|
||||
perPage,
|
||||
search,
|
||||
welayat: welayatFilter,
|
||||
status: statusFilter,
|
||||
});
|
||||
|
||||
const handleFilterChange = (fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) => {
|
||||
const existing = prev.find((f) => f.fieldId === fieldId);
|
||||
if (existing) {
|
||||
return prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f));
|
||||
}
|
||||
return [...prev, { fieldId, value }];
|
||||
});
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const handleFilterReset = () => {
|
||||
setActiveFilters([]);
|
||||
setPage(1);
|
||||
};
|
||||
const filterFields = useMemo<FilterField[]>(
|
||||
() => [
|
||||
{
|
||||
id: "status",
|
||||
label: t("sberPayments.filters.status", "Status"),
|
||||
options: [
|
||||
{ value: "pending", label: t("intlPayment.status.pending", "Garaşylýar") },
|
||||
{ value: "approved", label: t("intlPayment.status.approved", "Tassyklandy") },
|
||||
{ value: "rejected", label: t("intlPayment.status.rejected", "Ret edildi") },
|
||||
{ value: "completed", label: t("intlPayment.status.completed", "Tamamlandy") },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "region",
|
||||
label: t("sberPayments.filters.region", "Welaýat"),
|
||||
options: REGION_CODES.map((code) => ({ value: code, label: REGION_LABELS[code] ?? code })),
|
||||
},
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Page Title */}
|
||||
<h1 className="text-xl font-semibold text-foreground">{t("sberPayments.list.title", "Sber tölegler (talyplar üçin)")}</h1>
|
||||
|
||||
<div className="flex items-center gap-3 justify-between">
|
||||
<TableSearchInput
|
||||
value={search}
|
||||
@@ -249,12 +261,9 @@ export default function SberPaymentsListPage() {
|
||||
}}
|
||||
placeholder={t("common.search", "Gözlemek")}
|
||||
/>
|
||||
<CreateButton
|
||||
label={t("sberPayments.list.actionLabel", "Sber töleg (talyplar üçin) dörediň")}
|
||||
onClick={() => navigate("/sber-payments/create")}
|
||||
/>
|
||||
<CreateButton label={t("sberPayments.list.actionLabel", "Sber töleg dörediň")} onClick={() => navigate("/sber-payments/create")} />
|
||||
</div>
|
||||
{/* Toolbar */}
|
||||
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
@@ -264,48 +273,83 @@ export default function SberPaymentsListPage() {
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => row.id}
|
||||
currentPage={data?.pagination.currentPage ?? 1}
|
||||
totalPages={data?.pagination.totalPages ?? 1}
|
||||
totalCount={data?.pagination.totalCount ?? 0}
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
toolbar={
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(val) => {
|
||||
setSearch(val);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={colMeta}
|
||||
hideSearch
|
||||
hideAction
|
||||
searchValue=""
|
||||
onSearchChange={() => {}}
|
||||
columns={toggleableColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
filterFields={filterFlds}
|
||||
filterFields={filterFields}
|
||||
activeFilters={activeFilters}
|
||||
onFilterChange={handleFilterChange}
|
||||
onFilterReset={handleFilterReset}
|
||||
perPageOptions={[10, 25, 50, 100]}
|
||||
perPage={perPage}
|
||||
onPerPageChange={(val) => {
|
||||
setPerPage(val);
|
||||
onPerPageChange={(v) => {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
hideSearch
|
||||
hideAction
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
extraActions={
|
||||
<MonthSelect
|
||||
value={selectedMonth}
|
||||
onChange={(v) => {
|
||||
setSelectedMonth(v);
|
||||
setPage(1);
|
||||
}}
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-44">
|
||||
<InfiniteSelect
|
||||
value={branchFilter}
|
||||
onChange={(v) => {
|
||||
setBranchFilter(v);
|
||||
setPage(1);
|
||||
}}
|
||||
options={branchOptions}
|
||||
loading={branchQuery.isLoading}
|
||||
isLoadingMore={branchQuery.isFetchingNextPage}
|
||||
hasNextPage={!!branchQuery.hasNextPage}
|
||||
onLoadMore={() => branchQuery.fetchNextPage()}
|
||||
searchValue={branchSearch}
|
||||
onSearchChange={setBranchSearch}
|
||||
onOpenChange={(open) => {
|
||||
if (open) setBranchSelectOpen(true);
|
||||
}}
|
||||
placeholder={t("sberPayments.filters.branch", "Şahamça")}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-44">
|
||||
<InfiniteSelect
|
||||
value={userFilter}
|
||||
onChange={(v) => {
|
||||
setUserFilter(v);
|
||||
setPage(1);
|
||||
}}
|
||||
options={userOptions}
|
||||
loading={userQuery.isLoading}
|
||||
isLoadingMore={userQuery.isFetchingNextPage}
|
||||
hasNextPage={!!userQuery.hasNextPage}
|
||||
onLoadMore={() => userQuery.fetchNextPage()}
|
||||
searchValue={userSearch}
|
||||
onSearchChange={setUserSearch}
|
||||
onOpenChange={(open) => {
|
||||
if (open) setUserSelectOpen(true);
|
||||
}}
|
||||
placeholder={t("sberPayments.filters.user", "Ulanyjy")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* Delete confirmation dialog */}
|
||||
|
||||
<DeleteDialog
|
||||
open={deleteTarget !== null}
|
||||
onOpenChange={(o) => {
|
||||
@@ -314,7 +358,7 @@ export default function SberPaymentsListPage() {
|
||||
title={t("sberPayments.deleteDialog.title", "Bu tölegi pozmak isleýärsiňizmi?")}
|
||||
onConfirm={async () => {
|
||||
if (deleteTarget) {
|
||||
await deleteMutation.mutateAsync(deleteTarget.id);
|
||||
await deleteMutation.mutateAsync(String(deleteTarget.id));
|
||||
setDeleteTarget(null);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { SberPaymentForm } from '@/features/sberPayments/components/sberPaymentsForm'
|
||||
import { useSberPaymentOrder } from '@/features/sberPayments/hooks/useSberPayments'
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { PageSpinner } from "@/components/pageSpinner";
|
||||
import { PageError } from "@/components/pageError";
|
||||
import { SberPaymentForm } from "@/features/sberPayments/components/sberPaymentsForm";
|
||||
import { useIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
|
||||
export default function SberPaymentEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id ?? '')
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { t } = useTranslation();
|
||||
const { data: order, isLoading } = useIntlPayment(id ?? "");
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!order) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
if (isLoading) return <PageSpinner />;
|
||||
if (!order) return <PageError message={t("common.notFound", "Tapylmady")} />;
|
||||
|
||||
return <SberPaymentForm mode="edit" initialData={order} />
|
||||
return <SberPaymentForm mode="edit" initialData={order} />;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,33 @@ import { format } from "date-fns";
|
||||
import { Search, Download } from "lucide-react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useState } from "react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { useSberPaymentOrder, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import { useState } from "react";
|
||||
import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
import { ACCEPTED_DOC_DEFS, SENT_DOC_DEFS, docLabel, type TFn } from "@/features/sberPayments/constants/documents";
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function formatDate(value: string | null | undefined): string {
|
||||
if (!value) return "—";
|
||||
const d = new Date(value);
|
||||
return Number.isNaN(d.getTime()) ? "—" : format(d, "dd/MM/yyyy, HH:mm:ss") + " GMT+5";
|
||||
}
|
||||
|
||||
function fileNameFromUrl(url: string): string {
|
||||
const last = url.split("?")[0].split("/").pop() ?? "";
|
||||
try {
|
||||
return decodeURIComponent(last) || "faýl";
|
||||
} catch {
|
||||
return last || "faýl";
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Document row ─────────────────────────────────────────────────────────────
|
||||
|
||||
function DocumentRow({ label, fileName, fileUrl }: { label: string; fileName: string | null; fileUrl: string | null }) {
|
||||
function DocumentRow({ label, fileUrl }: { label: string; fileUrl: string | null }) {
|
||||
if (!fileUrl)
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
@@ -18,21 +36,25 @@ function DocumentRow({ label, fileName, fileUrl }: { label: string; fileName: st
|
||||
</InfoRow>
|
||||
);
|
||||
|
||||
const name = fileName ?? fileUrl.split("/").pop() ?? "faýl";
|
||||
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
<div className="flex items-center gap-2">
|
||||
<button className="p-1.5 rounded bg-muted hover:bg-accent transition-colors">
|
||||
<a
|
||||
href={fileUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="p-1.5 rounded bg-muted hover:bg-accent transition-colors"
|
||||
aria-label="Open"
|
||||
>
|
||||
<Search size={12} className="text-muted-foreground" />
|
||||
</button>
|
||||
</a>
|
||||
<a
|
||||
href={fileUrl}
|
||||
download
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-primary/10 hover:bg-primary/20 text-xs text-primary transition-colors"
|
||||
>
|
||||
<Download size={12} />
|
||||
<span className="max-w-[140px] truncate">{name}</span>
|
||||
<span className="max-w-[140px] truncate">{fileNameFromUrl(fileUrl)}</span>
|
||||
</a>
|
||||
</div>
|
||||
</InfoRow>
|
||||
@@ -62,13 +84,14 @@ function SberPaymentViewSkeleton() {
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function SberPaymentViewPage() {
|
||||
const { t } = useTranslation();
|
||||
const { t: _t } = useTranslation();
|
||||
const t: TFn = (key, fallback) => _t(key, fallback ?? key) as string;
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [historySearch, setHistorySearch] = useState("");
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id!);
|
||||
const deleteMutation = useDeleteSberPayment();
|
||||
const { data: order, isLoading } = useIntlPayment(id ?? "");
|
||||
const deleteMutation = useDeleteIntlPayment();
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(id!);
|
||||
@@ -85,18 +108,21 @@ export default function SberPaymentViewPage() {
|
||||
);
|
||||
}
|
||||
|
||||
const kabulDocs = order.documents?.slice(0, 6) ?? [];
|
||||
const ugradDocs = order.documents?.slice(6) ?? [];
|
||||
const payerInfo = [order.passport_series, order.passport_number, order.payer_full_name].filter(Boolean).join(" ");
|
||||
|
||||
const auditLogs: AuditRowProps[] =
|
||||
order.activityLog?.map((log) => ({
|
||||
id: log.id.split("-")[1] ?? log.id,
|
||||
action: log.analysisName,
|
||||
by: log.createdBy,
|
||||
target: log.target,
|
||||
status: log.status,
|
||||
date: format(new Date(log.createdAt), "dd/MM/yyyy, HH:mm:ss") + " GMT+5",
|
||||
})) ?? [];
|
||||
// Backend gives no activity log; only the creation event is derivable from real data.
|
||||
const auditLogs: AuditRowProps[] = order.created_at
|
||||
? [
|
||||
{
|
||||
id: order.id,
|
||||
action: t("sberPayments.audit.created", "Döredildi"),
|
||||
by: order.created_by_label || "—",
|
||||
target: order.id,
|
||||
status: "FINISHED" as AuditRowProps["status"],
|
||||
date: formatDate(order.created_at),
|
||||
},
|
||||
]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
@@ -124,16 +150,17 @@ export default function SberPaymentViewPage() {
|
||||
<StatusCell
|
||||
status={order.status}
|
||||
fallbackLabels={{
|
||||
GARASYLYYAR: t("sberPayments.status.pending", "Garaşylýar"),
|
||||
KANAGATLANDYRYLAN: t("sberPayments.status.approved", "Tassyklandy"),
|
||||
RET_EDILEN: t("sberPayments.status.rejected", "Ýatyryldy"),
|
||||
pending: t("sberPayments.status.pending", "Garaşylýar"),
|
||||
approved: t("sberPayments.status.approved", "Tassyklandy"),
|
||||
rejected: t("sberPayments.status.rejected", "Ýatyryldy"),
|
||||
completed: t("sberPayments.status.completed", "Tamamlandy"),
|
||||
}}
|
||||
fallbackVariants={{ GARASYLYYAR: "warning", KANAGATLANDYRYLAN: "success", RET_EDILEN: "error" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error", completed: "success" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("sberPayments.columns.paidStatus", "Tölenen (şul aý)")}>
|
||||
<InfoRow label={t("sberPayments.columns.paidStatus", "Tölenen")}>
|
||||
<StatusCell
|
||||
status={order.paidStatus}
|
||||
status={order.paid ? "Tolendi" : "Tolenmedik"}
|
||||
fallbackLabels={{
|
||||
Tolenmedik: t("sberPayments.paidStatus.unpaid", "Tölenmedi"),
|
||||
Tolendi: t("sberPayments.paidStatus.paid", "Tölendi"),
|
||||
@@ -141,16 +168,16 @@ export default function SberPaymentViewPage() {
|
||||
fallbackVariants={{ Tolenmedik: "error", Tolendi: "success" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("sberPayments.cards.bellik", "Bellik")} value={order.bellik} />
|
||||
<InfoRow label={t("sberPayments.cards.bellik", "Bellik")} value={order.note ?? ""} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("sberPayments.view.sections.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("sberPayments.fields.welayat", "Welaýat")} value={order.welayat} />
|
||||
<InfoRow label={t("sberPayments.fields.welayat", "Welaýat")} value={order.province_label} />
|
||||
<InfoRow
|
||||
label={t("sberPayments.fields.sahamca", "Şahamça")}
|
||||
value={order.sahamca}
|
||||
value={order.branch_label}
|
||||
isLink
|
||||
href={order.sahamcaId ? `/settings/location/branches/${order.sahamcaId}` : "/settings/location/branches"}
|
||||
href={order.branch ? `/settings/location/branches/${order.branch}` : "/settings/location/branches"}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
@@ -158,48 +185,38 @@ export default function SberPaymentViewPage() {
|
||||
{/* ── Row 2: Şahsy maglumatlar + Töleg ─────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("sberPayments.view.sections.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("sberPayments.fields.firstName", "Pasportdaky ady")} value={order.firstName} />
|
||||
<InfoRow label={t("sberPayments.fields.lastName", "Pasportdaky familiýa")} value={order.lastName} />
|
||||
<InfoRow label={t("sberPayments.fields.firstName", "Pasportdaky ady")} value={order.passport_first_name} />
|
||||
<InfoRow label={t("sberPayments.fields.lastName", "Pasportdaky familiýa")} value={order.passport_last_name} />
|
||||
<InfoRow label={t("sberPayments.fields.phone", "Telefon")} value={order.phone} />
|
||||
<InfoRow label={t("sberPayments.fields.email", "E-poçta")} value={order.email} />
|
||||
<InfoRow label={t("sberPayments.fields.address", "Salgy")} value={order.address} />
|
||||
<InfoRow label={t("sberPayments.fields.email", "E-poçta")} value={order.email ?? ""} />
|
||||
<InfoRow label={t("sberPayments.fields.address", "Salgy")} value={order.home_address ?? ""} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("sberPayments.view.sections.payment", "Töleg")}>
|
||||
<InfoRow
|
||||
label={t("sberPayments.payerInfo", "Töleg ugradyjynyň maglumatlary")}
|
||||
value={`I-M${order.passportNumber?.slice(0, 2) ?? "XX"}-${order.passportNumber ?? ""} ${order.fullName}`}
|
||||
/>
|
||||
<InfoRow label={t("sberPayments.fields.accountNumber", "Goýum hasaby")} value={order.accountNumber} />
|
||||
<InfoRow label={t("sberPayments.fields.passportSeries", "Pasport seriýasy")} value={order.passportSeries} />
|
||||
<InfoRow label={t("sberPayments.fields.passportNumber", "Pasport nomeri")} value={order.passportNumber} />
|
||||
<InfoRow label={t("sberPayments.fields.fullName", "Ady Familiýasy Atasynyň ady")} value={order.fullName} />
|
||||
<InfoRow label={t("sberPayments.payerInfo", "Töleg ugradyjynyň maglumatlary")} value={payerInfo} />
|
||||
<InfoRow label={t("sberPayments.fields.accountNumber", "Goýum hasaby")} value={order.payer_account_number} />
|
||||
<InfoRow label={t("sberPayments.fields.passportSeries", "Pasport seriýasy")} value={order.passport_series} />
|
||||
<InfoRow label={t("sberPayments.fields.passportNumber", "Pasport nomeri")} value={order.passport_number} />
|
||||
<InfoRow label={t("sberPayments.fields.fullName", "Ady Familiýasy Atasynyň ady")} value={order.payer_full_name} />
|
||||
<InfoRow label={t("sberPayments.fields.receiverInfo", "Töleg kabul edijiniň maglumatlary")} value={order.receiver_info} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Kabul ediji resminamalary ─────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t("sberPayments.view.sections.acceptedDocs", "Kabul ediji talyp boýunça resminamalary")}>
|
||||
{kabulDocs.length > 0 ? (
|
||||
kabulDocs.map((doc) => <DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />)
|
||||
) : (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
{t("sberPayments.view.noDocuments", "Resminamalar ýok")}
|
||||
</div>
|
||||
)}
|
||||
{ACCEPTED_DOC_DEFS.map((d) => (
|
||||
<DocumentRow key={d.key} label={docLabel(d, t)} fileUrl={order[d.key]} />
|
||||
))}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 4: Ugradyjy resminamalary ────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t("sberPayments.view.sections.sentDocs", "Ugradyjy boýunça resminamalary")}>
|
||||
{ugradDocs.length > 0 ? (
|
||||
ugradDocs.map((doc) => <DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />)
|
||||
) : (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
{t("sberPayments.view.noDocuments", "Resminamalar ýok")}
|
||||
</div>
|
||||
)}
|
||||
{SENT_DOC_DEFS.map((d) => (
|
||||
<DocumentRow key={d.key} label={docLabel(d, t)} fileUrl={order[d.key]} />
|
||||
))}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ export default function IntlPaymentsPage() {
|
||||
const [payTarget, setPayTarget] = useState<IntlPaymentItem | null>(null);
|
||||
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const branchQuery = useInfiniteBranches(branchSearch);
|
||||
const [branchSelectOpen, setBranchSelectOpen] = useState(false);
|
||||
const isBranchEnabled = branchSelectOpen || Boolean(branchFilter);
|
||||
const branchQuery = useInfiniteBranches(branchSearch, isBranchEnabled);
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
(branchQuery.data?.pages ?? []).flatMap((p) =>
|
||||
@@ -60,7 +62,9 @@ export default function IntlPaymentsPage() {
|
||||
);
|
||||
|
||||
const [userSearch, setUserSearch] = useState("");
|
||||
const userQuery = useInfiniteUsers(userSearch);
|
||||
const [userSelectOpen, setUserSelectOpen] = useState(false);
|
||||
const isUserEnabled = userSelectOpen || Boolean(userFilter);
|
||||
const userQuery = useInfiniteUsers(userSearch, isUserEnabled);
|
||||
const userOptions = useMemo(
|
||||
() =>
|
||||
(userQuery.data?.pages ?? []).flatMap((p) =>
|
||||
@@ -268,6 +272,9 @@ export default function IntlPaymentsPage() {
|
||||
onLoadMore={() => branchQuery.fetchNextPage()}
|
||||
searchValue={branchSearch}
|
||||
onSearchChange={setBranchSearch}
|
||||
onOpenChange={(open) => {
|
||||
if (open) setBranchSelectOpen(true);
|
||||
}}
|
||||
placeholder={t("intlPayment.branch", "Şahamça")}
|
||||
/>
|
||||
</div>
|
||||
@@ -285,6 +292,9 @@ export default function IntlPaymentsPage() {
|
||||
onLoadMore={() => userQuery.fetchNextPage()}
|
||||
searchValue={userSearch}
|
||||
onSearchChange={setUserSearch}
|
||||
onOpenChange={(open) => {
|
||||
if (open) setUserSelectOpen(true);
|
||||
}}
|
||||
placeholder={t("intlPayment.client", "Ulanyjy")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Search } from "lucide-react";
|
||||
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
|
||||
import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
import { PaymentHistoryTable } from "@/features/visaMasterPayments/components/PaymentHistoryTable";
|
||||
|
||||
// ─── DocFile row ──────────────────────────────────────────────────────────────
|
||||
|
||||
function DocFileRow({ label, url }: { label: string; url: string | null }) {
|
||||
if (!url)
|
||||
if (!url) {
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
<span className="text-muted-foreground/50">—</span>
|
||||
</InfoRow>
|
||||
);
|
||||
}
|
||||
|
||||
const filename = url.split("/").pop() ?? "faýl";
|
||||
const isImage = /\.(jpg|jpeg|png|gif|webp)$/i.test(url);
|
||||
@@ -29,18 +33,45 @@ function DocFileRow({ label, url }: { label: string; url: string | null }) {
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-muted/50 hover:bg-muted text-xs text-foreground transition-colors"
|
||||
className="
|
||||
flex
|
||||
items-center
|
||||
gap-1.5
|
||||
rounded-md
|
||||
bg-muted/50
|
||||
px-3
|
||||
py-1.5
|
||||
text-xs
|
||||
text-foreground
|
||||
transition-colors
|
||||
hover:bg-muted
|
||||
"
|
||||
>
|
||||
<Search size={12} />
|
||||
|
||||
<span className="max-w-[140px] truncate">{filename}</span>
|
||||
</a>
|
||||
)}
|
||||
|
||||
<a
|
||||
href={url}
|
||||
download
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-primary/10 hover:bg-primary/20 text-xs text-primary transition-colors"
|
||||
className="
|
||||
flex
|
||||
items-center
|
||||
gap-1.5
|
||||
rounded-md
|
||||
bg-primary/10
|
||||
px-3
|
||||
py-1.5
|
||||
text-xs
|
||||
text-primary
|
||||
transition-colors
|
||||
hover:bg-primary/20
|
||||
"
|
||||
>
|
||||
<Download size={12} />
|
||||
|
||||
<span className="max-w-[140px] truncate">{filename}</span>
|
||||
</a>
|
||||
</div>
|
||||
@@ -54,10 +85,24 @@ function IntlPaymentViewSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
{[...Array(4)].map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
<div
|
||||
key={i}
|
||||
className="
|
||||
flex
|
||||
flex-col
|
||||
gap-3
|
||||
rounded-xl
|
||||
border
|
||||
border-border
|
||||
bg-card
|
||||
p-4
|
||||
"
|
||||
>
|
||||
<Skeleton className="mb-1 h-3 w-24" />
|
||||
|
||||
{[...Array(3)].map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
@@ -74,32 +119,49 @@ export default function IntlPaymentViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const [historySearch, setHistorySearch] = useState("");
|
||||
|
||||
const { data, isLoading, isError } = useIntlPayment(id!);
|
||||
const { mutate: deletePayment, isPending: isDeleting } = useDeleteIntlPayment();
|
||||
|
||||
const { mutateAsync: deletePayment, isPending: isDeleting } = useDeleteIntlPayment();
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deletePayment(data!.id);
|
||||
await deletePayment(id!);
|
||||
navigate("/visa-master");
|
||||
};
|
||||
|
||||
if (isLoading) return <IntlPaymentViewSkeleton />;
|
||||
if (isLoading) {
|
||||
return <IntlPaymentViewSkeleton />;
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
<div className="flex h-64 items-center justify-center text-sm text-muted-foreground">
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const KABUL_DOCS = [
|
||||
{ label: 'Talypyň degişli welaýata "SBERBANK" kartyň rekwizitleri', url: data.doc_sberbank_account },
|
||||
{ label: "Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy", url: data.doc_school_enrollment },
|
||||
{ label: "Talypyň bilendiriň göçürmesi", url: data.doc_summons },
|
||||
{ label: "Talypyň degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi", url: data.doc_passport_tm },
|
||||
{ label: "Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi", url: data.doc_foreign_passport },
|
||||
{
|
||||
label: 'Talypyň degişli welaýata "SBERBANK" kartyň rekwizitleri',
|
||||
url: data.doc_sberbank_account,
|
||||
},
|
||||
{
|
||||
label: "Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy",
|
||||
url: data.doc_school_enrollment,
|
||||
},
|
||||
{
|
||||
label: "Talypyň bilendiriň göçürmesi",
|
||||
url: data.doc_summons,
|
||||
},
|
||||
{
|
||||
label: "Talypyň degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi",
|
||||
url: data.doc_passport_tm,
|
||||
},
|
||||
{
|
||||
label: "Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi",
|
||||
url: data.doc_foreign_passport,
|
||||
},
|
||||
{
|
||||
label:
|
||||
"Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurtda galan döwründe bakýan döwleti baradaky bellenen sahypasynyň göçürmesi",
|
||||
@@ -122,7 +184,10 @@ export default function IntlPaymentViewPage() {
|
||||
];
|
||||
|
||||
const UPGRAD_DOCS = [
|
||||
{ label: "Upgradyý degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi", url: data.upd_doc_passport_tm },
|
||||
{
|
||||
label: "Upgradyý degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi",
|
||||
url: data.upd_doc_passport_tm,
|
||||
},
|
||||
{
|
||||
label: "Upgradyý degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi",
|
||||
url: data.upd_doc_foreign_passport,
|
||||
@@ -132,24 +197,32 @@ export default function IntlPaymentViewPage() {
|
||||
"Upgradyý Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurt döwletinde galýandygy baradaky şaýmynyň bellenen sahypasynyň göçürmesi",
|
||||
url: data.upd_doc_visa,
|
||||
},
|
||||
{ label: "Upgradyýyň we kabul edijiniň resminamalarynyň göçürmesi", url: data.upd_doc_acceptance_letter },
|
||||
{
|
||||
label: "Upgradyýyň we kabul edijiniň resminamalarynyň göçürmesi",
|
||||
url: data.upd_doc_acceptance_letter,
|
||||
},
|
||||
{
|
||||
label: "Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky maglumatlary",
|
||||
url: data.upd_doc_passport_biometric,
|
||||
},
|
||||
{ label: "Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky göwnamasy", url: data.upd_doc_passport_old },
|
||||
{
|
||||
label: "Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky göwnamasy",
|
||||
url: data.upd_doc_passport_old,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("intlPayment.viewTitle", "Halkara töleg")}: {data.id}
|
||||
</h1>
|
||||
|
||||
<div className="flex items-center gap-1.5">
|
||||
<ViewActions
|
||||
editTo={`/intl-payments/visa-master/${id}/edit`}
|
||||
editTo={`/visa-master/${id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={isDeleting}
|
||||
deleteTitle={t("intlPayment.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
@@ -160,6 +233,7 @@ export default function IntlPaymentViewPage() {
|
||||
</div>
|
||||
|
||||
{/* ── Row 1: Meta + Ýüztuman + Lokasiýa ───────────────────────────── */}
|
||||
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("intlPayment.statusSection", "Esasy maglumatlar")}>
|
||||
<InfoRow
|
||||
@@ -168,16 +242,28 @@ export default function IntlPaymentViewPage() {
|
||||
isLink={Boolean(data.client_id)}
|
||||
href={data.client_id ? `/all-users/${data.client_id}` : undefined}
|
||||
/>
|
||||
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
|
||||
<InfoRow label={t("intlPayment.status", "Status")}>
|
||||
<StatusCell
|
||||
status={data.status}
|
||||
prefix="intlPayment.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklandy", rejected: "Ret edildi" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
fallbackLabels={{
|
||||
pending: "Garaşylýar",
|
||||
approved: "Tassyklandy",
|
||||
rejected: "Ret edildi",
|
||||
}}
|
||||
fallbackVariants={{
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
}}
|
||||
/>
|
||||
</InfoRow>
|
||||
|
||||
<InfoRow label={t("intlPayment.tilowanMonth", "Tölewan (Aý/aý)")} value={formatFromApiDate(data.created_at)} />
|
||||
|
||||
<InfoRow label={t("intlPayment.note", "Bellik")} value={data.note} />
|
||||
</BentoCard>
|
||||
|
||||
@@ -187,6 +273,7 @@ export default function IntlPaymentViewPage() {
|
||||
|
||||
<BentoCard title={t("intlPayment.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("intlPayment.province", "Welaýat")} value={data.province_label} />
|
||||
|
||||
<InfoRow
|
||||
label={t("intlPayment.branch", "Şahamça")}
|
||||
value={data.branch_label}
|
||||
@@ -197,69 +284,62 @@ export default function IntlPaymentViewPage() {
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy maglumatlar + Töleg ─────────────────────────────── */}
|
||||
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("intlPayment.personalSection", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("intlPayment.passportFirstName", "Pasportdaky ady")} value={data.passport_first_name} />
|
||||
|
||||
<InfoRow label={t("intlPayment.passportLastName", "Pasportdaky familiýa")} value={data.passport_last_name} />
|
||||
|
||||
<InfoRow label={t("intlPayment.phone", "Telefon")} value={data.phone} />
|
||||
|
||||
<InfoRow label={t("intlPayment.email", "E-poçta")} value={data.email} />
|
||||
|
||||
<InfoRow label={t("intlPayment.homeAddress", "Häzirki ýaşyş ýeri")} value={data.home_address} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("intlPayment.paymentSection", "Töleg")}>
|
||||
<InfoRow label={t("intlPayment.payerFullName", "Töleg upgradyjynyň maglumatlary")} value={data.payer_full_name} />
|
||||
|
||||
<InfoRow label={t("intlPayment.payerAccount", "Töleg upgradyjynyň goşun hasaby")} value={data.payer_account_number} />
|
||||
|
||||
<InfoRow label={t("intlPayment.passportSeries", "Pasport seriýasy")} value={data.passport_series} />
|
||||
|
||||
<InfoRow label={t("intlPayment.passportNumber", "Pasport nomeri")} value={data.passport_number} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Kabul ediji resminamalar ──────────────────────────────── */}
|
||||
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t("intlPayment.kabulDocsSection", "Kabul ediji talyp boyunca resminamalar")}>
|
||||
{KABUL_DOCS.map((doc, i) => (
|
||||
<DocFileRow key={i} label={doc.label} url={doc.url} />
|
||||
{KABUL_DOCS.map((doc, index) => (
|
||||
<DocFileRow key={index} label={doc.label} url={doc.url} />
|
||||
))}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 4: Upgradyý resminamalar ─────────────────────────────────── */}
|
||||
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t("intlPayment.upgradDocsSection", "Upgradyý boyunca resminamalar")}>
|
||||
{UPGRAD_DOCS.map((doc, i) => (
|
||||
<DocFileRow key={i} label={doc.label} url={doc.url} />
|
||||
{UPGRAD_DOCS.map((doc, index) => (
|
||||
<DocFileRow key={index} label={doc.label} url={doc.url} />
|
||||
))}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 5: Töleg taryhy ───────────────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t("intlPayment.paymentHistory", "Töleg taryhy")}>
|
||||
<div className="p-4">
|
||||
<div className="relative max-w-xs mb-4">
|
||||
<Search size={13} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" />
|
||||
<input
|
||||
type="text"
|
||||
value={historySearch}
|
||||
onChange={(e) => setHistorySearch(e.target.value)}
|
||||
placeholder={t("intlPayment.search", "Gözlemek")}
|
||||
className="h-9 w-full pl-9 pr-3 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center justify-center py-10 text-muted-foreground/50">
|
||||
<div className="w-12 h-12 mb-3 rounded-lg border-2 border-dashed border-muted-foreground/20 flex items-center justify-center">
|
||||
<svg viewBox="0 0 24 24" className="w-6 h-6" fill="none" stroke="currentColor" strokeWidth={1.5}>
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" />
|
||||
<line x1="3" y1="9" x2="21" y2="9" />
|
||||
<line x1="9" y1="9" x2="9" y2="21" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm">{t("intlPayment.noHistory", "Beriilen kriteriýalara Töleg gabat gelmedi")}</p>
|
||||
</div>
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
<section className="overflow-hidden rounded-xl border border-border bg-card">
|
||||
{/* Single history header */}
|
||||
<div className="border-b border-border px-4 py-3">
|
||||
<h2 className="text-sm font-medium text-foreground">{t("intlPayment.paymentHistory", "Töleg taryhy")}</h2>
|
||||
</div>
|
||||
|
||||
{/* Single history table */}
|
||||
<PaymentHistoryTable orderId={id} />
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,14 +29,24 @@ export default function LoanOrderMobilesPage() {
|
||||
const deleteMutation = useDeleteLoanOrderMobile();
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
|
||||
{ fieldId: "region", value: "" },
|
||||
{ fieldId: "status", value: "" },
|
||||
{ fieldId: "branch", value: "" },
|
||||
{ fieldId: "archived", value: "" },
|
||||
]);
|
||||
|
||||
const isBranchFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "branch")?.value);
|
||||
|
||||
const {
|
||||
data: branchesInfiniteData,
|
||||
fetchNextPage: fetchNextBranches,
|
||||
hasNextPage: hasNextBranches,
|
||||
isFetchingNextPage: isFetchingNextBranches,
|
||||
isLoading: isBranchesLoading,
|
||||
} = useInfiniteBranches(branchSearch);
|
||||
} = useInfiniteBranches(branchSearch, isBranchFilterEnabled);
|
||||
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
@@ -54,12 +64,6 @@ export default function LoanOrderMobilesPage() {
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([...COLUMN_IDS]);
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
|
||||
{ fieldId: "region", value: "" },
|
||||
{ fieldId: "status", value: "" },
|
||||
{ fieldId: "branch", value: "" },
|
||||
{ fieldId: "archived", value: "" },
|
||||
]);
|
||||
|
||||
const queryParams = useMemo(() => {
|
||||
const filterMap = Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value]));
|
||||
@@ -268,6 +272,9 @@ export default function LoanOrderMobilesPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
columns={columns}
|
||||
|
||||
@@ -28,14 +28,23 @@ export default function LoanOrdersPage() {
|
||||
const deleteMutation = useDeleteLoanOrder();
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
|
||||
{ fieldId: "region", value: "" },
|
||||
{ fieldId: "status", value: "" },
|
||||
{ fieldId: "branch", value: "" },
|
||||
]);
|
||||
|
||||
const isBranchFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "branch")?.value);
|
||||
|
||||
const {
|
||||
data: branchesInfiniteData,
|
||||
fetchNextPage: fetchNextBranches,
|
||||
hasNextPage: hasNextBranches,
|
||||
isFetchingNextPage: isFetchingNextBranches,
|
||||
isLoading: isBranchesLoading,
|
||||
} = useInfiniteBranches(branchSearch);
|
||||
} = useInfiniteBranches(branchSearch, isBranchFilterEnabled);
|
||||
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
@@ -52,11 +61,6 @@ export default function LoanOrdersPage() {
|
||||
const [perPage, setPerPage] = useState(25);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([...COLUMN_IDS]);
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
|
||||
{ fieldId: "region", value: "" },
|
||||
{ fieldId: "status", value: "" },
|
||||
{ fieldId: "branch", value: "" },
|
||||
]);
|
||||
|
||||
const queryParams = useMemo(() => {
|
||||
const filterMap = Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value]));
|
||||
@@ -252,6 +256,9 @@ export default function LoanOrdersPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -71,16 +71,23 @@ export default function LoanPaidOffLettersPage() {
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>(INITIAL_FILTERS);
|
||||
|
||||
// ── Dropdown data ──────────────────────────────────────────────────────────
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [districtSearch, setDistrictSearch] = useState("");
|
||||
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
const getFilter = useCallback((id: FilterId) => activeFilters.find((f) => f.fieldId === id)?.value ?? "", [activeFilters]);
|
||||
|
||||
const isBranchFilterEnabled = filterEnabled || Boolean(getFilter("branch_id"));
|
||||
const isDistrictFilterEnabled = filterEnabled || Boolean(getFilter("region"));
|
||||
|
||||
const {
|
||||
data: branchesInfiniteData,
|
||||
fetchNextPage: fetchNextBranches,
|
||||
hasNextPage: hasNextBranches,
|
||||
isFetchingNextPage: isFetchingNextBranches,
|
||||
isLoading: isBranchesLoading,
|
||||
} = useInfiniteBranches(branchSearch);
|
||||
} = useInfiniteBranches(branchSearch, isBranchFilterEnabled);
|
||||
|
||||
const {
|
||||
data: districtsInfiniteData,
|
||||
@@ -88,10 +95,7 @@ export default function LoanPaidOffLettersPage() {
|
||||
hasNextPage: hasNextDistricts,
|
||||
isFetchingNextPage: isFetchingNextDistricts,
|
||||
isLoading: isDistrictsLoading,
|
||||
} = useInfiniteDistricts(districtSearch);
|
||||
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
const getFilter = useCallback((id: FilterId) => activeFilters.find((f) => f.fieldId === id)?.value ?? "", [activeFilters]);
|
||||
} = useInfiniteDistricts(districtSearch, isDistrictFilterEnabled);
|
||||
|
||||
const queryParams = useMemo(
|
||||
() => ({
|
||||
@@ -332,6 +336,9 @@ export default function LoanPaidOffLettersPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
hideSearch
|
||||
hideAction
|
||||
/>
|
||||
|
||||
@@ -83,6 +83,9 @@ export default function OnlinePaymentHistoryPage() {
|
||||
]);
|
||||
|
||||
// ─── Branch infinite-select data
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const isBranchFilterEnabled = filterEnabled || Boolean(activeFilters.find((f) => f.fieldId === "branchId")?.value);
|
||||
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const {
|
||||
data: branchesInfiniteData,
|
||||
@@ -90,7 +93,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
hasNextPage: hasNextBranches,
|
||||
isFetchingNextPage: isFetchingNextBranches,
|
||||
isLoading: isBranchesLoading,
|
||||
} = useInfiniteBranches(branchSearch);
|
||||
} = useInfiniteBranches(branchSearch, isBranchFilterEnabled);
|
||||
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
@@ -306,6 +309,9 @@ export default function OnlinePaymentHistoryPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
columns={columns}
|
||||
|
||||
@@ -53,14 +53,17 @@ export function BranchesListPage() {
|
||||
uniqueCode: uniqueCodeFilter,
|
||||
});
|
||||
|
||||
const [filterEnabled, setFilterEnabled] = useState(false);
|
||||
const [provinceSearch, setProvinceSearch] = useState("");
|
||||
const isProvinceFilterEnabled = filterEnabled || Boolean(provinceIdFilter);
|
||||
|
||||
const {
|
||||
data: provincesInfiniteData,
|
||||
fetchNextPage: fetchNextProvinces,
|
||||
hasNextPage: hasNextProvinces,
|
||||
isFetchingNextPage: isFetchingNextProvinces,
|
||||
isLoading: isProvincesLoading,
|
||||
} = useInfiniteProvinces(provinceSearch);
|
||||
} = useInfiniteProvinces(provinceSearch, isProvinceFilterEnabled);
|
||||
|
||||
const provinceOptions = useMemo(
|
||||
() =>
|
||||
@@ -233,6 +236,9 @@ export function BranchesListPage() {
|
||||
setPerPage(v);
|
||||
setPage(1);
|
||||
}}
|
||||
onFilterOpenChange={(open) => {
|
||||
if (open) setFilterEnabled(true);
|
||||
}}
|
||||
hideSearch
|
||||
hideAction
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user