removed db icon

This commit is contained in:
Jelaletdin12
2026-10-24 22:07:16 +05:00
parent 879ed77121
commit 11903e23bf
7 changed files with 143 additions and 59 deletions

View File

@@ -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
</Dialog>
);
}
// ─── 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 (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-lg max-h-[80vh] overflow-y-auto">
<DialogHeader>
<div className="flex items-center gap-2">
<Eye className="size-5 text-primary" />
<DialogTitle className="text-base font-semibold">{t("onlinePayments.lastStep.title", "Iň soňky işlem")}</DialogTitle>
</div>
{orderId && <DialogDescription className="text-xs">Order #{orderId}</DialogDescription>}
</DialogHeader>
{isLoading ? (
<div className="space-y-3 py-2">
<Skeleton className="h-6 w-1/3" />
<Skeleton className="h-4 w-1/2" />
<Skeleton className="h-24 w-full rounded-lg" />
</div>
) : !lastStep ? (
<div className="py-8 text-center text-sm text-muted-foreground">{t("onlinePayments.noHistory", "Töleg taryhy tapylmady")}</div>
) : (
<div className="space-y-4 text-xs">
{/* Step header: status badge + time + operator */}
<div className="flex flex-wrap items-center gap-3 px-1">
<GatewayStatusBadge status={lastStep.step} />
<span className="text-muted-foreground whitespace-nowrap">{formatFromApiDate(lastStep.createdAt)}</span>
{lastStep.createdByName && <span className="text-muted-foreground">{lastStep.createdByName}</span>}
</div>
{/* Detail key-value grid */}
{detailEntries.length > 0 && (
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
{t("onlinePayments.detail.details", "Jikme-jikler")}
</p>
<div className="space-y-1.5">
{detailEntries.map(([key, value]) => (
<div key={key} className="flex gap-2">
<span className="text-muted-foreground font-medium min-w-[130px] shrink-0">
{t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key))}
</span>
<span className="text-foreground break-all">{String(value)}</span>
</div>
))}
</div>
</div>
)}
{/* Step ID */}
<p className="text-muted-foreground text-[11px] px-1">
Step ID: <span className="font-mono">{lastStep.id}</span>
</p>
</div>
)}
</DialogContent>
</Dialog>
);
}

View File

@@ -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<number | null>(null);
const [selectedOrderId, setSelectedOrderId] = useState<number | null>(null);
// ─── Pagination & Search ───────────────────────────────────────────────────
const [page, setPage] = useState(1);
@@ -258,7 +257,7 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
cell: ({ row }) => (
<div className="flex items-center justify-end gap-1">
{/* Storage (Database) icon: opens payment detail dialog */}
<Button
{/* <Button
variant="ghost"
size="icon"
className="size-8 text-muted-foreground hover:text-foreground cursor-pointer"
@@ -269,17 +268,17 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
}}
>
<Database className="size-4" />
</Button>
</Button> */}
{/* Eye icon: navigates to audit/history step timeline */}
{/* Eye icon: opens last-step dialog */}
<Button
variant="ghost"
size="icon"
className="size-8 text-muted-foreground hover:text-foreground cursor-pointer"
title={t("onlinePayments.auditHistory", "Töleg taryhy")}
title={t("onlinePayments.lastStep.title", "Iň soňky işlem")}
onClick={(e) => {
e.stopPropagation();
navigate(`/online-payments-history/${row.original.orderId || row.original.id}`);
setSelectedOrderId(row.original.orderId || row.original.id);
}}
>
<Eye className="size-4" />
@@ -289,7 +288,7 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
size: 80,
},
],
[t, navigate],
[t],
);
const columnMeta: ColumnMeta[] = useMemo(
@@ -354,6 +353,15 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
if (!open) setSelectedPaymentId(null);
}}
/>
{/* ── Last Step Dialog (Triggered on clicking eye icon) ─────────────────── */}
<LastStepDialog
orderId={selectedOrderId}
open={selectedOrderId !== null}
onOpenChange={(open) => {
if (!open) setSelectedOrderId(null);
}}
/>
</div>
);
}

