added card icon logic to sber payments

This commit is contained in:
Jelaletdin12 committed 2026-10-25 21:45:21 +05:00
1 parent 5fd800d506
commit 7a8c877ca3
2 files changed
+24 -25

No files matched your search

@@ -1,6 +1,7 @@
import { useState, useMemo, useCallback } from "react"; import { useState, useMemo, useCallback } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { CreditCard } from "lucide-react";
import type { ColumnDef, VisibilityState } from "@tanstack/react-table"; import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
import { DataTable } from "@/components/dataTable"; import { DataTable } from "@/components/dataTable";
@@ -17,6 +18,7 @@ import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUser
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers"; import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
import type { SberPaymentOrderItem, SberPaymentStatus } from "@/features/sberPayments/api/sberPaymentsApi"; import type { SberPaymentOrderItem, SberPaymentStatus } from "@/features/sberPayments/api/sberPaymentsApi";
import type { LocalizedText } from "@/features/branches/api/branchesApi"; import type { LocalizedText } from "@/features/branches/api/branchesApi";
import { PayDialog } from "@/features/visaMasterPayments/components/PayDialog";
// ─── Helpers ───────────────────────────────────────────────────────────────── // ─── Helpers ─────────────────────────────────────────────────────────────────
@@ -49,6 +51,7 @@ export default function SberPaymentsListPage() {
const deleteMutation = useDeleteSberPaymentReal(); const deleteMutation = useDeleteSberPaymentReal();
const [deleteTarget, setDeleteTarget] = useState<SberPaymentOrderItem | null>(null); const [deleteTarget, setDeleteTarget] = useState<SberPaymentOrderItem | null>(null);
const [payTarget, setPayTarget] = useState<SberPaymentOrderItem | null>(null);
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25); const [perPage, setPerPage] = useState(25);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
@@ -217,6 +220,17 @@ export default function SberPaymentsListPage() {
onEdit={() => navigate(`/sber-payments/${row.original.id}/edit`)} onEdit={() => navigate(`/sber-payments/${row.original.id}/edit`)}
onDelete={() => setDeleteTarget(row.original)} onDelete={() => setDeleteTarget(row.original)}
isDeleting={deleteMutation.isPending} isDeleting={deleteMutation.isPending}
extraActions={
row.original.status === "approved"
? [
{
icon: CreditCard,
title: t("intlPayment.pay.action", "Töleg et"),
onClick: () => setPayTarget(row.original),
},
]
: []
}
/> />
), ),
size: 90, size: 90,
@@ -364,6 +378,14 @@ export default function SberPaymentsListPage() {
}} }}
isLoading={deleteMutation.isPending} isLoading={deleteMutation.isPending}
/> />
<PayDialog
id={payTarget?.id ? String(payTarget.id) : ""}
open={payTarget !== null}
onOpenChange={(open) => {
if (!open) setPayTarget(null);
}}
/>
</div> </div>
); );
} }
@@ -2,11 +2,11 @@ import { format } from "date-fns";
import { Search, Download } from "lucide-react"; import { Search, Download } from "lucide-react";
import { useParams, useNavigate } from "react-router-dom"; import { useParams, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useState } from "react";
import { Skeleton } from "@/components/ui/skeleton"; import { Skeleton } from "@/components/ui/skeleton";
import { StatusCell } from "@/constants"; import { StatusCell } from "@/constants";
import { BentoGrid, BentoCard, InfoRow, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents"; import { BentoGrid, BentoCard, InfoRow, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments"; import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
import { PaymentHistoryTable } from "@/features/visaMasterPayments/components/PaymentHistoryTable";
import { ACCEPTED_DOC_DEFS, SENT_DOC_DEFS, docLabel, type TFn } from "@/features/sberPayments/constants/documents"; import { ACCEPTED_DOC_DEFS, SENT_DOC_DEFS, docLabel, type TFn } from "@/features/sberPayments/constants/documents";
// ─── Helpers ────────────────────────────────────────────────────────────────── // ─── Helpers ──────────────────────────────────────────────────────────────────
@@ -88,7 +88,6 @@ export default function SberPaymentViewPage() {
const t: TFn = (key, fallback) => _t(key, fallback ?? key) as string; const t: TFn = (key, fallback) => _t(key, fallback ?? key) as string;
const { id } = useParams<{ id: string }>(); const { id } = useParams<{ id: string }>();
const navigate = useNavigate(); const navigate = useNavigate();
const [historySearch, setHistorySearch] = useState("");
const { data: order, isLoading } = useIntlPayment(id ?? ""); const { data: order, isLoading } = useIntlPayment(id ?? "");
const deleteMutation = useDeleteIntlPayment(); const deleteMutation = useDeleteIntlPayment();
@@ -223,29 +222,7 @@ export default function SberPaymentViewPage() {
{/* ── Row 5: Töleg taryhy ───────────────────────────────────────────── */} {/* ── Row 5: Töleg taryhy ───────────────────────────────────────────── */}
<BentoGrid cols={1}> <BentoGrid cols={1}>
<BentoCard title={t("sberPayments.view.sections.paymentHistory", "Töleg taryhy")}> <BentoCard title={t("sberPayments.view.sections.paymentHistory", "Töleg taryhy")}>
<div className="p-4"> <PaymentHistoryTable orderId={order.id} />
<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("common.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="21" x2="9" y2="9" />
</svg>
</div>
<p className="text-sm">{t("sberPayments.view.noPaymentHistory", "Berlen kriteriýalara Töleg gabat gelmedi.")}</p>
</div>
</div>
</BentoCard> </BentoCard>
</BentoGrid> </BentoGrid>