added wifi icon to online history

This commit is contained in:
Jelaletdin12
2026-10-25 01:37:10 +05:00
parent 524733ad9f
commit c3cf23a192
12 changed files with 178 additions and 140 deletions

View File

@@ -1,7 +1,7 @@
import type React from "react";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Database, AlertTriangle, Eye, ExternalLink } from "lucide-react";
import { AlertTriangle, Database, Eye, ExternalLink } from "lucide-react";
import { Skeleton } from "@/components/ui/skeleton";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog";
@@ -23,9 +23,8 @@ interface PaymentDetailDialogProps {
}
export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDetailDialogProps) {
const { t, i18n } = useTranslation();
const lang = resolveLang(i18n.language);
const { data, isLoading, isError } = useGetOnlinePaymentDetail(paymentId ?? 0);
const { t } = useTranslation();
const { data, isLoading, isError } = useGetOnlinePaymentDetail(paymentId ?? 0, { lang: "tm" });
return (
<Dialog open={open} onOpenChange={onOpenChange}>
@@ -34,147 +33,42 @@ export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDe
<div className="flex items-center gap-2 pr-6 flex-wrap">
<Database className="size-5 text-primary shrink-0" />
<DialogTitle className="text-base font-semibold">
{t("onlinePayments.paymentViewTitle", "Töleg maglumaty")}: #{paymentId}
{t("onlinePayments.paymentViewTitle", "Halk bankdan gelen netije")}: #{paymentId}
</DialogTitle>
{data && (
<>
<GatewayStatusBadge status={data.gatewayStatus} />
<PaidBadge paid={data.paid} />
</>
)}
</div>
{data?.orderNumber && (
<DialogDescription className="text-xs">
{t("onlinePayments.columns.orderNumber", "Sargyt belgisi")}: {data.orderNumber}
</DialogDescription>
)}
<DialogDescription className="text-xs">{t("onlinePayments.gatewayResponse.title", "Gateway response")}</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-28 w-full rounded-lg" />
<Skeleton className="h-28 w-full rounded-lg" />
<Skeleton className="h-72 w-full rounded-lg" />
</div>
) : isError || !data ? (
<div className="py-8 text-center text-sm text-destructive">{t("common.error", "Maglumat ýüklenende ýalňyşlyk ýüze çykdy")}</div>
) : (
<div className="space-y-3 text-xs">
{/* Gateway error alert */}
{data.gatewayResponse && (data.gatewayResponse.errorCode || data.gatewayResponse.errorMessage) && (
<div className="flex items-start gap-2.5 p-3 rounded-lg border border-destructive/30 bg-destructive/10 text-destructive">
<AlertTriangle className="size-4 shrink-0 mt-0.5" />
<div className="space-y-0.5">
<div className="space-y-3">
{data.gatewayResponse && (data.gatewayResponse.errorCode != null || data.gatewayResponse.errorMessage) && (
<div className="flex items-start gap-2.5 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-destructive">
<AlertTriangle className="mt-0.5 size-4 shrink-0" />
<div className="space-y-0.5 text-xs">
<div className="font-semibold">
Gateway ýalňyşlygy {data.gatewayResponse.errorCode ? `(${data.gatewayResponse.errorCode})` : ""}
{t("onlinePayments.gatewayErrorTitle", "Gateway error")}
{data.gatewayResponse.errorCode != null && (
<span>
{" "}
({t("onlinePayments.gateway.errorCode", "Error code")}: {data.gatewayResponse.errorCode})
</span>
)}
</div>
{data.gatewayResponse.errorMessage && <div>{data.gatewayResponse.errorMessage}</div>}
</div>
</div>
)}
{/* Section 1: General */}
<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.sectionGeneral", "Esasy maglumatlar")}
</p>
<div className="space-y-1.5">
<Row label={t("common.id", "ID")}>
<span className="font-mono font-medium">{data.id}</span>
</Row>
<Row label={t("onlinePayments.columns.orderId", "Sargyt ID")}>
<Link to={`/visa-master/${data.orderId}`} className="font-mono text-primary hover:underline">
#{data.orderId}
</Link>
</Row>
<Row label={t("onlinePayments.columns.orderNumber", "Sargyt belgisi")}>
<span className="font-mono">{data.orderNumber || "—"}</span>
</Row>
<Row label={t("onlinePayments.columns.type", "Görnüşi")}>
<span className="uppercase font-medium">{data.type}</span>
</Row>
{data.description && (
<Row label={t("onlinePayments.columns.description", "Düşündiriş")}>
<span>{data.description}</span>
</Row>
)}
<Row label={t("onlinePayments.columns.createdAt", "Döredilen wagty")}>
<span>{formatFromApiDate(data.createdAt)}</span>
</Row>
<Row label={t("onlinePayments.columns.updatedAt", "Täzelenen wagty")}>
<span>{formatFromApiDate(data.updatedAt)}</span>
</Row>
</div>
</div>
{/* Section 2: Financial */}
<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.sectionFinancial", "Maliýe maglumatlary")}
</p>
<div className="space-y-1.5">
<Row label={t("onlinePayments.columns.amountTmt", "Töleg möçberi")}>
<span className="font-medium">{data.amountTmt?.toLocaleString?.() ?? data.amountTmt} TMT</span>
</Row>
<Row label={t("onlinePayments.columns.totalAmount", "Jemi töleg möçberi")}>
<span className="font-semibold text-primary">{data.totalAmountTmt?.toLocaleString?.() ?? data.totalAmountTmt} TMT</span>
</Row>
<Row label={t("onlinePayments.columns.bankFeeTmt", "Bank komissiýasy")}>
<span>{data.bankFeeTmt?.toLocaleString?.() ?? data.bankFeeTmt} TMT</span>
</Row>
<Row label={t("onlinePayments.columns.gbusFeeTmt", "GBUS komissiýasy")}>
<span>{data.gbusFeeTmt?.toLocaleString?.() ?? data.gbusFeeTmt} TMT</span>
</Row>
{data.amountUsd != null && (
<Row label={t("onlinePayments.columns.amountUsd", "Möçber (USD)")}>
<span>{data.amountUsd} $</span>
</Row>
)}
{data.exchangeRateUsd != null && (
<Row label={t("onlinePayments.columns.exchangeRateUsd", "Hümmet (USD)")}>
<span>{data.exchangeRateUsd} TMT</span>
</Row>
)}
{data.paymentPeriod && (
<Row label={t("onlinePayments.columns.paymentPeriod", "Töleg döwri")}>
<span>{formatFromApiDate(data.paymentPeriod)}</span>
</Row>
)}
{data.apiClient && (
<Row label={t("onlinePayments.columns.apiClient", "API Client")}>
<span className="font-mono">{data.apiClient}</span>
</Row>
)}
</div>
</div>
{/* Section 3: Customer & Branch */}
<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.sectionCustomer", "Müşderi we Şahamça")}
</p>
<div className="space-y-1.5">
<Row label={t("onlinePayments.columns.passport", "Müşderi")}>
<span className="font-medium">{[data.passportName, data.passportSurname].filter(Boolean).join(" ") || "—"}</span>
</Row>
<Row label={t("onlinePayments.columns.userId", "Ulanyjy ID")}>
<Link to={`/all-users/${data.userId}`} className="font-mono text-primary hover:underline">
#{data.userId}
</Link>
</Row>
<Row label={t("onlinePayments.columns.branch", "Şahamça")}>
<span>
{(typeof data.branchName === "string"
? data.branchName
: data.branchName?.[lang] || data.branchName?.tm || data.branchName?.en) || "—"}
</span>
</Row>
<Row label={t("onlinePayments.columns.createdByName", "Döreden işgär")}>
<span>{data.createdByName || "—"}</span>
</Row>
</div>
</div>
<pre className="max-h-[65vh] overflow-auto rounded-lg border border-border bg-muted/30 p-4 text-xs leading-5 text-foreground whitespace-pre-wrap break-all">
{JSON.stringify(data.gatewayResponse ?? {}, null, 2)}
</pre>
</div>
)}
</DialogContent>