feat(api, i18n): add admin report job functionalities and enhance locale support

- Introduced new API functions for managing admin report jobs, including download and post operations.
- Updated English, Nepali, and Chinese locale files to include new messages related to report job actions and rollback confirmations.
- Enhanced user experience by providing clearer instructions and feedback in the admin interface.
- Refactored related components to integrate new functionalities and improve overall usability.
This commit is contained in:
2026-05-26 11:48:51 +08:00
parent 7fb5ec6dff
commit a76b681828
21 changed files with 1139 additions and 118 deletions

View File

@@ -151,6 +151,8 @@ export function PlayConfigDocScreen() {
const [loadingDetail, setLoadingDetail] = useState(false);
const [saving, setSaving] = useState(false);
const [creatingDraftId, setCreatingDraftId] = useState<string | null>(null);
const [rollbackOpen, setRollbackOpen] = useState(false);
const [rollbackTarget, setRollbackTarget] = useState<ConfigVersionSummary | null>(null);
const [error, setError] = useState<string | null>(null);
const detailRequestSeq = useRef(0);
@@ -400,6 +402,41 @@ export function PlayConfigDocScreen() {
}
}
function requestRollback(row: ConfigVersionSummary) {
setRollbackTarget(row);
setRollbackOpen(true);
}
async function handleRollback() {
if (!rollbackTarget) {
return;
}
setSaving(true);
try {
const d = await postPlayConfigVersion({
reason: `rollback from v${rollbackTarget.version_no}`,
clone_from_version_id: rollbackTarget.id,
});
toast.success(
t("versionActions.rollbackSuccess", {
ns: "config",
fromVersion: rollbackTarget.version_no,
version: d.version_no,
}),
);
await refreshList();
setSelectedId(String(d.id));
setDetail(d);
setDraftRows(d.items.map((it) => ({ ...it })));
setRollbackOpen(false);
setRollbackTarget(null);
} catch (e) {
toast.error(e instanceof LotteryApiBizError ? e.message : t("versionActions.rollbackFailed", { ns: "config" }));
} finally {
setSaving(false);
}
}
return (
<ConfigDocPage
title={t("nav.items.plays", { ns: "config" })}
@@ -413,6 +450,8 @@ export function PlayConfigDocScreen() {
loading={loadingList}
sheetTitle={`${t("nav.items.plays", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
onDeleteVersion={handleDeleteVersion}
onRollbackVersion={requestRollback}
rollbackBusy={saving}
/>
}
actions={
@@ -744,6 +783,29 @@ export function PlayConfigDocScreen() {
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog open={rollbackOpen} onOpenChange={setRollbackOpen}>
<DialogContent showCloseButton className="sm:max-w-md">
<DialogHeader>
<DialogTitle>{t("versionActions.rollbackDialog.title", { ns: "config" })}</DialogTitle>
<DialogDescription>
{t("versionActions.rollbackDialog.description", {
ns: "config",
version: rollbackTarget?.version_no ?? "—",
})}
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button type="button" variant="outline" onClick={() => setRollbackOpen(false)}>
{t("actions.cancel", { ns: "adminUsers" })}
</Button>
<Button type="button" onClick={() => void handleRollback()} disabled={!rollbackTarget || saving}>
{t("versionActions.rollbackDialog.confirm", { ns: "config" })}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<ConfirmDialog />
</ConfigDocPage>
);