removed db icon

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

No files matched your search

@@ -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>
);
}