From 11903e23bf52fb187f6bf6290bfb0acd8f2212e0 Mon Sep 17 00:00:00 2001 From: Jelaletdin12 Date: Sat, 24 Oct 2026 22:07:16 +0500 Subject: [PATCH] removed db icon --- .../components/PaymentDetailDialog.tsx | 85 ++++++++++++++++++- .../components/PaymentHistoryTable.tsx | 28 +++--- src/lib/i18n/locales/en.json | 2 + src/lib/i18n/locales/ru.json | 2 + src/lib/i18n/locales/tk.json | 2 + .../onlinePaymenHistoryView.tsx | 2 +- .../onlinePaymentDetailView.tsx | 81 ++++++++---------- 7 files changed, 143 insertions(+), 59 deletions(-) diff --git a/src/features/visaMasterPayments/components/PaymentDetailDialog.tsx b/src/features/visaMasterPayments/components/PaymentDetailDialog.tsx index 4040af2..e26a77a 100644 --- a/src/features/visaMasterPayments/components/PaymentDetailDialog.tsx +++ b/src/features/visaMasterPayments/components/PaymentDetailDialog.tsx @@ -1,12 +1,13 @@ import { Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; -import { Database, AlertTriangle } from "lucide-react"; +import { Database, AlertTriangle, Eye } from "lucide-react"; import { Skeleton } from "@/components/ui/skeleton"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog"; -import { useGetOnlinePaymentDetail } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory"; +import { useGetOnlinePaymentDetail, useGetOnlinePaymentById } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory"; import { GatewayStatusBadge, PaidBadge } from "@/features/onlinePaymentHistory/components/PaymentStatusBadge"; import { formatFromApiDate } from "@/lib/utils/dateUtils"; +import { rawEnumKey } from "@/constants/enumLabels"; function resolveLang(lang: string): "en" | "ru" | "tm" { if (lang === "ru") return "ru"; @@ -200,3 +201,83 @@ export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDe ); } + +// ─── LastStepDialog ─────────────────────────────────────────────────────────── + +interface LastStepDialogProps { + /** The order ID (row.original.orderId) used to fetch the step history. */ + orderId: number | null; + open: boolean; + onOpenChange: (open: boolean) => void; +} + +/** + * Opens a dialog showing only the most recent payment history step + * for the given order. Used by the Eye icon in PaymentHistoryTable. + */ +export function LastStepDialog({ orderId, open, onOpenChange }: LastStepDialogProps) { + const { t } = useTranslation(); + const { data: steps, isLoading } = useGetOnlinePaymentById(orderId ?? 0); + + // The "last" step is the one with the highest createdAt (or last element if already sorted desc). + const lastStep = steps?.length ? [...steps].sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0] : null; + + const detailEntries = Object.entries(lastStep?.detail ?? {}); + + return ( + + + +
+ + {t("onlinePayments.lastStep.title", "Iň soňky işlem")} +
+ {orderId && Order #{orderId}} +
+ + {isLoading ? ( +
+ + + +
+ ) : !lastStep ? ( +
{t("onlinePayments.noHistory", "Töleg taryhy tapylmady")}
+ ) : ( +
+ {/* Step header: status badge + time + operator */} +
+ + {formatFromApiDate(lastStep.createdAt)} + {lastStep.createdByName && {lastStep.createdByName}} +
+ + {/* Detail key-value grid */} + {detailEntries.length > 0 && ( +
+

+ {t("onlinePayments.detail.details", "Jikme-jikler")} +

+
+ {detailEntries.map(([key, value]) => ( +
+ + {t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key))} + + {String(value)} +
+ ))} +
+
+ )} + + {/* Step ID */} +

+ Step ID: {lastStep.id} +

+
+ )} +
+
+ ); +} diff --git a/src/features/visaMasterPayments/components/PaymentHistoryTable.tsx b/src/features/visaMasterPayments/components/PaymentHistoryTable.tsx index 01c8683..e6ddcc4 100644 --- a/src/features/visaMasterPayments/components/PaymentHistoryTable.tsx +++ b/src/features/visaMasterPayments/components/PaymentHistoryTable.tsx @@ -1,7 +1,6 @@ import { useState, useMemo } from "react"; -import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; -import { Database, Eye } from "lucide-react"; +import { Eye } from "lucide-react"; import type { VisibilityState } from "@tanstack/react-table"; import { DataTable, type ColumnDef, type SortingState } from "@/components/dataTable"; @@ -10,7 +9,7 @@ import { Button } from "@/components/ui/button"; import { useGetPaymentGateway } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory"; import { ActiveStatusCell } from "@/constants/statusCells"; import { formatFromApiDate } from "@/lib/utils/dateUtils"; -import { PaymentDetailDialog } from "./PaymentDetailDialog"; +import { PaymentDetailDialog, LastStepDialog } from "./PaymentDetailDialog"; // ─── Helpers ────────────────────────────────────────────────────────────────── @@ -101,10 +100,10 @@ interface PaymentHistoryTableProps { export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableProps = {}) { const { t } = useTranslation(); - const navigate = useNavigate(); // ─── Dialog State ────────────────────────────────────────────────────────── const [selectedPaymentId, setSelectedPaymentId] = useState(null); + const [selectedOrderId, setSelectedOrderId] = useState(null); // ─── Pagination & Search ─────────────────────────────────────────────────── const [page, setPage] = useState(1); @@ -258,7 +257,7 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP cell: ({ row }) => (
{/* Storage (Database) icon: opens payment detail dialog */} - + */} - {/* Eye icon: navigates to audit/history step timeline */} + {/* Eye icon: opens last-step dialog */}
); } diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index f3bbb0f..e510f1f 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -1614,6 +1614,8 @@ "onlinePayments.paid.unpaid": "Unpaid", "onlinePayments.detail.stepsCount": "Steps", "onlinePayments.noHistory": "No payment history found", + "onlinePayments.lastStep.title": "Last Transaction", + "onlinePayments.detail.details": "Details", "onlinePayments.detailKeys.order_id": "Order ID", "onlinePayments.detailKeys.order_unique_id": "Unique order ID", "onlinePayments.detailKeys.type": "Type", diff --git a/src/lib/i18n/locales/ru.json b/src/lib/i18n/locales/ru.json index 9ae76ce..4e0ab62 100644 --- a/src/lib/i18n/locales/ru.json +++ b/src/lib/i18n/locales/ru.json @@ -1615,6 +1615,8 @@ "onlinePayments.paid.unpaid": "Не оплачено", "onlinePayments.detail.stepsCount": "Шаги", "onlinePayments.noHistory": "История платежа не найдена", + "onlinePayments.lastStep.title": "Последняя транзакция", + "onlinePayments.detail.details": "Детали", "onlinePayments.detailKeys.order_id": "ID заказа", "onlinePayments.detailKeys.order_unique_id": "Уникальный ID заказа", "onlinePayments.detailKeys.type": "Тип", diff --git a/src/lib/i18n/locales/tk.json b/src/lib/i18n/locales/tk.json index 54c85c3..91e87de 100644 --- a/src/lib/i18n/locales/tk.json +++ b/src/lib/i18n/locales/tk.json @@ -1613,6 +1613,8 @@ "onlinePayments.paid.unpaid": "Tölenmedi", "onlinePayments.detail.stepsCount": "Ädimler", "onlinePayments.noHistory": "Töleg taryhy tapylmady", + "onlinePayments.lastStep.title": "Iň soňky hereket", + "onlinePayments.detail.details": "Maglumatlar", "onlinePayments.detailKeys.order_id": "Order ID", "onlinePayments.detailKeys.order_unique_id": "Unikal order ID", "onlinePayments.detailKeys.type": "Görnüşi", diff --git a/src/pages/onlinePaymentsHistory/onlinePaymenHistoryView.tsx b/src/pages/onlinePaymentsHistory/onlinePaymenHistoryView.tsx index beb0ef6..6612a04 100644 --- a/src/pages/onlinePaymentsHistory/onlinePaymenHistoryView.tsx +++ b/src/pages/onlinePaymentsHistory/onlinePaymenHistoryView.tsx @@ -99,7 +99,7 @@ export default function OnlinePaymentDetailPage() {

{t("onlinePayments.detail.title", "Onlaýn töleg taryhy giňişleýin")} - {orderId ? ` — Order #${orderId}` : ""} + {orderId ? ` — Order #${orderId}` : ""} ffffffffffffffffffffffffffff

diff --git a/src/pages/onlinePaymentsHistory/onlinePaymentDetailView.tsx b/src/pages/onlinePaymentsHistory/onlinePaymentDetailView.tsx index f01c78b..bf902c4 100644 --- a/src/pages/onlinePaymentsHistory/onlinePaymentDetailView.tsx +++ b/src/pages/onlinePaymentsHistory/onlinePaymentDetailView.tsx @@ -8,7 +8,6 @@ import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents"; import { GatewayStatusBadge, PaidBadge } from "@/features/onlinePaymentHistory/components/PaymentStatusBadge"; import { useGetOnlinePaymentDetail, useGetOnlinePaymentById } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory"; import { formatFromApiDate } from "@/lib/utils/dateUtils"; -import type { PaymentHistoryStep } from "@/features/onlinePaymentHistory/api/onlinePaymentsHistoryApi"; import { rawEnumKey, type TranslateFn } from "@/constants/enumLabels"; function formatDateTime(iso: string | null | undefined): string { @@ -26,39 +25,6 @@ function detailKeyLabel(key: string, t: TranslateFn): string { return t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key)); } -function StepTimelineRow({ step }: { step: PaymentHistoryStep }) { - const { t } = useTranslation(); - const detailEntries = Object.entries(step.detail ?? {}); - - return ( -
-
-
-
-
- -
-
- - {formatDateTime(step.createdAt)} - {step.createdByName} -
- - {detailEntries.length > 0 && ( -
- {detailEntries.map(([key, value]) => ( -
- {detailKeyLabel(key, t)} - {String(value)} -
- ))} -
- )} -
-
- ); -} - export default function OnlinePaymentDetailViewPage() { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); @@ -108,8 +74,8 @@ export default function OnlinePaymentDetailViewPage() {

{t("onlinePayments.paymentViewTitle", "Töleg maglumaty")}: #{data.id}

- - + {/* */} + {/* */}
{data.orderNumber && (

@@ -226,16 +192,39 @@ export default function OnlinePaymentDetailViewPage() { - {/* ── Row 3: Step-by-Step History Log (Timeline) ───────────────────────── */} - {steps && steps.length > 0 && ( - -

- {steps.map((step) => ( - - ))} -
- - )} + {/* ── Row 3: Last Payment Step ──────────────────────────────────────────── */} + {steps && + steps.length > 0 && + (() => { + const lastStep = [...steps].sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0]; + const detailEntries = Object.entries(lastStep.detail ?? {}); + + return ( + +
+ {/* Header: status + time + operator */} +
+ + {formatDateTime(lastStep.createdAt)} + {lastStep.createdByName && {lastStep.createdByName}} + Step ID: {lastStep.id} +
+ + {/* Detail key-value rows */} + {detailEntries.length > 0 && ( +
+ {detailEntries.map(([key, value]) => ( +
+ {detailKeyLabel(key, t)} + {String(value)} +
+ ))} +
+ )} +
+
+ ); + })()}
); }