View File

@@ -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",

View File

@@ -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": "Тип",

View File

@@ -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",

View File

@@ -99,7 +99,7 @@ export default function OnlinePaymentDetailPage() {
<div>
<h1 className="text-xl font-semibold text-foreground mb-6">
{t("onlinePayments.detail.title", "Onlaýn töleg taryhy giňişleýin")}
{orderId ? ` — Order #${orderId}` : ""}
{orderId ? ` — Order #${orderId}` : ""} ffffffffffffffffffffffffffff
</h1>
<Section>

View File

@@ -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 (
<div className="flex gap-4 relative">
<div className="flex flex-col items-center">
<div className="w-3 h-3 rounded-full bg-primary mt-1 shrink-0 z-10" />
<div className="w-px flex-1 bg-border mt-1" />
</div>
<div className="pb-6 flex-1 min-w-0">
<div className="flex flex-wrap items-center gap-3 mb-1">
<GatewayStatusBadge status={step.step} />
<span className="text-xs text-muted-foreground whitespace-nowrap">{formatDateTime(step.createdAt)}</span>
<span className="text-xs text-muted-foreground">{step.createdByName}</span>
</div>
{detailEntries.length > 0 && (
<div className="mt-2 rounded-md border bg-muted/30 px-3 py-2 space-y-1">
{detailEntries.map(([key, value]) => (
<div key={key} className="flex gap-2 text-xs">
<span className="text-muted-foreground font-medium min-w-[120px]">{detailKeyLabel(key, t)}</span>
<span className="text-foreground break-all">{String(value)}</span>
</div>
))}
</div>
)}
</div>
</div>
);
}
export default function OnlinePaymentDetailViewPage() {
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
@@ -108,8 +74,8 @@ export default function OnlinePaymentDetailViewPage() {
<h1 className="text-xl font-semibold text-foreground tracking-tight">
{t("onlinePayments.paymentViewTitle", "Töleg maglumaty")}: #{data.id}
</h1>
<GatewayStatusBadge status={data.gatewayStatus} />
<PaidBadge paid={data.paid} />
{/* <GatewayStatusBadge status={data.gatewayStatus} /> */}
{/* <PaidBadge paid={data.paid} /> */}
</div>
{data.orderNumber && (
<p className="text-xs text-muted-foreground mt-0.5">
@@ -226,16 +192,39 @@ export default function OnlinePaymentDetailViewPage() {
</BentoCard>
</BentoGrid>
{/* ── Row 3: Step-by-Step History Log (Timeline) ───────────────────────── */}
{steps && steps.length > 0 && (
<BentoCard title={t("onlinePayments.detail.stepsCount", "Ädimler taryhy")}>
<div className="p-4">
{steps.map((step) => (
<StepTimelineRow key={step.id} step={step} />
))}
</div>
</BentoCard>
)}
{/* ── 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 (
<BentoCard title={t("onlinePayments.lastStep.title", "Iň soňky işlem")}>
<div className="p-4 space-y-3">
{/* Header: status + time + operator */}
<div className="flex flex-wrap items-center gap-3">
<GatewayStatusBadge status={lastStep.step} />
<span className="text-xs text-muted-foreground whitespace-nowrap">{formatDateTime(lastStep.createdAt)}</span>
{lastStep.createdByName && <span className="text-xs text-muted-foreground">{lastStep.createdByName}</span>}
<span className="text-xs text-muted-foreground font-mono ml-auto">Step ID: {lastStep.id}</span>
</div>
{/* Detail key-value rows */}
{detailEntries.length > 0 && (
<div className="rounded-md border bg-muted/30 px-3 py-2 space-y-1">
{detailEntries.map(([key, value]) => (
<div key={key} className="flex gap-2 text-xs">
<span className="text-muted-foreground font-medium min-w-[130px] shrink-0">{detailKeyLabel(key, t)}</span>
<span className="text-foreground break-all">{String(value)}</span>
</div>
))}
</div>
)}
</div>
</BentoCard>
);
})()}
</div>
);
}