feat(admin): 仪表盘重构、代理线路修复与后台体验优化
Some checks failed
lotteryadmin CI / build (push) Has been cancelled
Some checks failed
lotteryadmin CI / build (push) Has been cancelled
- 各角色仪表盘:KPI 可点击跳转、快捷入口、去重冗余区块,代理/站点降级 analytics - 代理线路:创建玩家权限、侧栏搜索、深链 URL、档案保存与删除预检等修复 - 统一密码最短 6 位;代理模块表格/侧栏背景色一致(admin-table-inset) - 报表、钱包、对账、开奖、结算、配置等模块结构与 i18n 同步更新
This commit is contained in:
@@ -18,10 +18,7 @@ import {
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ConfigChip, ConfigChipGroup } from "@/modules/config/config-chip-group";
|
||||
import { ConfigDocPage, ConfigDocToolbar } from "@/modules/config/config-doc-page";
|
||||
import {
|
||||
ConfigVersionToolbarMeta,
|
||||
ConfigVersionToolbarMetaEmphasis,
|
||||
} from "@/modules/config/config-version-toolbar-meta";
|
||||
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -37,7 +34,7 @@ import { ratioToPercentUi } from "@/lib/admin-rate-percent";
|
||||
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
|
||||
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
|
||||
import { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
|
||||
import { ensureAdminPlayTypesLoaded, resolveAdminPlayTypeDisplayName } from "@/lib/admin-play-types";
|
||||
import { useAsyncEffect } from "@/hooks/use-async-effect";
|
||||
import { useTranslationRef } from "@/hooks/use-translation-ref";
|
||||
@@ -56,9 +53,7 @@ import type {
|
||||
} from "@/types/api/admin-config";
|
||||
|
||||
import { OddsConfigDraftBar } from "@/modules/config/doc/odds-config-draft-bar";
|
||||
import { oddsDraftIsDirty } from "@/modules/config/doc/odds-config-dirty";
|
||||
import { OddsConfigPlayNav } from "@/modules/config/doc/odds-config-play-nav";
|
||||
import { OddsConfigSummaryPanel } from "@/modules/config/doc/odds-config-summary-panel";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -120,7 +115,6 @@ export function OddsConfigDocScreen({
|
||||
const tRef = useTranslationRef(["config", "common"]);
|
||||
const profile = useAdminProfile();
|
||||
const canManage = adminHasAnyPermission(profile?.permissions, [PRD_ODDS_MANAGE, PRD_REBATE_MANAGE]);
|
||||
const formatDt = useAdminDateTimeFormatter();
|
||||
const [types, setTypes] = useState<AdminPlayTypeRow[]>([]);
|
||||
const [list, setList] = useState<ConfigVersionSummary[]>([]);
|
||||
const [internalSelectedId, setInternalSelectedId] = useState("");
|
||||
@@ -465,8 +459,6 @@ export function OddsConfigDocScreen({
|
||||
}
|
||||
}
|
||||
|
||||
const activeHead = resolvedList.find((x) => x.status === "active");
|
||||
|
||||
async function handleDeleteVersion(row: ConfigVersionSummary) {
|
||||
try {
|
||||
await deleteOddsVersion(row.id);
|
||||
@@ -509,18 +501,10 @@ export function OddsConfigDocScreen({
|
||||
{ id: "d2", label: "2D" },
|
||||
];
|
||||
|
||||
const activeCatLabel = catTabs.find((tab) => tab.id === catTab)?.label ?? catTab;
|
||||
const activePlayLabel = resolvedPlayCode
|
||||
? resolveAdminPlayTypeDisplayName(resolvedPlayCode, i18n.language, sortedTypes.find((t) => t.play_code === resolvedPlayCode))
|
||||
: "—";
|
||||
|
||||
const isDirty = useMemo(() => {
|
||||
if (!resolvedDetail || !isDraft) {
|
||||
return false;
|
||||
}
|
||||
return oddsDraftIsDirty(resolvedDraftRows, resolvedDetail.items);
|
||||
}, [isDraft, resolvedDetail, resolvedDraftRows]);
|
||||
|
||||
const filtersInner = (
|
||||
<>
|
||||
<ConfigChipGroup label={t("odds.category", { ns: "config" })}>
|
||||
@@ -602,8 +586,7 @@ export function OddsConfigDocScreen({
|
||||
selectedId={selectedId}
|
||||
onSelectedIdChange={setSelectedId}
|
||||
loading={resolvedLoadingList}
|
||||
sheetTitle={`${t("nav.items.odds", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
|
||||
sheetDescription={embedded ? undefined : t("odds.sheetDescription", { ns: "config" })}
|
||||
|
||||
onDeleteVersion={handleDeleteVersion}
|
||||
onRollbackVersion={requestRollback}
|
||||
rollbackBusy={saving}
|
||||
@@ -623,58 +606,9 @@ export function OddsConfigDocScreen({
|
||||
onPublish={() => void requestPublishConfirm()}
|
||||
/>
|
||||
}
|
||||
footer={
|
||||
!resolvedDetail ? null : (
|
||||
<ConfigVersionToolbarMeta emphasis={!isDraft}>
|
||||
<span>
|
||||
{t("odds.activeVersionPrefix", { ns: "config" })}
|
||||
{activeHead ? (
|
||||
<>
|
||||
v{activeHead.version_no}
|
||||
{activeHead.effective_at ? ` · ${formatDt(activeHead.effective_at)}` : ""}
|
||||
</>
|
||||
) : (
|
||||
"—"
|
||||
)}
|
||||
</span>
|
||||
{!isDraft ? (
|
||||
<ConfigVersionToolbarMetaEmphasis>
|
||||
{t("odds.readOnlyHint", { ns: "config" })}
|
||||
</ConfigVersionToolbarMetaEmphasis>
|
||||
) : activeHead ? (
|
||||
<span>{t("versionToolbar.draftEditing", { ns: "config" })}</span>
|
||||
) : null}
|
||||
</ConfigVersionToolbarMeta>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
const rebateField = (
|
||||
<div className="rounded-lg border border-border/60 bg-muted/20 p-4">
|
||||
<div className="grid max-w-xs gap-1.5">
|
||||
<Label htmlFor="odds-rebate-rate">{t("odds.rebateRate", { ns: "config" })}</Label>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
id="odds-rebate-rate"
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="h-9 text-base font-semibold"
|
||||
disabled={saving}
|
||||
value={rebatePercentUi}
|
||||
placeholder={t("odds.placeholders.rebateRate", { ns: "config" })}
|
||||
onChange={(e) => setRebateForPlayPercent(e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue className="h-9 w-full max-w-xs justify-center text-base font-semibold">
|
||||
{rebatePercentUi}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</div>
|
||||
<p className="mt-2 text-xs text-muted-foreground">{t("odds.rebateRateHint", { ns: "config" })}</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
const scopeEditorRows = PRIZE_SCOPE_ORDER.map((scope) => {
|
||||
const row = scopeRows[scope];
|
||||
const hint = mergedLayout ? null : PRIZE_SCOPE_MULTIPLIER_HINT[scope];
|
||||
@@ -726,6 +660,26 @@ export function OddsConfigDocScreen({
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
<TableRow>
|
||||
<TableCell className="font-medium">{t("odds.rebateRate", { ns: "config" })}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="ml-auto h-9 w-full max-w-[9rem] text-base font-semibold"
|
||||
disabled={saving}
|
||||
value={rebatePercentUi}
|
||||
placeholder={t("odds.placeholders.rebateRate", { ns: "config" })}
|
||||
onChange={(e) => setRebateForPlayPercent(e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue className="ml-auto h-9 w-full max-w-[9rem] justify-center text-base font-semibold">
|
||||
{rebatePercentUi}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
@@ -798,19 +752,7 @@ export function OddsConfigDocScreen({
|
||||
/>
|
||||
) : resolvedPlayCode ? (
|
||||
<div className={cn(!mergedLayout && embedded ? "rounded-xl border border-border/60 bg-card p-4" : undefined)}>
|
||||
{mergedLayout ? (
|
||||
<div className="space-y-4">
|
||||
{mergedOddsTable}
|
||||
{rebateField}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{classicOddsGrid}
|
||||
{!embedded ? (
|
||||
<p className="mt-3 text-xs text-muted-foreground">{t("odds.rebateRateHint", { ns: "config" })}</p>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
{mergedLayout ? mergedOddsTable : classicOddsGrid}
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
@@ -889,51 +831,31 @@ export function OddsConfigDocScreen({
|
||||
if (embedded && mergedLayout) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="overflow-hidden rounded-xl border border-border/60 bg-card">{toolbarBlock}</div>
|
||||
|
||||
<div className="grid gap-4 xl:grid-cols-[minmax(0,1fr)_min(100%,260px)] xl:items-start">
|
||||
<div className="overflow-hidden rounded-xl border border-border/60 bg-card">
|
||||
<div className="grid gap-0 lg:grid-cols-[minmax(0,13rem)_minmax(0,1fr)]">
|
||||
<aside className="border-b border-border/50 px-4 py-4 lg:border-r lg:border-b-0">
|
||||
<OddsConfigPlayNav
|
||||
catTab={catTab}
|
||||
onCatTabChange={setCatTab}
|
||||
onPlayCodeChange={setPlayCode}
|
||||
types={sortedTypes}
|
||||
resolvedPlayCode={resolvedPlayCode}
|
||||
/>
|
||||
</aside>
|
||||
|
||||
<div className="min-w-0">
|
||||
<div className="border-b border-border/50 px-4 py-3 sm:px-5">
|
||||
<h3 className="text-base font-semibold">{activePlayLabel}</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t("odds.currentSelection", {
|
||||
ns: "config",
|
||||
category: activeCatLabel,
|
||||
play: activePlayLabel,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<div className="px-4 py-4 sm:px-5">{mainBlock}</div>
|
||||
{isDraft && canManage ? (
|
||||
<OddsConfigDraftBar
|
||||
isDirty={isDirty}
|
||||
saving={saving}
|
||||
loadingDetail={resolvedLoadingDetail}
|
||||
onSave={() => void handleSave()}
|
||||
onPublish={() => void requestPublishConfirm()}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
{toolbarBlock}
|
||||
<div className="grid gap-0 rounded-lg border border-border/60 lg:grid-cols-[minmax(0,13rem)_minmax(0,1fr)]">
|
||||
<aside className="border-b border-border/50 px-4 py-4 lg:border-r lg:border-b-0">
|
||||
<OddsConfigPlayNav
|
||||
catTab={catTab}
|
||||
onCatTabChange={setCatTab}
|
||||
onPlayCodeChange={setPlayCode}
|
||||
types={sortedTypes}
|
||||
resolvedPlayCode={resolvedPlayCode}
|
||||
/>
|
||||
</aside>
|
||||
<div className="min-w-0">
|
||||
<div className="border-b border-border/50 px-4 py-2.5 sm:px-5">
|
||||
<h3 className="text-base font-semibold">{activePlayLabel}</h3>
|
||||
</div>
|
||||
<div className="px-4 py-4 sm:px-5">{mainBlock}</div>
|
||||
{isDraft && canManage ? (
|
||||
<OddsConfigDraftBar
|
||||
saving={saving}
|
||||
loadingDetail={resolvedLoadingDetail}
|
||||
onSave={() => void handleSave()}
|
||||
onPublish={() => void requestPublishConfirm()}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<OddsConfigSummaryPanel
|
||||
compact
|
||||
detail={resolvedDetail}
|
||||
activeHead={activeHead ?? null}
|
||||
/>
|
||||
</div>
|
||||
{dialogs}
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { Rocket, Save } from "lucide-react";
|
||||
import { Save } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type OddsConfigDraftBarProps = {
|
||||
isDirty: boolean;
|
||||
saving: boolean;
|
||||
loadingDetail?: boolean;
|
||||
onSave: () => void;
|
||||
@@ -16,7 +15,6 @@ type OddsConfigDraftBarProps = {
|
||||
};
|
||||
|
||||
export function OddsConfigDraftBar({
|
||||
isDirty,
|
||||
saving,
|
||||
loadingDetail = false,
|
||||
onSave,
|
||||
@@ -29,23 +27,17 @@ export function OddsConfigDraftBar({
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"sticky bottom-0 z-10 flex flex-col gap-3 border-t border-border/60 bg-card/95 px-4 py-3 backdrop-blur sm:flex-row sm:items-center sm:justify-between sm:px-5",
|
||||
"sticky bottom-0 z-10 flex flex-wrap items-center justify-end gap-2 border-t border-border/60 bg-card/95 px-4 py-2.5 backdrop-blur sm:px-5",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{isDirty ? t("odds.draftBar.unsaved") : t("odds.draftBar.saved")}
|
||||
</p>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Button type="button" variant="outline" size="sm" disabled={busy} onClick={onSave}>
|
||||
<Save className="size-3.5" aria-hidden />
|
||||
{t("versionActions.saveDraft")}
|
||||
</Button>
|
||||
<Button type="button" size="sm" disabled={busy} onClick={onPublish}>
|
||||
<Rocket className="size-3.5" aria-hidden />
|
||||
{t("versionActions.publishCurrent")}
|
||||
</Button>
|
||||
</div>
|
||||
<Button type="button" variant="outline" size="sm" disabled={busy} onClick={onSave}>
|
||||
<Save className="size-3.5" aria-hidden />
|
||||
{t("versionActions.saveDraft")}
|
||||
</Button>
|
||||
<Button type="button" size="sm" disabled={busy} onClick={onPublish}>
|
||||
{t("versionActions.publishCurrent")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ export function OddsConfigPlayNav({
|
||||
className={cn(
|
||||
"w-full rounded-md px-2.5 py-2 text-left text-sm transition-colors",
|
||||
active
|
||||
? "bg-primary font-medium text-primary-foreground shadow-sm"
|
||||
: "text-foreground hover:bg-muted/80",
|
||||
? "bg-muted font-medium text-foreground"
|
||||
: "text-foreground hover:bg-muted/60",
|
||||
)}
|
||||
onClick={() => onPlayCodeChange(type.play_code)}
|
||||
aria-current={active ? "true" : undefined}
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { FileText, Info } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { ConfigStatusBadge } from "@/modules/config/config-status-badge";
|
||||
import { rateToPercentUi } from "@/modules/config/doc/odds-rebate-rates";
|
||||
import { prizeScopeLabel, type PrizeScopeCode } from "@/modules/config/doc/prize-scopes";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { ConfigVersionSummary, OddsItemRow, OddsVersionDetail } from "@/types/api/admin-config";
|
||||
|
||||
type OddsConfigSummaryPanelProps = {
|
||||
catTabLabel?: string;
|
||||
playLabel?: string;
|
||||
detail: OddsVersionDetail | null;
|
||||
scopeRows?: Partial<Record<PrizeScopeCode, OddsItemRow>>;
|
||||
playRebatePercent?: string;
|
||||
activeHead?: ConfigVersionSummary | null;
|
||||
/** 合并页:仅展示版本与操作提示,不重复主编辑区数值 */
|
||||
compact?: boolean;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function OddsConfigSummaryPanel({
|
||||
catTabLabel,
|
||||
playLabel,
|
||||
detail,
|
||||
scopeRows,
|
||||
playRebatePercent,
|
||||
activeHead = null,
|
||||
compact = false,
|
||||
className,
|
||||
}: OddsConfigSummaryPanelProps) {
|
||||
const { t } = useTranslation("config");
|
||||
const formatDt = useAdminDateTimeFormatter();
|
||||
|
||||
const isDraft = detail?.status === "draft";
|
||||
const isActive = detail?.status === "active";
|
||||
const versionLabel = detail ? `v${detail.version_no}` : "—";
|
||||
|
||||
return (
|
||||
<aside
|
||||
className={cn(
|
||||
"xl:sticky xl:top-24 xl:max-h-[calc(100vh-7rem)] xl:overflow-y-auto",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div className="overflow-hidden rounded-xl border border-border/60 bg-card">
|
||||
<div className="flex items-center gap-2 border-b border-border/50 px-4 py-3.5">
|
||||
<FileText className="size-4 text-primary" aria-hidden />
|
||||
<h3 className="text-base font-semibold">
|
||||
{compact ? t("odds.summary.contextTitle") : t("odds.summary.title")}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 px-4 py-4">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-sm text-muted-foreground">{t("odds.summary.version")}</span>
|
||||
<span className="font-mono text-sm font-medium">{versionLabel}</span>
|
||||
{detail ? <ConfigStatusBadge status={detail.status} /> : null}
|
||||
</div>
|
||||
|
||||
{activeHead ? (
|
||||
<div className="space-y-1 text-sm">
|
||||
<p className="text-muted-foreground">{t("odds.summary.activeVersion")}</p>
|
||||
<p className="font-mono font-medium">
|
||||
v{activeHead.version_no}
|
||||
{activeHead.effective_at ? ` · ${formatDt(activeHead.effective_at)}` : ""}
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!compact && catTabLabel && playLabel ? (
|
||||
<dl className="space-y-2 text-sm">
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto] gap-3">
|
||||
<dt className="text-muted-foreground">{t("odds.category")}</dt>
|
||||
<dd>{catTabLabel}</dd>
|
||||
</div>
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto] gap-3">
|
||||
<dt className="text-muted-foreground">{t("odds.playType")}</dt>
|
||||
<dd>{playLabel}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
) : null}
|
||||
|
||||
{!compact && scopeRows ? (
|
||||
<dl className="space-y-2.5">
|
||||
{(["first", "second", "third", "starter", "consolation"] as PrizeScopeCode[]).map((scope) => {
|
||||
const row = scopeRows[scope];
|
||||
return (
|
||||
<div key={scope} className="grid grid-cols-[minmax(0,1fr)_auto] gap-3 text-sm">
|
||||
<dt className="text-muted-foreground">{prizeScopeLabel(scope, t)}</dt>
|
||||
<dd className="text-right text-lg font-semibold text-foreground">
|
||||
{row ? oddsMultiplierLabel(row.odds_value) : "—"}
|
||||
</dd>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{playRebatePercent ? (
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto] gap-3 text-sm">
|
||||
<dt className="text-muted-foreground">{t("odds.rebateRate")}</dt>
|
||||
<dd className="text-right text-lg font-semibold text-foreground">{playRebatePercent}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
</dl>
|
||||
) : null}
|
||||
|
||||
{detail && !isDraft ? (
|
||||
<Alert className="border-sky-500/30 bg-sky-500/5 text-foreground">
|
||||
<Info className="size-4 text-sky-600 dark:text-sky-400" aria-hidden />
|
||||
<AlertDescription className="text-xs leading-relaxed">
|
||||
{t("odds.summary.readOnlyHint")}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
) : isDraft ? (
|
||||
<Alert className="border-primary/25 bg-primary/5 text-foreground">
|
||||
<AlertDescription className="text-xs leading-relaxed">
|
||||
{t("odds.summary.draftHint")}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
) : isActive ? (
|
||||
<Alert className="border-emerald-500/30 bg-emerald-500/5 text-foreground">
|
||||
<AlertDescription className="text-xs leading-relaxed">
|
||||
{t("odds.summary.activeHint")}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
function oddsMultiplierLabel(oddsValue: number): string {
|
||||
return (oddsValue / 10000).toFixed(4);
|
||||
}
|
||||
|
||||
/** 当前玩法在摘要中展示的回水百分比(与赔率区输入一致)。 */
|
||||
export function playRebatePercentFromScopes(
|
||||
scopeRows: Partial<Record<PrizeScopeCode, OddsItemRow>>,
|
||||
order: readonly PrizeScopeCode[],
|
||||
): string {
|
||||
const first = order.map((s) => scopeRows[s]).find(Boolean);
|
||||
if (!first) {
|
||||
return "0";
|
||||
}
|
||||
return rateToPercentUi(String(first.rebate_rate));
|
||||
}
|
||||
@@ -17,11 +17,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { ConfigChipGroup } from "@/modules/config/config-chip-group";
|
||||
import { ConfigDocPage, ConfigDocToolbar } from "@/modules/config/config-doc-page";
|
||||
import {
|
||||
ConfigVersionToolbarMeta,
|
||||
ConfigVersionToolbarMetaEmphasis,
|
||||
} from "@/modules/config/config-version-toolbar-meta";
|
||||
import { ConfigSection } from "@/modules/config/config-section";
|
||||
|
||||
import { ConfirmableSwitch } from "@/components/admin/confirmable-switch";
|
||||
import {
|
||||
Dialog,
|
||||
@@ -52,7 +48,7 @@ import { AdminLoadingState } from "@/components/admin/admin-loading-state";
|
||||
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
|
||||
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
|
||||
import { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
|
||||
import { useAsyncEffect } from "@/hooks/use-async-effect";
|
||||
import { useConfirmAction } from "@/hooks/use-confirm-action";
|
||||
import { useTranslationRef } from "@/hooks/use-translation-ref";
|
||||
@@ -152,7 +148,6 @@ export function PlayConfigDocScreen() {
|
||||
const { request: requestConfirm, ConfirmDialog, busy: confirmBusy } = useConfirmAction();
|
||||
const profile = useAdminProfile();
|
||||
const canManage = adminHasAnyPermission(profile?.permissions, [PRD_PLAY_SWITCH_MANAGE]);
|
||||
const formatDt = useAdminDateTimeFormatter();
|
||||
const [list, setList] = useState<ConfigVersionSummary[]>([]);
|
||||
const [selectedId, setSelectedId] = useState("");
|
||||
const [detail, setDetail] = useState<PlayConfigVersionDetail | null>(null);
|
||||
@@ -429,8 +424,6 @@ export function PlayConfigDocScreen() {
|
||||
return <span>{name || row.play_code}</span>;
|
||||
}
|
||||
|
||||
const activeHead = list.find((x) => x.status === "active");
|
||||
|
||||
async function handleDeleteVersion(row: ConfigVersionSummary) {
|
||||
try {
|
||||
await deletePlayConfigVersion(row.id);
|
||||
@@ -488,7 +481,7 @@ export function PlayConfigDocScreen() {
|
||||
selectedId={selectedId}
|
||||
onSelectedIdChange={setSelectedId}
|
||||
loading={loadingList}
|
||||
sheetTitle={`${t("nav.items.plays", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
|
||||
|
||||
onDeleteVersion={handleDeleteVersion}
|
||||
onRollbackVersion={requestRollback}
|
||||
rollbackBusy={saving}
|
||||
@@ -515,100 +508,63 @@ export function PlayConfigDocScreen() {
|
||||
}
|
||||
/>
|
||||
}
|
||||
footer={
|
||||
detail ? (
|
||||
<ConfigVersionToolbarMeta emphasis={!isDraft}>
|
||||
{activeHead ? (
|
||||
<span>
|
||||
{t("play.activeVersion", { ns: "config", version: activeHead.version_no })}
|
||||
{activeHead.effective_at ? ` · ${formatDt(activeHead.effective_at)}` : ""}
|
||||
</span>
|
||||
) : null}
|
||||
{!isDraft ? (
|
||||
<ConfigVersionToolbarMetaEmphasis>
|
||||
{t("play.readOnlyHint", { ns: "config" })}
|
||||
</ConfigVersionToolbarMetaEmphasis>
|
||||
) : activeHead ? (
|
||||
<span>{t("versionToolbar.draftEditing", { ns: "config" })}</span>
|
||||
) : null}
|
||||
</ConfigVersionToolbarMeta>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{detail ? (
|
||||
<ConfigSection
|
||||
title={t("play.filters.sectionTitle", { ns: "config" })}
|
||||
description={isDraft ? t("play.filters.sectionDescription", { ns: "config" }) : undefined}
|
||||
>
|
||||
{!isDraft ? (
|
||||
<div className="rounded-md border border-amber-200 bg-amber-50/70 px-3 py-2 text-xs text-amber-950">
|
||||
{t("play.readOnlyDraftHint", { ns: "config" })}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex flex-col gap-3 lg:flex-row lg:items-end">
|
||||
<div className="flex flex-1 flex-col gap-3 md:flex-row md:flex-wrap md:items-end">
|
||||
<div className="flex min-w-0 flex-col gap-1.5 md:w-[320px]">
|
||||
<span className="text-sm font-medium">{t("play.filters.keyword", { ns: "config" })}</span>
|
||||
<Input
|
||||
value={keyword}
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
placeholder={t("play.filters.keywordPlaceholder", { ns: "config" })}
|
||||
className="h-8"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1.5 md:w-[140px]">
|
||||
<span className="text-sm font-medium">{t("play.filters.category", { ns: "config" })}</span>
|
||||
<Select value={categoryFilter} onValueChange={(value) => setCategoryFilter(value ?? "all")}>
|
||||
<SelectTrigger className="h-8">
|
||||
<SelectValue>
|
||||
{categoryFilter === "all"
|
||||
? t("play.filters.allCategories", { ns: "config" })
|
||||
: categoryLabel(categoryFilter)}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">{t("play.filters.allCategories", { ns: "config" })}</SelectItem>
|
||||
{categoryOptions.map((category) => (
|
||||
<SelectItem key={category} value={category}>
|
||||
{categoryLabel(category)}
|
||||
</SelectItem>
|
||||
))}
|
||||
<SelectItem value="uncategorized">
|
||||
{t("play.filters.uncategorized", { ns: "config" })}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1.5 md:w-[140px]">
|
||||
<span className="text-sm font-medium">{t("play.filters.status", { ns: "config" })}</span>
|
||||
<Select
|
||||
value={statusFilter}
|
||||
onValueChange={(value) => setStatusFilter(value as "all" | "enabled" | "disabled")}
|
||||
>
|
||||
<SelectTrigger className="h-8">
|
||||
<SelectValue>
|
||||
{statusFilter === "all"
|
||||
? t("play.filters.allStatuses", { ns: "config" })
|
||||
: statusFilter === "enabled"
|
||||
? t("play.states.enabled", { ns: "config" })
|
||||
: t("play.states.disabled", { ns: "config" })}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">{t("play.filters.allStatuses", { ns: "config" })}</SelectItem>
|
||||
<SelectItem value="enabled">{t("play.states.enabled", { ns: "config" })}</SelectItem>
|
||||
<SelectItem value="disabled">{t("play.states.disabled", { ns: "config" })}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-end justify-start lg:flex-none">
|
||||
<div className="space-y-3">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Input
|
||||
value={keyword}
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
placeholder={t("play.filters.keywordPlaceholder", { ns: "config" })}
|
||||
className="h-8 w-full min-w-[12rem] max-w-xs"
|
||||
/>
|
||||
<Select value={categoryFilter} onValueChange={(value) => setCategoryFilter(value ?? "all")}>
|
||||
<SelectTrigger className="h-8 w-[8.5rem]">
|
||||
<SelectValue>
|
||||
{categoryFilter === "all"
|
||||
? t("play.filters.allCategories", { ns: "config" })
|
||||
: categoryLabel(categoryFilter)}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">{t("play.filters.allCategories", { ns: "config" })}</SelectItem>
|
||||
{categoryOptions.map((category) => (
|
||||
<SelectItem key={category} value={category}>
|
||||
{categoryLabel(category)}
|
||||
</SelectItem>
|
||||
))}
|
||||
<SelectItem value="uncategorized">
|
||||
{t("play.filters.uncategorized", { ns: "config" })}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select
|
||||
value={statusFilter}
|
||||
onValueChange={(value) => setStatusFilter(value as "all" | "enabled" | "disabled")}
|
||||
>
|
||||
<SelectTrigger className="h-8 w-[6.5rem]">
|
||||
<SelectValue>
|
||||
{statusFilter === "all"
|
||||
? t("play.filters.allStatuses", { ns: "config" })
|
||||
: statusFilter === "enabled"
|
||||
? t("play.states.enabled", { ns: "config" })
|
||||
: t("play.states.disabled", { ns: "config" })}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">{t("play.filters.allStatuses", { ns: "config" })}</SelectItem>
|
||||
<SelectItem value="enabled">{t("play.states.enabled", { ns: "config" })}</SelectItem>
|
||||
<SelectItem value="disabled">{t("play.states.disabled", { ns: "config" })}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{(keyword || categoryFilter !== "all" || statusFilter !== "all") ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
variant="ghost"
|
||||
className="h-8 px-2"
|
||||
onClick={() => {
|
||||
setKeyword("");
|
||||
setCategoryFilter("all");
|
||||
@@ -617,76 +573,52 @@ export function PlayConfigDocScreen() {
|
||||
>
|
||||
{t("play.filters.reset", { ns: "config" })}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{isDraft ? (
|
||||
<div className="space-y-2 border-t border-border/60 pt-3">
|
||||
<div className="text-xs font-medium text-muted-foreground">
|
||||
{t("play.batchSwitchesTitle", { ns: "config" })}
|
||||
</div>
|
||||
<ConfigChipGroup>
|
||||
{batchSwitchStates.map((group) => {
|
||||
const groupOn = group.allEnabled;
|
||||
const isPartial =
|
||||
group.total > 0 && group.enabledCount > 0 && group.enabledCount < group.total;
|
||||
return (
|
||||
<div
|
||||
key={group.key}
|
||||
className="flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-card px-3 py-2"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium text-foreground">{group.label}</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{group.total > 0
|
||||
? isPartial
|
||||
? t("play.batchPartialEnabled", {
|
||||
ns: "config",
|
||||
enabledCount: group.enabledCount,
|
||||
total: group.total,
|
||||
})
|
||||
: t("play.batchEnabledCount", {
|
||||
ns: "config",
|
||||
enabledCount: group.enabledCount,
|
||||
total: group.total,
|
||||
})
|
||||
: t("play.noPlayTypes", { ns: "config" })}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center justify-center">
|
||||
<Checkbox
|
||||
checked={groupOn}
|
||||
indeterminate={isPartial}
|
||||
disabled={saving || group.total === 0 || confirmBusy}
|
||||
aria-label={t("play.aria.batchGroupSwitch", {
|
||||
<ConfigChipGroup label={t("play.batchSwitchesTitle", { ns: "config" })}>
|
||||
{batchSwitchStates.map((group) => {
|
||||
const groupOn = group.allEnabled;
|
||||
const isPartial =
|
||||
group.total > 0 && group.enabledCount > 0 && group.enabledCount < group.total;
|
||||
return (
|
||||
<label
|
||||
key={group.key}
|
||||
className="inline-flex cursor-pointer items-center gap-2 rounded-md border border-border/60 px-2.5 py-1.5 text-sm"
|
||||
>
|
||||
<span>{group.label}</span>
|
||||
<Checkbox
|
||||
checked={groupOn}
|
||||
indeterminate={isPartial}
|
||||
disabled={saving || group.total === 0 || confirmBusy}
|
||||
aria-label={t("play.aria.batchGroupSwitch", {
|
||||
ns: "config",
|
||||
group: group.label,
|
||||
})}
|
||||
onCheckedChange={(checked) => {
|
||||
const enable = checked === true;
|
||||
const action = enable
|
||||
? t("play.batchSwitchEnable", { ns: "config" })
|
||||
: t("play.batchSwitchDisable", { ns: "config" });
|
||||
requestConfirm({
|
||||
title: t("play.batchSwitchConfirmTitle", { ns: "config", action }),
|
||||
description: t("play.batchSwitchConfirmDescription", {
|
||||
ns: "config",
|
||||
action,
|
||||
group: group.label,
|
||||
})}
|
||||
onCheckedChange={(checked) => {
|
||||
const enable = checked === true;
|
||||
const action = enable
|
||||
? t("play.batchSwitchEnable", { ns: "config" })
|
||||
: t("play.batchSwitchDisable", { ns: "config" });
|
||||
requestConfirm({
|
||||
title: t("play.batchSwitchConfirmTitle", { ns: "config", action }),
|
||||
description: t("play.batchSwitchConfirmDescription", {
|
||||
ns: "config",
|
||||
action,
|
||||
group: group.label,
|
||||
count: group.total,
|
||||
}),
|
||||
confirmVariant: enable ? "default" : "destructive",
|
||||
onConfirm: () => applyBatchSwitch(group, enable),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</ConfigChipGroup>
|
||||
</div>
|
||||
count: group.total,
|
||||
}),
|
||||
confirmVariant: enable ? "default" : "destructive",
|
||||
onConfirm: () => applyBatchSwitch(group, enable),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
</ConfigChipGroup>
|
||||
) : null}
|
||||
</ConfigSection>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{error ? <p className="text-sm text-destructive">{error}</p> : null}
|
||||
|
||||
@@ -481,8 +481,7 @@ export function RebateConfigDocScreen({
|
||||
selectedId={selectedId}
|
||||
onSelectedIdChange={setSelectedId}
|
||||
loading={resolvedLoading}
|
||||
sheetTitle={`${t("nav.items.rebate", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
|
||||
sheetDescription={t("rebate.sheetDescription", { ns: "config" })}
|
||||
|
||||
onDeleteVersion={handleDeleteVersion}
|
||||
onRollbackVersion={requestRollback}
|
||||
rollbackBusy={saving}
|
||||
|
||||
@@ -15,14 +15,11 @@ import {
|
||||
putRiskCapItems,
|
||||
} from "@/api/admin-config";
|
||||
import { getAdminDraws } from "@/api/admin-draws";
|
||||
import { AdminPageCard } from "@/components/admin/admin-page-card";
|
||||
import { AdminRowActionsMenu } from "@/components/admin/admin-row-actions-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ConfigDocPage, ConfigDocToolbar } from "@/modules/config/config-doc-page";
|
||||
import {
|
||||
ConfigVersionToolbarMeta,
|
||||
ConfigVersionToolbarMetaEmphasis,
|
||||
} from "@/modules/config/config-version-toolbar-meta";
|
||||
import { ConfigSection } from "@/modules/config/config-section";
|
||||
import { ConfigVersionToolbarMeta } from "@/modules/config/config-version-toolbar-meta";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -35,7 +32,6 @@ import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { AdminLoadingState } from "@/components/admin/admin-loading-state";
|
||||
import { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
|
||||
import { RiskCapRuntimePanel } from "@/modules/config/risk-cap-runtime-panel";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -44,13 +40,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
|
||||
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
|
||||
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
|
||||
@@ -63,9 +53,7 @@ import { PRD_RISK_CAP_MANAGE } from "@/lib/admin-prd";
|
||||
import { useAdminProfile } from "@/stores/admin-session";
|
||||
import { LotteryApiBizError } from "@/types/api/errors";
|
||||
import { pickDefaultConfigVersionId } from "@/lib/config-version-auto-pick";
|
||||
import type {
|
||||
AdminDrawListItem,
|
||||
} from "@/types/api/admin-draws";
|
||||
import type { AdminDrawListItem } from "@/types/api/admin-draws";
|
||||
import type {
|
||||
ConfigVersionSummary,
|
||||
RiskCapItemRow,
|
||||
@@ -102,6 +90,14 @@ function formatMinorToEditableMajor(minor: number, currencyCode: string): string
|
||||
return formatAdminMinorDecimal(minor, currencyCode).replace(/,/g, "");
|
||||
}
|
||||
|
||||
function syncDefaultCapInput(rows: DraftRiskRow[], currencyCode: string): string {
|
||||
const defaultRow = rows.find(isDefaultRiskRow);
|
||||
if (!defaultRow) {
|
||||
return "";
|
||||
}
|
||||
return formatMinorToEditableMajor(defaultRow.cap_amount, currencyCode);
|
||||
}
|
||||
|
||||
export function RiskCapDocScreen() {
|
||||
const { t } = useTranslation(["config", "adminUsers", "common"]);
|
||||
const tRef = useTranslationRef(["config", "common"]);
|
||||
@@ -113,16 +109,15 @@ export function RiskCapDocScreen() {
|
||||
const [selectedId, setSelectedId] = useState("");
|
||||
const [detail, setDetail] = useState<RiskCapVersionDetail | null>(null);
|
||||
const [draftRows, setDraftRows] = useState<DraftRiskRow[]>([]);
|
||||
const [defaultCapInput, setDefaultCapInput] = useState("");
|
||||
const [loadingList, setLoadingList] = useState(true);
|
||||
const [loadingDetail, setLoadingDetail] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [drawOptions, setDrawOptions] = useState<AdminDrawListItem[]>([]);
|
||||
|
||||
const [defaultCapStr, setDefaultCapStr] = useState("");
|
||||
const [syncOpen, setSyncOpen] = useState(false);
|
||||
const [rollbackOpen, setRollbackOpen] = useState(false);
|
||||
const [rollbackTarget, setRollbackTarget] = useState<ConfigVersionSummary | null>(null);
|
||||
const [showNumberCaps, setShowNumberCaps] = useState(false);
|
||||
|
||||
const amountCurrencyCode = "NPR";
|
||||
|
||||
@@ -159,40 +154,49 @@ export function RiskCapDocScreen() {
|
||||
void loadDrawOptions();
|
||||
}, []);
|
||||
|
||||
function syncDefaultCapFromRows(rows: DraftRiskRow[]) {
|
||||
const defaultRow = rows.find(isDefaultRiskRow);
|
||||
if (!defaultRow) {
|
||||
setDefaultCapStr("");
|
||||
return;
|
||||
}
|
||||
setDefaultCapStr(formatMinorToEditableMajor(defaultRow.cap_amount, amountCurrencyCode));
|
||||
}
|
||||
const applyDefaultCapInput = useCallback(
|
||||
(value: string) =>
|
||||
(prev: DraftRiskRow[]): DraftRiskRow[] => {
|
||||
const n = parseAdminMajorToMinor(value, amountCurrencyCode);
|
||||
const rest = prev.filter((row) => !isDefaultRiskRow(row));
|
||||
if (n != null && n > 0) {
|
||||
return [defaultRiskRowFromAmount(n), ...rest];
|
||||
}
|
||||
return rest;
|
||||
},
|
||||
[amountCurrencyCode],
|
||||
);
|
||||
|
||||
const loadDetail = useCallback(async (id: number) => {
|
||||
setLoadingDetail(true);
|
||||
try {
|
||||
const d = await getRiskCapVersion(id);
|
||||
setDetail(d);
|
||||
const mapped = d.items.map((it) => ({
|
||||
clientKey: `srv-${it.id}`,
|
||||
draw_id: it.draw_id,
|
||||
normalized_number: it.normalized_number,
|
||||
cap_amount: it.cap_amount,
|
||||
cap_type: it.cap_type,
|
||||
}));
|
||||
setDraftRows(mapped);
|
||||
syncDefaultCapFromRows(mapped);
|
||||
} catch (e) {
|
||||
toast.error(
|
||||
e instanceof LotteryApiBizError ? e.message : tRef.current("errors.loadFailed", { ns: "common" }),
|
||||
);
|
||||
setDetail(null);
|
||||
setDraftRows([]);
|
||||
syncDefaultCapFromRows([]);
|
||||
} finally {
|
||||
setLoadingDetail(false);
|
||||
}
|
||||
}, []);
|
||||
const loadDetail = useCallback(
|
||||
async (id: number) => {
|
||||
setLoadingDetail(true);
|
||||
try {
|
||||
const d = await getRiskCapVersion(id);
|
||||
setDetail(d);
|
||||
const mapped = d.items.map((it) => ({
|
||||
clientKey: `srv-${it.id}`,
|
||||
draw_id: it.draw_id,
|
||||
normalized_number: it.normalized_number,
|
||||
cap_amount: it.cap_amount,
|
||||
cap_type: it.cap_type,
|
||||
}));
|
||||
setDraftRows(mapped);
|
||||
setDefaultCapInput(syncDefaultCapInput(mapped, amountCurrencyCode));
|
||||
setShowNumberCaps(mapped.some((row) => !isDefaultRiskRow(row)));
|
||||
} catch (e) {
|
||||
toast.error(
|
||||
e instanceof LotteryApiBizError ? e.message : tRef.current("errors.loadFailed", { ns: "common" }),
|
||||
);
|
||||
setDetail(null);
|
||||
setDraftRows([]);
|
||||
setDefaultCapInput("");
|
||||
setShowNumberCaps(false);
|
||||
} finally {
|
||||
setLoadingDetail(false);
|
||||
}
|
||||
},
|
||||
[amountCurrencyCode, tRef],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (list.length === 0) {
|
||||
@@ -201,7 +205,7 @@ export function RiskCapDocScreen() {
|
||||
setSelectedId("");
|
||||
setDetail(null);
|
||||
setDraftRows([]);
|
||||
syncDefaultCapFromRows([]);
|
||||
setDefaultCapInput("");
|
||||
});
|
||||
}
|
||||
return;
|
||||
@@ -251,11 +255,13 @@ export function RiskCapDocScreen() {
|
||||
if (!detail || !canEditDraft) {
|
||||
return;
|
||||
}
|
||||
if (draftRows.length === 0) {
|
||||
const rowsToSave = applyDefaultCapInput(defaultCapInput)(draftRows);
|
||||
setDraftRows(rowsToSave);
|
||||
if (rowsToSave.length === 0) {
|
||||
toast.error(t("riskCap.validation.requireAtLeastOne", { ns: "config" }));
|
||||
return;
|
||||
}
|
||||
for (const r of draftRows) {
|
||||
for (const r of rowsToSave) {
|
||||
if (isDefaultRiskRow(r)) {
|
||||
if (r.cap_amount <= 0) {
|
||||
toast.error(t("riskCap.validation.defaultGreaterThanZero", { ns: "config" }));
|
||||
@@ -278,7 +284,7 @@ export function RiskCapDocScreen() {
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const payload = draftRows.map((r) => ({
|
||||
const payload = rowsToSave.map((r) => ({
|
||||
draw_id: r.draw_id && r.draw_id > 0 ? r.draw_id : null,
|
||||
normalized_number: r.normalized_number,
|
||||
cap_amount: r.cap_amount,
|
||||
@@ -294,7 +300,7 @@ export function RiskCapDocScreen() {
|
||||
cap_type: it.cap_type,
|
||||
}));
|
||||
setDraftRows(saved);
|
||||
syncDefaultCapFromRows(saved);
|
||||
setDefaultCapInput(syncDefaultCapInput(saved, amountCurrencyCode));
|
||||
toast.success(t("versionActions.saveDraft", { ns: "config" }));
|
||||
void refreshList();
|
||||
} catch (e) {
|
||||
@@ -320,7 +326,7 @@ export function RiskCapDocScreen() {
|
||||
cap_type: it.cap_type,
|
||||
}));
|
||||
setDraftRows(pub);
|
||||
syncDefaultCapFromRows(pub);
|
||||
setDefaultCapInput(syncDefaultCapInput(pub, amountCurrencyCode));
|
||||
toast.success(t("versionActions.publishCurrent", { ns: "config" }));
|
||||
void refreshList();
|
||||
setSelectedId(String(d.id));
|
||||
@@ -351,7 +357,7 @@ export function RiskCapDocScreen() {
|
||||
cap_type: it.cap_type,
|
||||
}));
|
||||
setDraftRows(nd);
|
||||
syncDefaultCapFromRows(nd);
|
||||
setDefaultCapInput(syncDefaultCapInput(nd, amountCurrencyCode));
|
||||
} catch (e) {
|
||||
toast.error(e instanceof LotteryApiBizError ? e.message : t("riskCap.createDraftFailed", { ns: "config" }));
|
||||
} finally {
|
||||
@@ -359,37 +365,25 @@ export function RiskCapDocScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
function applyDefaultCap() {
|
||||
const n = parseAdminMajorToMinor(defaultCapStr, amountCurrencyCode);
|
||||
if (n == null || !Number.isFinite(n) || n <= 0) {
|
||||
toast.error(t("riskCap.validation.enterValidCapAmount", { ns: "config" }));
|
||||
return;
|
||||
}
|
||||
setDraftRows((prev) => {
|
||||
const next = prev.filter((row) => !isDefaultRiskRow(row));
|
||||
return [defaultRiskRowFromAmount(n), ...next];
|
||||
});
|
||||
setSyncOpen(false);
|
||||
toast.message(t("riskCap.savedLocalDraft", { ns: "config" }));
|
||||
}
|
||||
|
||||
const specialRows = useMemo(
|
||||
() => draftRows.map((row, index) => ({ row, index })).filter(({ row }) => !isDefaultRiskRow(row)),
|
||||
() =>
|
||||
draftRows
|
||||
.map((row, index) => ({ row, index }))
|
||||
.filter(({ row }) => !isDefaultRiskRow(row) && row.draw_id == null),
|
||||
[draftRows],
|
||||
);
|
||||
const globalRows = useMemo(
|
||||
() => specialRows.filter(({ row }) => row.draw_id == null),
|
||||
[specialRows],
|
||||
);
|
||||
const drawRows = useMemo(
|
||||
() => specialRows.filter(({ row }) => row.draw_id != null),
|
||||
[specialRows],
|
||||
|
||||
const drawBoundRows = useMemo(
|
||||
() => draftRows.filter((row) => !isDefaultRiskRow(row) && row.draw_id != null),
|
||||
[draftRows],
|
||||
);
|
||||
|
||||
function drawLabel(drawId: number): string {
|
||||
return drawOptions.find((draw) => draw.id === drawId)?.draw_no ?? String(drawId);
|
||||
}
|
||||
|
||||
const defaultCapDisplay = detail
|
||||
? formatAdminMinorDecimal(
|
||||
draftRows.find(isDefaultRiskRow)?.cap_amount ?? 0,
|
||||
amountCurrencyCode,
|
||||
)
|
||||
? formatAdminMinorDecimal(draftRows.find(isDefaultRiskRow)?.cap_amount ?? 0, amountCurrencyCode)
|
||||
: formatAdminMinorDecimal(0, amountCurrencyCode);
|
||||
|
||||
async function handleDeleteVersion(row: ConfigVersionSummary) {
|
||||
@@ -436,7 +430,7 @@ export function RiskCapDocScreen() {
|
||||
cap_type: it.cap_type,
|
||||
}));
|
||||
setDraftRows(mapped);
|
||||
syncDefaultCapFromRows(mapped);
|
||||
setDefaultCapInput(syncDefaultCapInput(mapped, amountCurrencyCode));
|
||||
setRollbackOpen(false);
|
||||
setRollbackTarget(null);
|
||||
} catch (e) {
|
||||
@@ -458,7 +452,7 @@ export function RiskCapDocScreen() {
|
||||
selectedId={selectedId}
|
||||
onSelectedIdChange={setSelectedId}
|
||||
loading={loadingList}
|
||||
sheetTitle={`${t("nav.items.risk-cap", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
|
||||
|
||||
onDeleteVersion={handleDeleteVersion}
|
||||
onRollbackVersion={requestRollback}
|
||||
rollbackBusy={saving}
|
||||
@@ -486,276 +480,191 @@ export function RiskCapDocScreen() {
|
||||
/>
|
||||
}
|
||||
footer={
|
||||
detail ? (
|
||||
<ConfigVersionToolbarMeta emphasis={!isDraft}>
|
||||
detail?.effective_at ? (
|
||||
<ConfigVersionToolbarMeta>
|
||||
<span>
|
||||
{t("riskCap.effectiveAt", {
|
||||
ns: "config",
|
||||
value: detail.effective_at ? formatDt(detail.effective_at) : "—",
|
||||
value: formatDt(detail.effective_at),
|
||||
})}
|
||||
</span>
|
||||
{!isDraft ? (
|
||||
<ConfigVersionToolbarMetaEmphasis>
|
||||
{t("riskCap.readOnlyHint", { ns: "config" })}
|
||||
</ConfigVersionToolbarMetaEmphasis>
|
||||
) : (
|
||||
<span>{t("versionToolbar.draftEditing", { ns: "config" })}</span>
|
||||
)}
|
||||
</ConfigVersionToolbarMeta>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
}
|
||||
contentClassName="space-y-8"
|
||||
contentClassName="space-y-6"
|
||||
>
|
||||
{error ? <p className="text-sm text-destructive">{error}</p> : null}
|
||||
|
||||
<div className="grid gap-3 md:grid-cols-3">
|
||||
{[
|
||||
{
|
||||
key: "default",
|
||||
label: t("riskCap.summary.defaultCap", { ns: "config" }),
|
||||
value: defaultCapDisplay,
|
||||
hint: t("riskCap.summary.defaultHint", { ns: "config" }),
|
||||
},
|
||||
{
|
||||
key: "global",
|
||||
label: t("riskCap.summary.globalCaps", { ns: "config" }),
|
||||
value: t("riskCap.groups.count", { ns: "config", count: globalRows.length }),
|
||||
hint: t("riskCap.summary.globalHint", { ns: "config" }),
|
||||
},
|
||||
{
|
||||
key: "draw",
|
||||
label: t("riskCap.summary.drawCaps", { ns: "config" }),
|
||||
value: t("riskCap.groups.count", { ns: "config", count: drawRows.length }),
|
||||
hint: t("riskCap.summary.drawHint", { ns: "config" }),
|
||||
},
|
||||
].map((card) => (
|
||||
<div key={card.key} className="rounded-xl border border-border/60 bg-background p-4 shadow-sm">
|
||||
<p className="text-xs text-muted-foreground">{card.label}</p>
|
||||
<p className="mt-1 text-2xl font-semibold tabular-nums text-foreground">{card.value}</p>
|
||||
<p className="mt-2 text-xs leading-5 text-muted-foreground">{card.hint}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<ConfigSection title={t("riskCap.defaultCap.title", { ns: "config" })}>
|
||||
<div className="flex flex-wrap items-end gap-2">
|
||||
<div className="grid gap-1">
|
||||
<Label htmlFor="default-cap">{t("riskCap.defaultCap.fieldLabel", { ns: "config" })}</Label>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
id="default-cap"
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="h-9 w-[220px] text-base font-semibold"
|
||||
disabled={saving}
|
||||
value={defaultCapStr}
|
||||
placeholder={t("riskCap.placeholders.defaultCap", { ns: "config" })}
|
||||
onChange={(e) => setDefaultCapStr(e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue className="h-9 w-[220px] text-base font-semibold">
|
||||
{defaultCapDisplay}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</div>
|
||||
{canEditDraft ? (
|
||||
<Button type="button" variant="secondary" disabled={saving} onClick={() => setSyncOpen(true)}>
|
||||
{t("riskCap.actions.update", { ns: "config" })}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</ConfigSection>
|
||||
|
||||
<ConfigSection
|
||||
title={t("riskCap.specialCaps.title", { ns: "config" })}
|
||||
description={t("riskCap.specialCaps.description", { ns: "config" })}
|
||||
actions={
|
||||
canEditDraft ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
<AdminPageCard title={t("riskCap.defaultCap.title", { ns: "config" })}>
|
||||
<div className="max-w-xs space-y-2">
|
||||
<Label htmlFor="default-cap">{t("riskCap.defaultCap.fieldLabel", { ns: "config" })}</Label>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
id="default-cap"
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="font-semibold tabular-nums"
|
||||
disabled={saving}
|
||||
onClick={() => setDraftRows((prev) => [...prev, newRow()])}
|
||||
>
|
||||
{t("riskCap.actions.addSpecialCap", { ns: "config" })}
|
||||
</Button>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
value={defaultCapInput}
|
||||
placeholder={t("riskCap.placeholders.defaultCap", { ns: "config" })}
|
||||
onChange={(e) => setDefaultCapInput(e.target.value)}
|
||||
onBlur={() => setDraftRows(applyDefaultCapInput(defaultCapInput))}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue className="font-semibold tabular-nums">{defaultCapDisplay}</ConfigReadonlyValue>
|
||||
)}
|
||||
</div>
|
||||
</AdminPageCard>
|
||||
|
||||
{canEditDraft && !showNumberCaps && specialRows.length === 0 && drawBoundRows.length === 0 ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={saving || loadingDetail}
|
||||
onClick={() => {
|
||||
setShowNumberCaps(true);
|
||||
setDraftRows((prev) => [...prev, newRow()]);
|
||||
}}
|
||||
>
|
||||
{t("riskCap.actions.addNumberCap", { ns: "config" })}
|
||||
</Button>
|
||||
) : null}
|
||||
|
||||
{showNumberCaps || specialRows.length > 0 || drawBoundRows.length > 0 ? (
|
||||
<AdminPageCard
|
||||
title={t("riskCap.specialCaps.title", { ns: "config" })}
|
||||
actions={
|
||||
canEditDraft ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={saving}
|
||||
onClick={() => setDraftRows((prev) => [...prev, newRow()])}
|
||||
>
|
||||
{t("riskCap.actions.addSpecialCap", { ns: "config" })}
|
||||
</Button>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{loadingDetail ? (
|
||||
<AdminLoadingState minHeight="6rem" className="py-4" label={t("riskCap.loadingDetails", { ns: "config" })} />
|
||||
) : specialRows.length === 0 ? (
|
||||
<AdminLoadingState
|
||||
minHeight="6rem"
|
||||
className="py-4"
|
||||
label={t("riskCap.loadingDetails", { ns: "config" })}
|
||||
/>
|
||||
) : specialRows.length === 0 && drawBoundRows.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">{t("riskCap.noDetailRows", { ns: "config" })}</p>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{[
|
||||
{
|
||||
key: "global",
|
||||
title: t("riskCap.groups.globalTitle", { ns: "config" }),
|
||||
description: t("riskCap.groups.globalDescription", { ns: "config" }),
|
||||
rows: globalRows,
|
||||
emptyText: t("riskCap.groups.globalEmpty", { ns: "config" }),
|
||||
},
|
||||
{
|
||||
key: "draw",
|
||||
title: t("riskCap.groups.drawTitle", { ns: "config" }),
|
||||
description: t("riskCap.groups.drawDescription", { ns: "config" }),
|
||||
rows: drawRows,
|
||||
emptyText: t("riskCap.groups.drawEmpty", { ns: "config" }),
|
||||
},
|
||||
].map((group) => (
|
||||
<div key={group.key} className="rounded-xl border border-border/60 bg-muted/10 p-3">
|
||||
<div className="mb-3 flex flex-wrap items-start justify-between gap-2">
|
||||
<div className="space-y-1">
|
||||
<h3 className="text-sm font-semibold text-foreground">{group.title}</h3>
|
||||
<p className="text-xs leading-5 text-muted-foreground">{group.description}</p>
|
||||
</div>
|
||||
<span className="rounded-full bg-background px-2 py-1 text-xs text-muted-foreground">
|
||||
{t("riskCap.groups.count", { ns: "config", count: group.rows.length })}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{group.rows.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">{group.emptyText}</p>
|
||||
) : (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-[180px]">{t("riskCap.table.scope", { ns: "config" })}</TableHead>
|
||||
<TableHead className="w-[110px]">{t("riskCap.table.number", { ns: "config" })}</TableHead>
|
||||
<TableHead className="w-[140px]">{t("riskCap.table.capAmount", { ns: "config" })}</TableHead>
|
||||
<TableHead className="sticky right-0 z-20 w-14 bg-muted text-center shadow-[-1px_0_0_rgba(203,213,225,0.7)]">
|
||||
{t("riskCap.table.actions", { ns: "config" })}
|
||||
</TableHead>
|
||||
{specialRows.length > 0 ? (
|
||||
<div className="admin-table-shell">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-[110px]">{t("riskCap.table.number", { ns: "config" })}</TableHead>
|
||||
<TableHead className="w-[140px]">{t("riskCap.table.capAmount", { ns: "config" })}</TableHead>
|
||||
<TableHead className="sticky right-0 z-20 w-14 bg-muted text-center shadow-[-1px_0_0_rgba(203,213,225,0.7)]">
|
||||
{t("riskCap.table.actions", { ns: "config" })}
|
||||
</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{specialRows.map(({ row: r, index: idx }) => (
|
||||
<TableRow key={r.clientKey}>
|
||||
<TableCell>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
className="h-8 font-mono tabular-nums"
|
||||
maxLength={4}
|
||||
disabled={saving}
|
||||
value={r.normalized_number}
|
||||
placeholder={t("riskCap.placeholders.number", { ns: "config" })}
|
||||
onChange={(e) =>
|
||||
updateRow(idx, {
|
||||
normalized_number: e.target.value.replace(/\D/g, "").slice(0, 4),
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue mono>{r.normalized_number}</ConfigReadonlyValue>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="h-8 tabular-nums"
|
||||
disabled={saving}
|
||||
value={formatMinorToEditableMajor(r.cap_amount, amountCurrencyCode)}
|
||||
placeholder={t("riskCap.placeholders.capAmount", { ns: "config" })}
|
||||
onChange={(e) =>
|
||||
updateRow(idx, {
|
||||
cap_amount: parseAdminMajorToMinor(e.target.value, amountCurrencyCode) ?? 0,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue>
|
||||
{formatAdminMinorDecimal(r.cap_amount, amountCurrencyCode)}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="sticky right-0 z-10 bg-card text-center shadow-[-1px_0_0_rgba(203,213,225,0.7)]">
|
||||
{canEditDraft ? (
|
||||
<AdminRowActionsMenu
|
||||
busy={saving}
|
||||
actions={[
|
||||
{
|
||||
key: "delete",
|
||||
label: t("actions.delete", { ns: "adminUsers" }),
|
||||
icon: Trash2,
|
||||
destructive: true,
|
||||
onClick: () => removeRow(idx),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">—</span>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{group.rows.map(({ row: r, index: idx }) => (
|
||||
<TableRow key={r.clientKey}>
|
||||
<TableCell>
|
||||
{canEditDraft ? (
|
||||
<Select
|
||||
value={r.draw_id == null ? "__global__" : String(r.draw_id)}
|
||||
onValueChange={(value) =>
|
||||
updateRow(idx, { draw_id: value === "__global__" ? null : Number(value) })
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="h-8 min-w-0">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="__global__">
|
||||
{t("riskCap.scope.global", { ns: "config" })}
|
||||
</SelectItem>
|
||||
{drawOptions.map((draw) => (
|
||||
<SelectItem key={draw.id} value={String(draw.id)}>
|
||||
{draw.draw_no}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
) : (
|
||||
<ConfigReadonlyValue>
|
||||
{r.draw_id == null
|
||||
? t("riskCap.scope.global", { ns: "config" })
|
||||
: drawOptions.find((draw) => draw.id === r.draw_id)?.draw_no ??
|
||||
t("riskCap.scope.drawId", { ns: "config", id: r.draw_id })}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
className="h-8 font-mono tabular-nums"
|
||||
maxLength={4}
|
||||
disabled={saving}
|
||||
value={r.normalized_number}
|
||||
placeholder={t("riskCap.placeholders.number", { ns: "config" })}
|
||||
onChange={(e) =>
|
||||
updateRow(idx, {
|
||||
normalized_number: e.target.value.replace(/\D/g, "").slice(0, 4),
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue mono>{r.normalized_number}</ConfigReadonlyValue>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{canEditDraft ? (
|
||||
<Input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="h-8 tabular-nums"
|
||||
disabled={saving}
|
||||
value={formatMinorToEditableMajor(r.cap_amount, amountCurrencyCode)}
|
||||
placeholder={t("riskCap.placeholders.capAmount", { ns: "config" })}
|
||||
onChange={(e) =>
|
||||
updateRow(idx, {
|
||||
cap_amount:
|
||||
parseAdminMajorToMinor(e.target.value, amountCurrencyCode) ?? 0,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue>
|
||||
{formatAdminMinorDecimal(r.cap_amount, amountCurrencyCode)}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="sticky right-0 z-10 bg-card text-center shadow-[-1px_0_0_rgba(203,213,225,0.7)]">
|
||||
{canEditDraft ? (
|
||||
<AdminRowActionsMenu
|
||||
busy={saving}
|
||||
actions={[
|
||||
{
|
||||
key: "delete",
|
||||
label: t("actions.delete", { ns: "adminUsers" }),
|
||||
icon: Trash2,
|
||||
destructive: true,
|
||||
onClick: () => removeRow(idx),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t("riskCap.readOnly", { ns: "config" })}
|
||||
</span>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
))}
|
||||
) : null}
|
||||
|
||||
{drawBoundRows.length > 0 ? (
|
||||
<div className="admin-table-shell">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{t("riskCap.table.draw", { ns: "config" })}</TableHead>
|
||||
<TableHead>{t("riskCap.table.number", { ns: "config" })}</TableHead>
|
||||
<TableHead>{t("riskCap.table.capAmount", { ns: "config" })}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{drawBoundRows.map((row) => (
|
||||
<TableRow key={row.clientKey}>
|
||||
<TableCell>{drawLabel(row.draw_id ?? 0)}</TableCell>
|
||||
<TableCell className="font-mono">{row.normalized_number}</TableCell>
|
||||
<TableCell>{formatAdminMinorDecimal(row.cap_amount, amountCurrencyCode)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</ConfigSection>
|
||||
|
||||
<RiskCapRuntimePanel />
|
||||
|
||||
<Dialog open={syncOpen} onOpenChange={setSyncOpen}>
|
||||
<DialogContent showCloseButton className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t("riskCap.syncDialog.title", { ns: "config" })}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{t("riskCap.syncDialog.description", { ns: "config", value: defaultCapStr || "(empty)" })}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" onClick={() => setSyncOpen(false)}>
|
||||
{t("actions.cancel", { ns: "adminUsers" })}
|
||||
</Button>
|
||||
<Button type="button" onClick={applyDefaultCap}>
|
||||
{t("riskCap.syncDialog.confirm", { ns: "config" })}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</AdminPageCard>
|
||||
) : null}
|
||||
|
||||
<Dialog open={rollbackOpen} onOpenChange={setRollbackOpen}>
|
||||
<DialogContent showCloseButton className="sm:max-w-md">
|
||||
@@ -782,4 +691,4 @@ export function RiskCapDocScreen() {
|
||||
<ConfirmDialog />
|
||||
</ConfigDocPage>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user