"use client"; import { AlertTriangleIcon, CheckCircle2, LoaderCircle, Lock, WalletCards, XIcon, } from "lucide-react"; import Image from "next/image"; import { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { formatMinorAsCurrency } from "@/lib/money"; import { playLabel } from "@/lib/play-labels"; import type { TicketPreviewData, TicketPreviewWarning } from "@/types/api/ticket"; type HallBetPreviewDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; currencyCode: string; data: TicketPreviewData | null; placing: boolean; jackpotEnabled?: boolean; /** 界面 §4.2:封盘后禁止提交,主按钮文案为「已封盘」 */ allowSubmit?: boolean; onConfirmPlace: () => void; }; function WarningsBlock({ warnings }: { warnings: TicketPreviewWarning[] }) { const { t } = useTranslation("player"); if (warnings.length === 0) return null; return ( {t("hall.preview.warningsTitle")} {t("hall.preview.warningsDescription")} {warnings.map((w, i) => ( {w.number_4d} · {w.message} ))} ); } function SubmittingPanel() { const { t } = useTranslation("player"); return ( {t("hall.preview.processingTitle")} {t("hall.preview.processingDescription")} {t("hall.preview.processingProgress")} ); } /** * 预览弹窗 + 提交确认(产品文档 §10.1.2:预览不下单,确认后 place)。 */ export function HallBetPreviewDialog({ open, onOpenChange, currencyCode, data, placing, jackpotEnabled = false, allowSubmit = true, onConfirmPlace, }: HallBetPreviewDialogProps) { const { t } = useTranslation("player"); const summary = data?.summary; const lines = data?.lines ?? []; const periodRebate = summary?.instant_rebate_applied === false; const rebateLabel = periodRebate ? t("hall.preview.periodRebate", { defaultValue: "账期回水" }) : t("hall.preview.rebate"); useEffect(() => { if (open && !placing && !data) { onOpenChange(false); } }, [data, onOpenChange, open, placing]); if (placing) { return ( {}}> ); } if (!data) { return null; } return ( onOpenChange(false)} disabled={placing} className="absolute right-3 top-3 inline-flex size-9 items-center justify-center rounded-full text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:opacity-50" aria-label={t("actions.close")} > {t("hall.preview.title")} {t("hall.preview.description")} {!allowSubmit ? ( {t("hall.preview.sealedTitle")} {t("hall.preview.sealedDescription")} ) : null} {!data ? ( {t("hall.preview.empty")} ) : ( <> {t("hall.preview.draw")}: {data.draw.draw_id} {data.draw.status} {jackpotEnabled ? ( {t("hall.jackpotParticipation.title")} {t("hall.jackpotParticipation.previewDescription")} ) : null} No. {t("hall.result.number")} {t("orders.play")} {t("hall.preview.amount")} {rebateLabel} {t("hall.preview.estimatedMax")} {t("hall.preview.actual")} {lines.map((ln) => ( {ln.client_line_no} {ln.number} {playLabel(ln.play_code, t)} {ln.play_code} {formatMinorAsCurrency(ln.total_bet_amount, currencyCode)} {periodRebate ? "" : "-"} {formatMinorAsCurrency(ln.rebate_amount, currencyCode).replace(`${currencyCode} `, "")} {formatMinorAsCurrency(ln.estimated_max_payout, currencyCode)} {formatMinorAsCurrency(ln.actual_deduct_amount, currencyCode)} ))} {summary ? ( {t("hall.preview.totalBet")} {formatMinorAsCurrency(summary.total_bet_amount, currencyCode)} {rebateLabel} {periodRebate ? "" : "-"} {formatMinorAsCurrency(summary.total_rebate_amount, currencyCode).replace( `${currencyCode} `, "", )} {t("hall.preview.actualDeduct")} {formatMinorAsCurrency(summary.total_actual_deduct, currencyCode)} {t("hall.preview.estimatedPayout")} {formatMinorAsCurrency(summary.total_estimated_payout, currencyCode)} ) : null} {periodRebate ? ( {t("hall.preview.periodRebateHint", { defaultValue: "信用盘回水在账期结算入账,下注时按全额占用可用信用,此处为账期回水预估。", })} ) : null} {data.warnings.length > 0 ? ( ) : ( {t("hall.preview.noWarnings")} )} > )} onOpenChange(false)} disabled={placing} className="h-12 rounded-lg border-[#ff3650] bg-white text-base font-black text-[#e5002c] hover:bg-[#fff5f6]" > {t("hall.preview.backEdit")} {!allowSubmit && !placing ? : null} {placing ? t("hall.preview.submitting") : allowSubmit ? t("hall.preview.confirmSubmit") : t("hall.preview.sealedTitle")} ); }
{t("hall.preview.warningsDescription")}
{t("hall.preview.empty")}
{t("hall.preview.totalBet")}
{formatMinorAsCurrency(summary.total_bet_amount, currencyCode)}
{rebateLabel}
{periodRebate ? "" : "-"} {formatMinorAsCurrency(summary.total_rebate_amount, currencyCode).replace( `${currencyCode} `, "", )}
{t("hall.preview.actualDeduct")}
{formatMinorAsCurrency(summary.total_actual_deduct, currencyCode)}
{t("hall.preview.estimatedPayout")}
{formatMinorAsCurrency(summary.total_estimated_payout, currencyCode)}
{t("hall.preview.periodRebateHint", { defaultValue: "信用盘回水在账期结算入账,下注时按全额占用可用信用,此处为账期回水预估。", })}