Files
lotteryFront/src/features/results/jackpot-results-strip.tsx
kang 626914feb6 feat: 优化多语言文案接入并升级大厅与钱包交互体验
- 补充大厅下注结果、快速填单、查中奖、分页与通用操作多语言文案
- 移除多处界面默认文案回退,统一改用 i18n 配置输出
- 优化大厅快速填单、开奖结果入口与注单筛选区域视觉交互
- 重构钱包转入转出弹窗与流水卡片样式,增强金额与状态信息展示
2026-05-20 17:56:18 +08:00

65 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { getJackpotSummary } from "@/api/jackpot";
import { formatMinorAsCurrency } from "@/lib/money";
type JackpotResultsStripProps = {
currencyCode?: string;
};
/** 开奖模块顶部Jackpot 当前池(公开接口) */
export function JackpotResultsStrip({
currencyCode = "NPR",
}: JackpotResultsStripProps) {
const { t } = useTranslation("player");
const [minor, setMinor] = useState<number | null>(null);
const [gap, setGap] = useState<number | null>(null);
const [enabled, setEnabled] = useState(false);
useEffect(() => {
let cancelled = false;
void (async () => {
try {
const j = await getJackpotSummary(currencyCode);
if (!cancelled) {
setEnabled(j.enabled);
setMinor(j.current_amount_minor);
setGap(j.draws_since_last_burst);
}
} catch {
if (!cancelled) {
setEnabled(false);
setMinor(null);
setGap(null);
}
}
})();
return () => {
cancelled = true;
};
}, [currencyCode]);
if (!enabled || minor === null) {
return null;
}
return (
<div className="rounded-xl border border-amber-200 bg-gradient-to-r from-amber-100 via-white to-[#f8fbff] px-3 py-3 shadow-[0_8px_20px_rgba(180,83,9,0.08)]">
<p className="text-[11px] font-black uppercase tracking-normal text-amber-700">
{t("results.jackpotLabel")}
</p>
<p className="font-mono text-lg font-black tabular-nums text-[#0b3f96]">
{formatMinorAsCurrency(minor, currencyCode.toUpperCase())}
</p>
{gap !== null ? (
<p className="mt-1 text-xs font-semibold text-amber-800">
{t("results.jackpotGap", { count: gap })}
</p>
) : null}
</div>
);
}