refactor: 更新风险监控页面标题为国际化支持,优化风险池控制台的标题处理

This commit is contained in:
2026-05-22 16:11:36 +08:00
parent 51891548a5
commit 2d4a23968e
29 changed files with 491 additions and 94 deletions

View File

@@ -21,6 +21,12 @@ import {
import { getAdminAuditLogs } from "@/api/admin-audit";
import { getAdminPlayTypes } from "@/api/admin-config";
import { useAdminPlayCodeLabel, useAdminPlayTypeCatalog } from "@/hooks/use-admin-play-type-catalog";
import {
getAdminPlayTypesLoadPromise,
getCachedAdminPlayTypes,
resolveAdminPlayTypeDisplayName,
} from "@/lib/admin-play-types";
import { getAdminDraws, getAdminDrawFinanceSummary } from "@/api/admin-draws";
import { getAdminPlayers } from "@/api/admin-player";
import {
@@ -358,8 +364,10 @@ function resultRowCount(result: ReportResult | null): number {
}
export function ReportsConsole() {
const { t } = useTranslation(["reports", "common"]);
const { t, i18n } = useTranslation(["reports", "common"]);
useAdminCurrencyCatalog();
useAdminPlayTypeCatalog();
const playCodeLabel = useAdminPlayCodeLabel();
const formatTs = useAdminDateTimeFormatter();
const [selectedKey, setSelectedKey] = useState<ReportKey>(REPORTS[0].key);
const [filters, setFilters] = useState<ReportFilters>(emptyFilters);
@@ -388,17 +396,20 @@ export function ReportsConsole() {
const loadPlayOptions = useCallback(async () => {
try {
const payload = await getAdminPlayTypes();
await getAdminPlayTypesLoadPromise(getAdminPlayTypes);
setPlayOptions(
payload.items.map((item) => ({
getCachedAdminPlayTypes().map((item) => ({
code: item.play_code,
label: optionText(item.display_name_zh, item.play_code),
label: optionText(
resolveAdminPlayTypeDisplayName(item.play_code, i18n.language, item),
item.play_code,
),
})),
);
} catch {
setPlayOptions([]);
}
}, []);
}, [i18n.language]);
useEffect(() => {
void loadPlayOptions();
@@ -1056,7 +1067,7 @@ export function ReportsConsole() {
<TableCell className="font-mono text-xs">#{item.id}</TableCell>
<TableCell>{item.action_type}</TableCell>
<TableCell className="text-right">{formatPlainMoney(item.amount, result.raw.currency_code)}</TableCell>
<TableCell>{item.play_code || "-"}</TableCell>
<TableCell>{playCodeLabel(item.play_code)}</TableCell>
<TableCell>{item.ticket_no || "-"}</TableCell>
<TableCell>{item.player_id || "-"}</TableCell>
<TableCell>{item.source_reason || "-"}</TableCell>
@@ -1115,7 +1126,7 @@ export function ReportsConsole() {
if (result.key === "play_dimension") {
return result.raw.map((item) => (
<TableRow key={`${item.play_code}-${item.dimension}`}>
<TableCell className="font-medium">{item.play_code}</TableCell>
<TableCell className="font-medium">{playCodeLabel(item.play_code)}</TableCell>
<TableCell>{item.dimension}D</TableCell>
<TableCell className="text-right">{formatPlainMoney(item.total_bet_minor, "NPR")}</TableCell>
<TableCell className="text-right">{formatPlainMoney(item.total_payout_minor, "NPR")}</TableCell>
@@ -1130,7 +1141,7 @@ export function ReportsConsole() {
if (result.key === "rebate_commission") {
return result.raw.map((item) => (
<TableRow key={item.play_code}>
<TableCell className="font-medium">{item.play_code}</TableCell>
<TableCell className="font-medium">{playCodeLabel(item.play_code)}</TableCell>
<TableCell>{item.order_count}</TableCell>
<TableCell className="text-right">{formatPlainMoney(item.total_rebate_minor, "NPR")}</TableCell>
<TableCell className="text-right">{item.ticket_item_count}</TableCell>