feat(i18n, draws): 新增“随机填充”翻译并实现随机选号功能
在英文、尼泊尔语与中文语言包中新增 “Fill Randomly(随机填充)” 翻译文案,完善多语言支持。 在 DrawReviewConsole 组件中新增随机选号功能,用户可通过按钮一键填充随机号码。 优化开奖录入流程,减少手动输入操作,提升使用效率与用户体验。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { Rocket } from "lucide-react";
|
||||
import { Dices, Rocket } from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
@@ -46,6 +46,10 @@ const RESULT_SLOTS = [
|
||||
})),
|
||||
] as const;
|
||||
|
||||
function randomDrawNumber4d(): string {
|
||||
return String(Math.floor(Math.random() * 10_000)).padStart(4, "0");
|
||||
}
|
||||
|
||||
export function DrawReviewConsole({ drawId }: { drawId: string }) {
|
||||
const { t } = useTranslation(["draws", "common"]);
|
||||
const profile = useAdminProfile();
|
||||
@@ -91,6 +95,10 @@ export function DrawReviewConsole({ drawId }: { drawId: string }) {
|
||||
data,
|
||||
]);
|
||||
|
||||
function fillRandomManualNumbers(): void {
|
||||
setManualNumbers(RESULT_SLOTS.map(() => randomDrawNumber4d()));
|
||||
}
|
||||
|
||||
async function saveManualDraft(): Promise<void> {
|
||||
if (!Number.isFinite(idNum)) return;
|
||||
const invalid = manualNumbers.some((n) => !/^[0-9]{4}$/.test(n));
|
||||
@@ -163,6 +171,15 @@ export function DrawReviewConsole({ drawId }: { drawId: string }) {
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={!canManageDraw || savingManual}
|
||||
onClick={fillRandomManualNumbers}
|
||||
>
|
||||
<Dices className="size-4" aria-hidden />
|
||||
{t("fillRandomNumbers")}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
|
||||
Reference in New Issue
Block a user