refactor: 更新管理端页面元数据,统一国际化支持,移除冗余代码

This commit is contained in:
2026-05-21 17:27:52 +08:00
parent 26feed3c4f
commit e8a5507411
77 changed files with 1669 additions and 732 deletions

View File

@@ -20,6 +20,7 @@ import {
TableRow,
} from "@/components/ui/table";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { useExportLabels } from "@/hooks/use-export-labels";
import { formatAdminMinorUnits } from "@/lib/money";
import { LotteryApiBizError } from "@/types/api/errors";
import type {
@@ -33,6 +34,8 @@ type JackpotRecordsConsoleProps = {
export function JackpotRecordsConsole({ embedded = false }: JackpotRecordsConsoleProps) {
const { t } = useTranslation(["jackpot", "common"]);
const payoutExport = useExportLabels("jackpotPayouts");
const contributionExport = useExportLabels("jackpotContributions");
const formatDt = useAdminDateTimeFormatter();
const [drawNo, setDrawNo] = useState("");
const [appliedDrawNo, setAppliedDrawNo] = useState("");
@@ -105,36 +108,71 @@ export function JackpotRecordsConsole({ embedded = false }: JackpotRecordsConsol
return translated === key ? value : translated;
};
const filterBlock = embedded ? (
<div className="mb-4 flex flex-col gap-3 sm:flex-row sm:items-end">
<div className="flex max-w-xs flex-1 flex-col gap-1.5">
<Label htmlFor="jk-draw">{t("drawNo")}</Label>
<Input
id="jk-draw"
className="font-mono"
value={drawNo}
onChange={(e) => setDrawNo(e.target.value)}
placeholder={t("optional")}
/>
</div>
<Button type="button" onClick={applyDraw}>
{t("apply")}
</Button>
</div>
) : (
<Card className="mb-6">
<CardHeader className="pb-3">
<CardTitle className="text-base">{t("filter")}</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-3 sm:flex-row sm:items-end">
<div className="flex max-w-xs flex-1 flex-col gap-1.5">
<Label htmlFor="jk-draw">{t("drawNo")}</Label>
<Input
id="jk-draw"
className="font-mono"
value={drawNo}
onChange={(e) => setDrawNo(e.target.value)}
placeholder={t("optional")}
/>
</div>
<Button type="button" onClick={applyDraw}>
{t("apply")}
</Button>
</CardContent>
</Card>
);
const payoutHeader = embedded ? (
<p className="mb-3 text-sm font-semibold">{t("payoutRecords")}</p>
) : (
<CardHeader>
<CardTitle className="text-base">{t("payoutRecords")}</CardTitle>
</CardHeader>
);
const contributionHeader = embedded ? (
<p className="mb-3 text-sm font-semibold">{t("contributionRecords")}</p>
) : (
<CardHeader>
<CardTitle className="text-base">{t("contributionRecords")}</CardTitle>
</CardHeader>
);
const content = (
<>
<Card className="mb-6">
<CardHeader className="pb-3">
<CardTitle className="text-base">{t("filter")}</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-3 sm:flex-row sm:items-end">
<div className="flex max-w-xs flex-1 flex-col gap-1.5">
<Label htmlFor="jk-draw">{t("drawNo")}</Label>
<Input
id="jk-draw"
className="font-mono"
value={drawNo}
onChange={(e) => setDrawNo(e.target.value)}
placeholder={t("optional")}
/>
</div>
<Button type="button" onClick={applyDraw}>
{t("apply")}
</Button>
</CardContent>
</Card>
{filterBlock}
{err ? <p className="text-destructive mb-4 text-sm">{err}</p> : null}
<Card className="mb-8">
<CardHeader>
<CardTitle className="text-base">{t("payoutRecords")}</CardTitle>
</CardHeader>
<CardContent>
<Card className={embedded ? "mb-6 border-border/60 shadow-none" : "mb-8"}>
{!embedded ? payoutHeader : null}
<CardContent className={embedded ? "p-0" : undefined}>
{embedded ? payoutHeader : null}
{loadingP && !payouts ? (
<p className="text-muted-foreground text-sm">{t("states.loading", { ns: "common" })}</p>
) : (
@@ -142,8 +180,8 @@ export function JackpotRecordsConsole({ embedded = false }: JackpotRecordsConsol
<div className="admin-table-toolbar">
<AdminTableExportButton
tableId="jackpot-payout-table"
filename="奖池派彩记录"
sheetName="奖池派彩"
filename={payoutExport.filename}
sheetName={payoutExport.sheetName}
/>
</div>
<Table id="jackpot-payout-table">
@@ -194,11 +232,10 @@ export function JackpotRecordsConsole({ embedded = false }: JackpotRecordsConsol
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="text-base">{t("contributionRecords")}</CardTitle>
</CardHeader>
<CardContent>
<Card className={embedded ? "border-border/60 shadow-none" : undefined}>
{!embedded ? contributionHeader : null}
<CardContent className={embedded ? "p-0" : undefined}>
{embedded ? contributionHeader : null}
{loadingC && !contribs ? (
<p className="text-muted-foreground text-sm">{t("states.loading", { ns: "common" })}</p>
) : (
@@ -206,8 +243,8 @@ export function JackpotRecordsConsole({ embedded = false }: JackpotRecordsConsol
<div className="admin-table-toolbar">
<AdminTableExportButton
tableId="jackpot-contribution-table"
filename="奖池注入记录"
sheetName="奖池注入"
filename={contributionExport.filename}
sheetName={contributionExport.sheetName}
/>
</div>
<Table id="jackpot-contribution-table">