refactor: 更新管理端页面元数据,统一国际化支持,移除冗余代码
This commit is contained in:
@@ -27,15 +27,11 @@ export function JackpotConfigScreen() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ConfigDocPage title={t("configTitle")} description={t("pageDescription")}>
|
||||
<ConfigSection title={t("poolsSectionTitle")} description={t("poolsSectionDescription")}>
|
||||
<ConfigDocPage title={t("configTitle")}>
|
||||
<ConfigSection title={t("poolsSectionTitle")}>
|
||||
<JackpotPoolsConsole embedded />
|
||||
</ConfigSection>
|
||||
<ConfigSection
|
||||
id="jackpot-records"
|
||||
title={t("recordsSectionTitle")}
|
||||
description={t("recordsSectionDescription")}
|
||||
>
|
||||
<ConfigSection id="jackpot-records" title={t("recordsSectionTitle")}>
|
||||
<JackpotRecordsConsole embedded />
|
||||
</ConfigSection>
|
||||
</ConfigDocPage>
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { formatAdminMinorUnits } from "@/lib/money";
|
||||
import { toast } from "sonner";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import type { AdminJackpotPoolRow } from "@/types/api/admin-jackpot";
|
||||
@@ -167,14 +166,7 @@ export function JackpotPoolsConsole({ embedded = false }: JackpotPoolsConsolePro
|
||||
const d = drafts[p.id] ?? toDraft(p);
|
||||
return (
|
||||
<div key={p.id} className="space-y-4 rounded-lg border border-border p-4">
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<h3 className="font-mono text-sm font-semibold">{p.currency_code}</h3>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{t("displayBalance", {
|
||||
amount: formatAdminMinorUnits(p.current_amount, p.currency_code),
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="font-mono text-sm font-semibold">{p.currency_code}</h3>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor={`amt-${p.id}`}>{t("currentAmount")}</Label>
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user