feat: 增强结果展示与用户交互
- 在 PlayerBottomNav 中新增注单导航选项 - 在 DrawResultDetailScreen 中添加高亮显示用户命中号码的功能,并显示个人派彩信息 - 在 DrawResultsListScreen 中引入 JackpotResultsStrip 组件以展示奖池信息 - 在 TwentyThreeResultsGrid 中实现命中号码的高亮效果,提升用户体验
This commit is contained in:
54
src/features/results/jackpot-results-strip.tsx
Normal file
54
src/features/results/jackpot-results-strip.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { getJackpotSummary } from "@/api/jackpot";
|
||||
import { formatMinorAsCurrency } from "@/lib/money";
|
||||
|
||||
type JackpotResultsStripProps = {
|
||||
currencyCode?: string;
|
||||
};
|
||||
|
||||
/** 开奖模块顶部:Jackpot 当前池(公开接口) */
|
||||
export function JackpotResultsStrip({
|
||||
currencyCode = "NPR",
|
||||
}: JackpotResultsStripProps) {
|
||||
const [minor, setMinor] = 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);
|
||||
}
|
||||
} catch {
|
||||
if (!cancelled) {
|
||||
setEnabled(false);
|
||||
setMinor(null);
|
||||
}
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [currencyCode]);
|
||||
|
||||
if (!enabled || minor === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rounded-lg border border-amber-500/30 bg-gradient-to-r from-amber-500/10 via-amber-400/5 to-transparent px-3 py-2">
|
||||
<p className="text-[11px] font-medium uppercase tracking-wide text-amber-800/90 dark:text-amber-200/90">
|
||||
Jackpot
|
||||
</p>
|
||||
<p className="font-mono text-sm font-semibold tabular-nums text-amber-950 dark:text-amber-50">
|
||||
{formatMinorAsCurrency(minor, currencyCode.toUpperCase())}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user