feat: 添加货币管理功能,更新国际化支持,移除报表相关代码

This commit is contained in:
2026-05-21 16:24:56 +08:00
parent 6ecbaf5fb4
commit 055c613a6d
87 changed files with 1615 additions and 1319 deletions

View File

@@ -2,6 +2,7 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
allowedDevOrigins: ["192.168.0.101"],
reactCompiler: true,
async redirects() {
return [

View File

@@ -0,0 +1,32 @@
import { adminRequest } from "@/lib/admin-http";
import { API_V1_PREFIX } from "./paths";
import type {
AdminCurrencyCreatePayload,
AdminCurrencyDeleteResult,
AdminCurrencyListData,
AdminCurrencyRow,
AdminCurrencyUpdatePayload,
} from "@/types/api/admin-currency";
const A = `${API_V1_PREFIX}/admin`;
export async function getAdminCurrencies(): Promise<AdminCurrencyListData> {
return adminRequest.get<AdminCurrencyListData>(`${A}/currencies`);
}
export async function postAdminCurrency(body: AdminCurrencyCreatePayload): Promise<AdminCurrencyRow> {
return adminRequest.post<AdminCurrencyRow>(`${A}/currencies`, body);
}
export async function putAdminCurrency(
code: string,
body: AdminCurrencyUpdatePayload,
): Promise<AdminCurrencyRow> {
return adminRequest.put<AdminCurrencyRow>(`${A}/currencies/${encodeURIComponent(code)}`, body);
}
export async function deleteAdminCurrency(code: string): Promise<AdminCurrencyDeleteResult> {
return adminRequest.delete<AdminCurrencyDeleteResult>(`${A}/currencies/${encodeURIComponent(code)}`);
}

View File

@@ -22,8 +22,9 @@ export async function getAdminReconcileJobs(params?: {
export async function postAdminReconcileJob(body: {
reconcile_type: string;
period_start?: string | null;
period_end?: string | null;
date_from?: string | null;
date_to?: string | null;
player_id?: number | null;
items?: {
side_a_ref?: string | null;
side_b_ref?: string | null;

View File

@@ -1,44 +0,0 @@
import { adminHttp, adminRequest } from "@/lib/admin-http";
import { withAdminAuthHeader } from "@/lib/admin-auth";
import { withAdminLocaleHeaders } from "@/lib/admin-locale";
import { API_V1_PREFIX } from "./paths";
import type {
AdminReportJobCreateResponse,
AdminReportJobListData,
} from "@/types/api/admin-reports";
const A = `${API_V1_PREFIX}/admin`;
export async function getAdminReportJobs(params?: {
page?: number;
per_page?: number;
}): Promise<AdminReportJobListData> {
return adminRequest.get<AdminReportJobListData>(`${A}/report-jobs`, {
params,
});
}
export async function postAdminReportJob(body: {
report_type: string;
export_format?: "csv" | "xlsx";
parameters?: Record<string, unknown> | null;
filter_json?: Record<string, unknown> | null;
}): Promise<AdminReportJobCreateResponse> {
return adminRequest.post<AdminReportJobCreateResponse>(
`${A}/report-jobs`,
body,
);
}
export async function downloadAdminReportJob(jobId: number): Promise<Blob> {
const res = await adminHttp.request<Blob>(
withAdminAuthHeader(withAdminLocaleHeaders({
url: `${A}/report-jobs/${jobId}/download`,
method: "GET",
responseType: "blob",
})),
);
return res.data;
}

View File

@@ -8,7 +8,6 @@ export {
getAdminTransferOrders,
getAdminWalletTransactions,
} from "@/api/admin-wallet";
export { getAdminReportJobs, postAdminReportJob } from "@/api/admin-reports";
export {
getAdminReconcileJobItems,
getAdminReconcileJobs,

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminRolesPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<AdminRolesConsole />
</ModuleScaffold>
);

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminUsersPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<AdminUsersConsole />
</ModuleScaffold>
);

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminAuditLogsPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<AuditLogsConsole />
</ModuleScaffold>
);

View File

@@ -0,0 +1,15 @@
import { ModuleScaffold } from "@/components/admin/module-scaffold";
import { CurrencyManagementScreen } from "@/modules/settings/currency-management-screen";
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "币种管理",
};
export default function AdminCurrenciesPage() {
return (
<ModuleScaffold>
<CurrencyManagementScreen />
</ModuleScaffold>
);
}

View File

@@ -8,7 +8,7 @@ export default async function AdminDrawSegmentLayout(props: {
const { drawId } = await props.params;
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<DrawSubnav drawId={drawId} />
{props.children}
</ModuleScaffold>

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminDrawsPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<DrawsIndexConsole />
</ModuleScaffold>
);

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminPlayersPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<PlayersConsole />
</ModuleScaffold>
);

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminReconcilePage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<ReconcileConsole />
</ModuleScaffold>
);

View File

@@ -1,16 +0,0 @@
import { ModuleScaffold } from "@/components/admin/module-scaffold";
import { reportsModuleMeta } from "@/modules/reports/meta";
import { ReportsConsole } from "@/modules/reports/reports-console";
import type { Metadata } from "next";
export const metadata: Metadata = {
title: reportsModuleMeta.title,
};
export default function AdminReportsPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ReportsConsole />
</ModuleScaffold>
);
}

View File

@@ -11,7 +11,7 @@ export default async function AdminRiskDrawLayout(props: {
const safeId = Number.isFinite(id) ? id : 0;
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<RiskDrawHeader drawId={safeId} />
<RiskSubnav drawId={drawId} />
{props.children}

View File

@@ -0,0 +1,10 @@
import { redirect } from "next/navigation";
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "币种管理",
};
export default function AdminCurrencySettingsPage() {
redirect("/admin/currencies");
}

View File

@@ -9,7 +9,7 @@ export const metadata: Metadata = {
export default function AdminTicketsPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<ModuleScaffold>
<PlayerTicketsConsole />
</ModuleScaffold>
);

View File

@@ -4,8 +4,10 @@ import { WalletSubnav } from "@/modules/wallet/wallet-subnav";
export default function AdminWalletLayout({ children }: { children: ReactNode }) {
return (
<div className="w-full max-w-none">
<WalletSubnav />
<div className="mx-auto flex w-full max-w-[1680px] min-w-0 flex-col gap-6 px-4 py-5 sm:px-6 lg:px-8 lg:py-6">
<div className="sticky top-14 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">
<WalletSubnav />
</div>
{children}
</div>
);

View File

@@ -1,4 +1,3 @@
import { ModuleScaffold } from "@/components/admin/module-scaffold";
import { walletModuleMeta } from "@/modules/wallet/meta";
import { PlayerWalletPanel } from "@/modules/wallet/wallet-console";
import type { Metadata } from "next";
@@ -8,9 +7,5 @@ export const metadata: Metadata = {
};
export default function AdminWalletPlayerPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<PlayerWalletPanel />
</ModuleScaffold>
);
return <PlayerWalletPanel />;
}

View File

@@ -1,4 +1,3 @@
import { ModuleScaffold } from "@/components/admin/module-scaffold";
import { walletModuleMeta } from "@/modules/wallet/meta";
import { WalletTxnsPanel } from "@/modules/wallet/wallet-console";
import type { Metadata } from "next";
@@ -8,9 +7,5 @@ export const metadata: Metadata = {
};
export default function AdminWalletTransactionsPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<WalletTxnsPanel />
</ModuleScaffold>
);
return <WalletTxnsPanel />;
}

View File

@@ -1,4 +1,3 @@
import { ModuleScaffold } from "@/components/admin/module-scaffold";
import { walletModuleMeta } from "@/modules/wallet/meta";
import { TransferOrdersPanel } from "@/modules/wallet/wallet-console";
import type { Metadata } from "next";
@@ -8,9 +7,5 @@ export const metadata: Metadata = {
};
export default function AdminWalletTransferOrdersPage() {
return (
<ModuleScaffold className="w-full max-w-none">
<TransferOrdersPanel />
</ModuleScaffold>
);
return <TransferOrdersPanel />;
}

View File

@@ -131,27 +131,27 @@
@layer components {
.admin-list-card {
@apply overflow-hidden border-border/80 shadow-sm;
@apply overflow-hidden border-border/80 bg-card shadow-sm;
}
.admin-list-header {
@apply border-b bg-muted/20 pb-4;
@apply border-b border-border/70 bg-gradient-to-b from-muted/25 to-transparent pb-5;
}
.admin-list-title {
@apply text-lg font-semibold tracking-tight;
@apply text-[1.05rem] font-semibold tracking-tight text-[#13315f];
}
.admin-list-content {
@apply space-y-4;
@apply space-y-5;
}
.admin-list-toolbar {
@apply flex w-full flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center;
@apply flex w-full flex-col gap-3 border-t border-border/60 pt-4 xl:flex-row xl:flex-wrap xl:items-center;
}
.admin-list-field {
@apply flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:shrink-0 sm:gap-1.5;
@apply flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-2;
}
.admin-list-field > label {
@@ -159,16 +159,15 @@
}
.admin-list-actions {
@apply flex shrink-0 flex-wrap gap-2;
margin-left: auto;
@apply flex shrink-0 flex-wrap items-center gap-2 xl:ml-auto xl:justify-end;
}
.admin-table-shell {
@apply overflow-x-auto rounded-xl border border-border bg-background;
@apply overflow-x-auto rounded-2xl border border-border/80 bg-card shadow-sm;
}
.admin-table-toolbar {
@apply flex items-center justify-end border-b border-border bg-muted/15 px-3 py-2.5;
@apply flex items-center justify-end border-b border-border/70 bg-muted/20 px-4 py-2.5;
}
.admin-inline-note {

View File

@@ -26,6 +26,7 @@ const NAV_TRANSLATION_KEYS: Record<string, string> = {
admin_users: "admin_users",
admin_roles: "admin_roles",
players: "players",
currencies: "currencies",
wallet: "wallet",
draws: "draws",
config: "config",
@@ -33,11 +34,14 @@ const NAV_TRANSLATION_KEYS: Record<string, string> = {
settlement: "settlement",
reconcile: "reconcile",
tickets: "tickets",
reports: "reports",
audit: "audit",
settings: "settings",
};
const SETTINGS_ROUTE_LABELS: Record<string, string> = {
currencies: "currencies.title",
};
function titleCase(value: string): string {
return value
.split("-")
@@ -52,7 +56,7 @@ type BreadcrumbCrumb = {
};
export function AdminBreadcrumb() {
const { t } = useTranslation(["common", "dashboard", "reports", "audit", "config", "draws"]);
const { t } = useTranslation(["common", "dashboard", "audit", "config", "draws"]);
const pathname = usePathname();
const profile = useAdminProfile();
const navItems = profile?.navigation ?? [];
@@ -105,6 +109,11 @@ export function AdminBreadcrumb() {
let subLabel = "";
if (businessSegment === "config" && subSegment) {
subLabel = t(`nav.items.${subSegment}`, { ns: "config", defaultValue: titleCase(subSegment) });
} else if (businessSegment === "settings" && subSegment) {
subLabel = t(SETTINGS_ROUTE_LABELS[subSegment] ?? `settings.${subSegment}`, {
ns: "config",
defaultValue: titleCase(subSegment),
});
} else {
subLabel = subSegment
? t(`subnav.${subSegment}`, {

View File

@@ -117,8 +117,8 @@ export function AdminListPaginationFooter({
}) {
const { t } = useTranslation(["common"]);
return (
<div className="flex flex-col gap-4 border-t border-border pt-4 sm:flex-row sm:items-center sm:justify-between">
<p className="text-muted-foreground text-sm tabular-nums">
<div className="flex flex-col gap-4 border-t border-border/70 bg-muted/10 px-1 pt-4 sm:flex-row sm:items-center sm:justify-between">
<p className="text-sm tabular-nums text-muted-foreground">
{t("pagination.summary", {
total,
page,

View File

@@ -22,17 +22,21 @@ import { adminNavIconBySegment } from "@/modules/_config/admin-nav-icons";
import { ADMIN_BASE } from "@/modules/_config/admin-nav";
import { useAdminProfile } from "@/stores/admin-session";
function isActive(pathname: string, item: { href: string; activeMatchPrefix?: string }): boolean {
const { href, activeMatchPrefix } = item;
function isActive(pathname: string, item: { href: string; activeMatchPrefix?: string; segment?: string }): boolean {
const { href, activeMatchPrefix, segment } = item;
const prefix = activeMatchPrefix ?? href;
if (prefix === ADMIN_BASE || prefix === `${ADMIN_BASE}/`) {
return pathname === ADMIN_BASE || pathname === `${ADMIN_BASE}/`;
}
// Keep "settings" independent from its child routes like /admin/settings/currencies.
if (segment === "settings") {
return pathname === href;
}
return pathname === prefix || pathname.startsWith(`${prefix}/`);
}
export function AdminAppSidebar() {
const { t } = useTranslation(["common", "dashboard", "players", "draws", "config", "wallet", "risk", "settlement", "jackpot", "reconcile", "tickets", "reports", "audit"]);
const { t } = useTranslation(["common", "dashboard", "players", "draws", "config", "wallet", "risk", "settlement", "jackpot", "reconcile", "tickets", "audit"]);
const pathname = usePathname();
const profile = useAdminProfile();
const visibleNav = useMemo(

View File

@@ -9,5 +9,14 @@ type ModuleScaffoldProps = {
/** 内容区容器;模块标题由侧栏导航体现,此处不再重复大标题与说明。 */
export function ModuleScaffold({ children, className }: ModuleScaffoldProps) {
return <div className={cn("mx-auto w-full max-w-none min-w-0", className)}>{children}</div>;
return (
<div
className={cn(
"mx-auto flex w-full max-w-[1680px] min-w-0 flex-col gap-6 px-4 py-5 sm:px-6 lg:px-8 lg:py-6",
className,
)}
>
{children}
</div>
);
}

View File

@@ -12,7 +12,7 @@ function Card({
data-slot="card"
data-size={size}
className={cn(
"group/card flex flex-col gap-4 overflow-hidden rounded-lg border border-border bg-card py-4 text-sm text-card-foreground shadow-[0_6px_18px_rgb(15_48_96_/_5%)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg",
"group/card flex flex-col gap-4 overflow-hidden rounded-2xl border border-border/60 bg-card py-5 text-sm text-card-foreground shadow-none has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-2xl *:[img:last-child]:rounded-b-2xl",
className
)}
{...props}
@@ -25,7 +25,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-header"
className={cn(
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-2xl px-5 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
className
)}
{...props}
@@ -73,7 +73,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
className={cn("px-5 group-data-[size=sm]/card:px-3", className)}
{...props}
/>
)
@@ -84,7 +84,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-footer"
className={cn(
"flex items-center rounded-b-lg border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
"flex items-center rounded-b-2xl border-t border-border/60 bg-muted/30 p-5 group-data-[size=sm]/card:p-3",
className
)}
{...props}

View File

@@ -8,11 +8,11 @@ function Table({ className, ...props }: React.ComponentProps<"table">) {
return (
<div
data-slot="table-container"
className="relative w-full overflow-x-auto rounded-lg border border-border bg-card"
className="relative w-full overflow-x-auto rounded-2xl border border-border/60 bg-card shadow-none"
>
<table
data-slot="table"
className={cn("w-full caption-bottom border-collapse text-xs", className)}
className={cn("w-full min-w-full caption-bottom border-collapse text-sm", className)}
{...props}
/>
</div>
@@ -23,7 +23,7 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
return (
<thead
data-slot="table-header"
className={cn("bg-muted/70 [&_tr]:border-b", className)}
className={cn("bg-muted/20 [&_tr]:border-b", className)}
{...props}
/>
)
@@ -57,7 +57,7 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
<tr
data-slot="table-row"
className={cn(
"border-b border-border transition-colors hover:bg-muted/45 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
"border-b border-border/60 transition-colors hover:bg-muted/35 has-aria-expanded:bg-muted/45 data-[state=selected]:bg-muted/60",
className
)}
{...props}
@@ -70,7 +70,7 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
<th
data-slot="table-head"
className={cn(
"h-9 border-r border-border px-2 text-center align-middle font-semibold whitespace-nowrap text-[#17305f] last:border-r-0 [&:has([role=checkbox])]:pr-0",
"h-11 px-3 text-left align-middle font-semibold tracking-wide whitespace-nowrap text-[#17305f] [&:has([role=checkbox])]:pr-0",
className
)}
{...props}
@@ -83,7 +83,7 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
<td
data-slot="table-cell"
className={cn(
"border-r border-border px-2 py-2 text-center align-middle whitespace-nowrap last:border-r-0 [&:has([role=checkbox])]:pr-0",
"px-3 py-2.5 text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
className
)}
{...props}

View File

@@ -0,0 +1,32 @@
"use client";
import { useEffect } from "react";
import { getAdminCurrencies } from "@/api/admin-currencies";
import type { AdminCurrencyRow } from "@/types/api/admin-currency";
let cachedAdminCurrencies: AdminCurrencyRow[] = [];
let inflightAdminCurrencyLoad: Promise<void> | null = null;
export function getCachedAdminCurrencies(): AdminCurrencyRow[] {
return cachedAdminCurrencies;
}
export function useAdminCurrencyCatalog() {
useEffect(() => {
if (cachedAdminCurrencies.length > 0 || inflightAdminCurrencyLoad !== null) {
return;
}
inflightAdminCurrencyLoad = getAdminCurrencies()
.then((data) => {
cachedAdminCurrencies = data.items;
})
.catch(() => {
// 币种目录失败时回退默认 2 位小数,不阻断后台页面。
})
.finally(() => {
inflightAdminCurrencyLoad = null;
});
}, []);
}

View File

@@ -12,7 +12,6 @@ import enConfig from "@/i18n/locales/en/config.json";
import enDashboard from "@/i18n/locales/en/dashboard.json";
import enDraws from "@/i18n/locales/en/draws.json";
import enJackpot from "@/i18n/locales/en/jackpot.json";
import enReports from "@/i18n/locales/en/reports.json";
import enRisk from "@/i18n/locales/en/risk.json";
import enSettlement from "@/i18n/locales/en/settlement.json";
import enPlayers from "@/i18n/locales/en/players.json";
@@ -27,7 +26,6 @@ import neConfig from "@/i18n/locales/ne/config.json";
import neDashboard from "@/i18n/locales/ne/dashboard.json";
import neDraws from "@/i18n/locales/ne/draws.json";
import neJackpot from "@/i18n/locales/ne/jackpot.json";
import neReports from "@/i18n/locales/ne/reports.json";
import neRisk from "@/i18n/locales/ne/risk.json";
import neSettlement from "@/i18n/locales/ne/settlement.json";
import nePlayers from "@/i18n/locales/ne/players.json";
@@ -42,7 +40,6 @@ import zhConfig from "@/i18n/locales/zh/config.json";
import zhDashboard from "@/i18n/locales/zh/dashboard.json";
import zhDraws from "@/i18n/locales/zh/draws.json";
import zhJackpot from "@/i18n/locales/zh/jackpot.json";
import zhReports from "@/i18n/locales/zh/reports.json";
import zhRisk from "@/i18n/locales/zh/risk.json";
import zhSettlement from "@/i18n/locales/zh/settlement.json";
import zhPlayers from "@/i18n/locales/zh/players.json";
@@ -54,7 +51,7 @@ export const ADMIN_SUPPORTED_LANGUAGES = ["en", "ne", "zh"] as const;
export type AdminLanguage = (typeof ADMIN_SUPPORTED_LANGUAGES)[number];
export const ADMIN_DEFAULT_LANGUAGE: AdminLanguage = "zh";
const namespaces = ["common", "auth", "dashboard", "reports", "audit", "draws", "settlement", "risk", "jackpot", "players", "tickets", "reconcile", "wallet", "adminUsers", "config"] as const;
const namespaces = ["common", "auth", "dashboard", "audit", "draws", "settlement", "risk", "jackpot", "players", "tickets", "reconcile", "wallet", "adminUsers", "config"] as const;
const resources = {
en: {
@@ -68,7 +65,6 @@ const resources = {
players: enPlayers,
tickets: enTickets,
reconcile: enReconcile,
reports: enReports,
risk: enRisk,
audit: enAudit,
settlement: enSettlement,
@@ -85,7 +81,6 @@ const resources = {
players: nePlayers,
tickets: neTickets,
reconcile: neReconcile,
reports: neReports,
risk: neRisk,
audit: neAudit,
settlement: neSettlement,
@@ -102,7 +97,6 @@ const resources = {
players: zhPlayers,
tickets: zhTickets,
reconcile: zhReconcile,
reports: zhReports,
risk: zhRisk,
audit: zhAudit,
settlement: zhSettlement,

View File

@@ -133,7 +133,6 @@
"jackpot": "Jackpot",
"reconcile": "Reconcile",
"tickets": "Tickets",
"reports": "Reports",
"audit": "Audit Logs",
"settings": "Settings"
},
@@ -141,6 +140,7 @@
"prd.admin_user.manage": "Admin Users · Manage",
"prd.admin_role.manage": "Role Management · Manage",
"prd.users.manage": "Players · Manage",
"prd.currency.manage": "Currency Management · Manage",
"prd.users.view_finance": "Players · View Finance",
"prd.users.view_cs": "Players · View Customer Service Cases",
"prd.player_freeze.manage": "Freeze/Unfreeze Player · Manage",
@@ -162,10 +162,6 @@
"prd.payout.manage": "Payout Confirmation · Manage",
"prd.payout.review": "Payout Confirmation · Review",
"prd.payout.view": "Payout Confirmation · View",
"prd.report.all": "Reports · All",
"prd.report.risk": "Reports · Risk",
"prd.report.finance": "Reports · Finance",
"prd.report.player": "Reports · Single Player",
"prd.audit.all": "Audit Logs · All",
"prd.audit.self": "Audit Logs · Related to Self",
"prd.audit.finance": "Audit Logs · Finance Related"

View File

@@ -62,6 +62,7 @@
"admin_users": "Admin Users",
"admin_roles": "Role Management",
"players": "Players",
"currencies": "Currencies",
"wallet": "Wallet",
"draws": "Draws",
"config": "Configuration",
@@ -70,7 +71,6 @@
"jackpot": "Jackpot",
"reconcile": "Reconcile",
"tickets": "Ticket list",
"reports": "Reports",
"audit": "Audit Logs",
"settings": "Settings"
},

View File

@@ -94,6 +94,54 @@
},
"discard": "Discard changes"
},
"currencies": {
"title": "Currency management",
"description": "Maintain currency master data for admin operations and control whether a currency is enabled or allowed for betting.",
"loading": "Loading currencies…",
"empty": "No currencies yet.",
"loadFailed": "Failed to load currencies",
"createSuccess": "Currency created",
"createFailed": "Failed to create currency",
"updateSuccess": "Currency updated",
"updateFailed": "Failed to update currency",
"deleteSuccess": "Currency {{code}} deleted",
"deleteFailed": "Failed to delete currency",
"actions": {
"create": "Add currency",
"edit": "Edit",
"delete": "Delete",
"openStandalone": "Open dedicated page",
"backToSettings": "Back to settings"
},
"table": {
"code": "Code",
"name": "Name",
"decimals": "Decimals",
"enabled": "Enabled",
"bettable": "Bettable",
"actions": "Actions"
},
"dialog": {
"createTitle": "Add currency",
"editTitle": "Edit currency",
"description": "Currency code is immutable after creation. Disabling a currency also turns off bettable status."
},
"deleteDialog": {
"title": "Delete currency?",
"description": "Delete currency {{code}}? The system blocks deletion when it is still referenced by defaults, wallets, tickets, odds, or jackpot data."
},
"form": {
"code": "Currency code",
"name": "Currency name",
"decimals": "Decimal places",
"enabled": "Enabled status",
"enabledHint": "Disabled currencies should not be used for new business.",
"bettable": "Allow betting",
"bettableHint": "Only enabled currencies can be marked as bettable.",
"required": "Please fill in the required fields",
"decimalInvalid": "Enter a valid decimal place value"
}
},
"play": {
"batchGroups": {
"d2": "2D Global",

View File

@@ -46,7 +46,6 @@
"results": "Results",
"tickets": "Ticket management",
"walletTransactions": "Wallet transactions",
"reports": "Reports",
"auditLogs": "Audit logs"
},
"warnings": {

View File

@@ -1,36 +1,46 @@
{
"title": "Reconcile",
"createTitle": "Create reconcile job",
"createDesc": "Manually check abnormal transfers by period or selected references. Scheduled reconciliation still runs automatically.",
"createDesc": "Manually check abnormal transfers by date range and optional player. Scheduled reconciliation still runs automatically.",
"reconcileType": "Reconcile type",
"walletTransfer": "Wallet transfer (main site ⇄ lottery)",
"startTime": "Start time",
"endTime": "End time",
"scope": "Targets (optional)",
"scopePlaceholder": "One per line: player ID, transfer number, or main-site transaction number.\nLeave empty to check abnormal transfers in the selected period.",
"reconcileTypeFixed": "Wallet transfer (main site ⇄ lottery)",
"reconcileTypeHint": "Only wallet transfer is currently supported.",
"dateRange": "Reconcile date range",
"createTask": "Create reconcile job",
"submitting": "Submitting…",
"loadFailed": "Failed to load",
"loadItemsFailed": "Failed to load details",
"periodRequired": "Enter both reconcile start and end time",
"periodInvalid": "Invalid time range",
"periodRequired": "Enter both reconcile start and end dates",
"periodInvalid": "Invalid date range",
"periodOrderInvalid": "End time must be later than or equal to start time",
"createSuccess": "Reconcile job created",
"createFailed": "Failed to create job",
"noCreatePermission": "Current account cannot create reconcile jobs.",
"jobsTitle": "Reconcile jobs",
"jobsDesc": "Click a row to view paginated item details.",
"jobsDesc": "Use the action on the right to open paginated item details.",
"refresh": "Refresh",
"jobNo": "Job no.",
"type": "Type",
"status": "Status",
"period": "Period",
"createdAt": "Created at",
"operate": "Action",
"view": "View",
"detailsTitle": "Job details",
"sideARef": "Lottery ref",
"sideBRef": "Main site ref",
"differenceAmount": "Difference (cent)",
"noDetails": "No details",
"playerSearch": "Player (optional)",
"playerSearchPlaceholder": "Search by player ID / username / nickname",
"playerSearchHint": "After selection, reconciliation is limited to this player in the chosen date range.",
"playerSearchEmpty": "Enter a keyword to search players.",
"playerNoResults": "No matching players",
"playerChoose": "Choose",
"playerSelected": "Selected player",
"playerSelectedShort": "Selected",
"playerClear": "Clear",
"loadingPlayers": "Searching players…",
"statusCompleted": "Completed",
"statusRunning": "Running",
"statusFailed": "Failed",

View File

@@ -1,45 +0,0 @@
{
"title": "Reports",
"createExport": "Create export",
"reportType": "Report type",
"exportFormat": "Export format",
"filterJson": "filter_json (optional)",
"parseFilterFailed": "Failed to parse filter JSON",
"createSuccess": "Export job created",
"createFailed": "Failed to create job",
"downloadFailed": "Download failed",
"taskList": "Job list",
"jobId": "Job no.",
"type": "Type",
"format": "Format",
"status": "Status",
"output": "Output",
"download": "Download",
"createdAt": "Created at",
"id": "ID",
"empty": "No data",
"formatOptions": {
"csv": "CSV",
"xlsx": "Excel"
},
"statusOptions": {
"pending": "Pending",
"queued": "Queued",
"running": "Running",
"completed": "Completed",
"failed": "Failed"
},
"reportTypes": {
"draw_profit_summary": "Draw profit summary",
"daily_profit_summary": "Daily profit summary",
"player_win_loss": "Player win/loss report",
"wallet_transfer_report": "Wallet transfer report",
"hot_number_risk_report": "Hot number risk report",
"play_dimension_report": "Play dimension report",
"sold_out_number_report": "Sold-out number report",
"rebate_commission_report": "Rebate and commission report",
"audit_operation_report": "Audit operation report",
"wallet_txns_daily": "Wallet transactions daily",
"transfer_orders_daily": "Transfer orders daily"
}
}

View File

@@ -133,7 +133,6 @@
"jackpot": "ज्याकपोट",
"reconcile": "मिलान",
"tickets": "टिकटहरू",
"reports": "रिपोर्टहरू",
"audit": "अडिट लग",
"settings": "सेटिङ"
},
@@ -141,6 +140,7 @@
"prd.admin_user.manage": "प्रशासक सूची · व्यवस्थापन",
"prd.admin_role.manage": "भूमिका व्यवस्थापन · व्यवस्थापन",
"prd.users.manage": "खेलाडी व्यवस्थापन · व्यवस्थापन",
"prd.currency.manage": "मुद्रा व्यवस्थापन · व्यवस्थापन",
"prd.users.view_finance": "खेलाडी व्यवस्थापन · वित्त हेर्नुहोस्",
"prd.users.view_cs": "खेलाडी व्यवस्थापन · ग्राहक सेवा एकल प्रयोगकर्ता",
"prd.player_freeze.manage": "खेलाडी रोक्ने/फुकाउने · व्यवस्थापन",
@@ -162,10 +162,6 @@
"prd.payout.manage": "भुक्तानी पुष्टि · व्यवस्थापन",
"prd.payout.review": "भुक्तानी पुष्टि · समीक्षा",
"prd.payout.view": "भुक्तानी पुष्टि · हेर्नुहोस्",
"prd.report.all": "रिपोर्ट · सबै",
"prd.report.risk": "रिपोर्ट · जोखिम",
"prd.report.finance": "रिपोर्ट · वित्त",
"prd.report.player": "रिपोर्ट · एकल खेलाडी",
"prd.audit.all": "अडिट लग · सबै",
"prd.audit.self": "अडिट लग · आफूसँग सम्बन्धित",
"prd.audit.finance": "अडिट लग · वित्त सम्बन्धित"

View File

@@ -62,6 +62,7 @@
"admin_users": "प्रशासक सूची",
"admin_roles": "भूमिका व्यवस्थापन",
"players": "खेलाडी सूची",
"currencies": "मुद्रा व्यवस्थापन",
"wallet": "वालेट",
"draws": "ड्रअहरू",
"config": "कन्फिगरेसन",
@@ -70,7 +71,6 @@
"jackpot": "Jackpot",
"reconcile": "मिलान",
"tickets": "टिकट सूची",
"reports": "रिपोर्टहरू",
"audit": "अडिट लग",
"settings": "सेटिङ"
},

View File

@@ -94,6 +94,54 @@
},
"discard": "परिवर्तन त्याग्नुहोस्"
},
"currencies": {
"title": "मुद्रा व्यवस्थापन",
"description": "एडमिन सञ्चालनका लागि मुद्रा master data राख्नुहोस् र मुद्रा सक्रिय वा बेटिङका लागि उपलब्ध छ कि छैन नियन्त्रण गर्नुहोस्।",
"loading": "मुद्रा सूची लोड हुँदैछ…",
"empty": "अहिलेसम्म मुद्रा छैन।",
"loadFailed": "मुद्रा सूची लोड गर्न असफल",
"createSuccess": "मुद्रा सिर्जना भयो",
"createFailed": "मुद्रा सिर्जना असफल भयो",
"updateSuccess": "मुद्रा अद्यावधिक भयो",
"updateFailed": "मुद्रा अद्यावधिक गर्न असफल",
"deleteSuccess": "मुद्रा {{code}} मेटाइयो",
"deleteFailed": "मुद्रा मेटाउन असफल",
"actions": {
"create": "मुद्रा थप्नुहोस्",
"edit": "सम्पादन",
"delete": "मेटाउनुहोस्",
"openStandalone": "अलग पृष्ठ खोल्नुहोस्",
"backToSettings": "सेटिङमा फर्कनुहोस्"
},
"table": {
"code": "कोड",
"name": "नाम",
"decimals": "दशमलव स्थान",
"enabled": "सक्रिय",
"bettable": "बेटिङयोग्य",
"actions": "कार्य"
},
"dialog": {
"createTitle": "मुद्रा थप्नुहोस्",
"editTitle": "मुद्रा सम्पादन गर्नुहोस्",
"description": "मुद्रा कोड सिर्जना भएपछि परिवर्तन गर्न मिल्दैन। मुद्रा निष्क्रिय गर्दा bettable पनि स्वतः बन्द हुन्छ।"
},
"deleteDialog": {
"title": "मुद्रा मेटाउने पुष्टि",
"description": "मुद्रा {{code}} मेटाउने? यदि यो मुद्रा default, wallet, ticket, odds वा jackpot डाटामा प्रयोग भएको छ भने प्रणालीले मेटाउन दिँदैन।"
},
"form": {
"code": "मुद्रा कोड",
"name": "मुद्रा नाम",
"decimals": "दशमलव स्थान",
"enabled": "सक्रिय स्थिति",
"enabledHint": "निष्क्रिय मुद्रा नयाँ व्यवसायमा प्रयोग गर्नु हुँदैन।",
"bettable": "बेटिङ अनुमति",
"bettableHint": "सक्रिय मुद्रा मात्र bettable बनाउन सकिन्छ।",
"required": "कृपया आवश्यक फिल्ड भर्नुहोस्",
"decimalInvalid": "मान्य दशमलव स्थान प्रविष्ट गर्नुहोस्"
}
},
"play": {
"batchGroups": {
"d2": "2D ग्लोबल",

View File

@@ -46,7 +46,6 @@
"results": "परिणाम",
"tickets": "टिकट व्यवस्थापन",
"walletTransactions": "वालेट कारोबार",
"reports": "रिपोर्ट",
"auditLogs": "अडिट लग"
},
"warnings": {

View File

@@ -1,36 +1,46 @@
{
"title": "मिलान",
"createTitle": "म्यानुअल मिलान कार्य",
"createDesc": "समय अवधि वा छानिएका सन्दर्भहरूबाट असामान्य ट्रान्सफर म्यानुअल रूपमा जाँच गर्नुहोस्। scheduled reconciliation स्वतः चलिरहन्छ।",
"createDesc": "मिति दायरा र वैकल्पिक खेलाडी चयनबाट असामान्य ट्रान्सफर म्यानुअल रूपमा जाँच गर्नुहोस्। scheduled reconciliation स्वतः चलिरहन्छ।",
"reconcileType": "मिलान प्रकार",
"walletTransfer": "वालेट ट्रान्सफर (मुख्य साइट ⇄ लटरी)",
"startTime": "सुरु समय",
"endTime": "अन्त्य समय",
"scope": "लक्षित सन्दर्भ (वैकल्पिक)",
"scopePlaceholder": "प्रति लाइन एउटा: player ID, transfer no, वा main-site transaction no.\nखाली छोडेमा चयन गरिएको अवधिका असामान्य ट्रान्सफर जाँच हुन्छ।",
"reconcileTypeFixed": "वालेट ट्रान्सफर (मुख्य साइट ⇄ लटरी)",
"reconcileTypeHint": "हाल वालेट ट्रान्सफर मात्र समर्थित छ।",
"dateRange": "मिलान मिति दायरा",
"createTask": "मिलान कार्य सिर्जना",
"submitting": "पेश हुँदैछ…",
"loadFailed": "लोड असफल भयो",
"loadItemsFailed": "विवरण लोड असफल भयो",
"periodRequired": "सुरु र अन्त्य समय दुवै लेख्नुहोस्",
"periodInvalid": "अवैध समय दायरा",
"periodRequired": "सुरु र अन्त्य मिति दुवै लेख्नुहोस्",
"periodInvalid": "अवैध मिति दायरा",
"periodOrderInvalid": "अन्त्य समय सुरु समयभन्दा पछाडि वा बराबर हुनुपर्छ",
"createSuccess": "मिलान कार्य सिर्जना भयो",
"createFailed": "कार्य सिर्जना असफल भयो",
"noCreatePermission": "हालको खातासँग मिलान कार्य सिर्जना गर्ने अनुमति छैन।",
"jobsTitle": "मिलान कार्यहरू",
"jobsDesc": "विवरण हेर्न row क्लिक गर्नुहोस्।",
"jobsDesc": "दायाँपट्टिको कार्यबाट विवरण खोल्नुहोस्।",
"refresh": "रिफ्रेस",
"jobNo": "कार्य नं.",
"type": "प्रकार",
"status": "स्थिति",
"period": "अवधि",
"createdAt": "सिर्जना समय",
"operate": "कार्य",
"view": "हेर्नुहोस्",
"detailsTitle": "कार्य विवरण",
"sideARef": "लटरी साइड सन्दर्भ",
"sideBRef": "मुख्य साइट सन्दर्भ",
"differenceAmount": "अन्तर (cent)",
"noDetails": "विवरण छैन",
"playerSearch": "खेलाडी (वैकल्पिक)",
"playerSearchPlaceholder": "player ID / username / nickname बाट खोज्नुहोस्",
"playerSearchHint": "चयनपछि छनोट गरिएको मिति दायरामा सो खेलाडी मात्र मिलान हुन्छ।",
"playerSearchEmpty": "खेलाडी खोज्न कुञ्जी शब्द लेख्नुहोस्।",
"playerNoResults": "मिल्ने खेलाडी भेटिएन",
"playerChoose": "छान्नुहोस्",
"playerSelected": "छानिएको खेलाडी",
"playerSelectedShort": "छानियो",
"playerClear": "खाली गर्नुहोस्",
"loadingPlayers": "खेलाडी खोजिँदै…",
"statusCompleted": "सम्पन्न",
"statusRunning": "चलिरहेको",
"statusFailed": "असफल",

View File

@@ -1,45 +0,0 @@
{
"title": "रिपोर्ट",
"createExport": "निर्यात सिर्जना",
"reportType": "रिपोर्ट प्रकार",
"exportFormat": "निर्यात ढाँचा",
"filterJson": "फिल्टर JSON (वैकल्पिक)",
"parseFilterFailed": "फिल्टर JSON पार्स गर्न सकिएन",
"createSuccess": "निर्यात कार्य सिर्जना भयो",
"createFailed": "कार्य सिर्जना असफल भयो",
"downloadFailed": "डाउनलोड असफल भयो",
"taskList": "कार्य सूची",
"jobId": "कार्य नं.",
"type": "प्रकार",
"format": "ढाँचा",
"status": "स्थिति",
"output": "आउटपुट",
"download": "डाउनलोड",
"createdAt": "सिर्जना समय",
"id": "ID",
"empty": "डाटा छैन",
"formatOptions": {
"csv": "CSV",
"xlsx": "Excel"
},
"statusOptions": {
"pending": "पेन्डिङ",
"queued": "पर्खाइमा",
"running": "चल्दैछ",
"completed": "सम्पन्न",
"failed": "असफल"
},
"reportTypes": {
"draw_profit_summary": "ड्रअ नाफा सारांश",
"daily_profit_summary": "दैनिक नाफा सारांश",
"player_win_loss": "खेलाडी जित/हार रिपोर्ट",
"wallet_transfer_report": "वालेट ट्रान्सफर रिपोर्ट",
"hot_number_risk_report": "हट नम्बर जोखिम रिपोर्ट",
"play_dimension_report": "प्ले डाइमेन्सन रिपोर्ट",
"sold_out_number_report": "बिक्री समाप्त नम्बर रिपोर्ट",
"rebate_commission_report": "रिबेट र कमिसन रिपोर्ट",
"audit_operation_report": "अडिट अपरेशन रिपोर्ट",
"wallet_txns_daily": "वालेट कारोबार दैनिक",
"transfer_orders_daily": "ट्रान्सफर अर्डर दैनिक"
}
}

View File

@@ -133,7 +133,6 @@
"jackpot": "奖池",
"reconcile": "对账",
"tickets": "玩家注单",
"reports": "报表导出",
"audit": "审计日志",
"settings": "系统设置"
},
@@ -141,6 +140,7 @@
"prd.admin_user.manage": "管理员列表·可管理",
"prd.admin_role.manage": "角色管理·可管理",
"prd.users.manage": "用户管理·可管理",
"prd.currency.manage": "币种管理·可管理",
"prd.users.view_finance": "用户管理·财务查看",
"prd.users.view_cs": "用户管理·客服单用户",
"prd.player_freeze.manage": "冻结/解冻玩家·可管理",
@@ -162,10 +162,6 @@
"prd.payout.manage": "派彩确认·可管理",
"prd.payout.review": "派彩确认·可审核",
"prd.payout.view": "派彩确认·查看",
"prd.report.all": "报表·全部",
"prd.report.risk": "报表·风控",
"prd.report.finance": "报表·财务",
"prd.report.player": "报表·单用户",
"prd.audit.all": "审计日志·全部",
"prd.audit.self": "审计日志·自身相关",
"prd.audit.finance": "审计日志·资金相关"

View File

@@ -62,6 +62,7 @@
"admin_users": "管理列表",
"admin_roles": "角色管理",
"players": "玩家列表",
"currencies": "币种管理",
"wallet": "钱包流水",
"draws": "期号列表",
"config": "运营配置",
@@ -70,7 +71,6 @@
"jackpot": "奖池",
"reconcile": "对账",
"tickets": "注单列表",
"reports": "报表导出",
"audit": "审计日志",
"settings": "系统设置"
},

View File

@@ -94,6 +94,54 @@
},
"discard": "放弃更改"
},
"currencies": {
"title": "币种管理",
"description": "维护后台可用的币种主数据,控制是否启用以及是否允许用于下注。",
"loading": "正在加载币种列表…",
"empty": "暂无币种。",
"loadFailed": "币种列表加载失败",
"createSuccess": "币种已创建",
"createFailed": "币种创建失败",
"updateSuccess": "币种已更新",
"updateFailed": "币种更新失败",
"deleteSuccess": "币种 {{code}} 已删除",
"deleteFailed": "币种删除失败",
"actions": {
"create": "新增币种",
"edit": "编辑",
"delete": "删除",
"openStandalone": "进入独立页面",
"backToSettings": "返回系统设置"
},
"table": {
"code": "代码",
"name": "名称",
"decimals": "小数位",
"enabled": "启用",
"bettable": "可下注",
"actions": "操作"
},
"dialog": {
"createTitle": "新增币种",
"editTitle": "编辑币种",
"description": "币种代码创建后不可修改;禁用币种时会自动关闭“可下注”。"
},
"deleteDialog": {
"title": "确认删除币种",
"description": "确定删除币种 {{code}} 吗?如果该币种已被默认配置、钱包、注单、赔率或奖池引用,系统会阻止删除。"
},
"form": {
"code": "币种代码",
"name": "币种名称",
"decimals": "小数位",
"enabled": "启用状态",
"enabledHint": "关闭后,新业务不应继续使用该币种。",
"bettable": "允许下注",
"bettableHint": "仅启用中的币种才可设置为可下注。",
"required": "请先填写必填字段",
"decimalInvalid": "请输入合法的小数位"
}
},
"play": {
"batchGroups": {
"d2": "2D 全局",

View File

@@ -46,7 +46,6 @@
"results": "开奖结果",
"tickets": "注单管理",
"walletTransactions": "钱包流水",
"reports": "报表中心",
"auditLogs": "审计日志"
},
"warnings": {

View File

@@ -1,36 +1,46 @@
{
"title": "对账",
"createTitle": "人工发起对账",
"createDesc": "用于按时间段或指定单据人工核对异常转账。系统定时对账仍会自动执行。",
"createDesc": "用于按日期范围并可选指定玩家,人工核对异常转账。系统定时对账仍会自动执行。",
"reconcileType": "对账类型",
"walletTransfer": "钱包划转(主站 ⇄ 彩票)",
"startTime": "对账开始时间",
"endTime": "对账结束时间",
"scope": "指定对象(可选)",
"scopePlaceholder": "每行一条:玩家 ID、划转单号或主站流水号。\n留空则核对所选时间段内的异常转账。",
"reconcileTypeFixed": "钱包划转(主站 ⇄ 彩票)",
"reconcileTypeHint": "当前仅支持钱包划转。",
"dateRange": "对账日期范围",
"createTask": "创建对账任务",
"submitting": "提交中…",
"loadFailed": "加载失败",
"loadItemsFailed": "加载明细失败",
"periodRequired": "请填写对账时间范围(开始与结束)",
"periodInvalid": "时间无效,请检查所选日期与时间",
"periodRequired": "请填写对账日期范围(开始与结束)",
"periodInvalid": "日期无效,请检查所选日期",
"periodOrderInvalid": "结束时间需晚于或等于开始时间",
"createSuccess": "已创建对账任务",
"createFailed": "创建失败",
"noCreatePermission": "当前账号无新建对账任务权限。",
"jobsTitle": "对账任务",
"jobsDesc": "点击一行查看差异明细与分页。",
"jobsDesc": "在右侧操作中查看差异明细与分页。",
"refresh": "刷新",
"jobNo": "任务号",
"type": "类型",
"status": "状态",
"period": "对账周期",
"createdAt": "创建时间",
"operate": "操作",
"view": "查看",
"detailsTitle": "任务明细",
"sideARef": "彩票侧引用",
"sideBRef": "主站侧引用",
"differenceAmount": "差额(分)",
"noDetails": "无明细",
"playerSearch": "指定玩家(可选)",
"playerSearchPlaceholder": "输入玩家 ID / 用户名 / 昵称搜索",
"playerSearchHint": "选择后只按该玩家核对所选日期范围内的异常转账。",
"playerSearchEmpty": "请输入关键词后选择玩家。",
"playerNoResults": "暂无匹配玩家",
"playerChoose": "选择",
"playerSelected": "已选玩家",
"playerSelectedShort": "已选",
"playerClear": "清除",
"loadingPlayers": "玩家搜索中…",
"statusCompleted": "已完成",
"statusRunning": "执行中",
"statusFailed": "失败",

View File

@@ -1,45 +0,0 @@
{
"title": "报表",
"createExport": "新建导出",
"reportType": "报表类型",
"exportFormat": "导出格式",
"filterJson": "筛选条件 JSON可选",
"parseFilterFailed": "筛选 JSON 无法解析",
"createSuccess": "已创建导出任务",
"createFailed": "创建失败",
"downloadFailed": "下载失败",
"taskList": "任务列表",
"jobId": "任务号",
"type": "类型",
"format": "格式",
"status": "状态",
"output": "输出",
"download": "下载",
"createdAt": "创建时间",
"id": "ID",
"empty": "无数据",
"formatOptions": {
"csv": "CSV",
"xlsx": "Excel"
},
"statusOptions": {
"pending": "待处理",
"queued": "排队中",
"running": "执行中",
"completed": "已完成",
"failed": "失败"
},
"reportTypes": {
"draw_profit_summary": "期号盈亏",
"daily_profit_summary": "每日盈亏汇总",
"player_win_loss": "玩家输赢报表",
"wallet_transfer_report": "玩家转入转出报表",
"hot_number_risk_report": "热门号码风险报表",
"play_dimension_report": "玩法维度报表",
"sold_out_number_report": "售罄号码报表",
"rebate_commission_report": "佣金回水报表",
"audit_operation_report": "后台操作审计报表",
"wallet_txns_daily": "钱包流水日报",
"transfer_orders_daily": "转账单日报"
}
}

View File

@@ -1,8 +1,35 @@
import { getCachedAdminCurrencies } from "@/hooks/use-admin-currency-catalog";
const DEFAULT_DECIMAL_PLACES = 2;
export function getAdminCurrencyDecimalPlaces(currencyCode: string | null | undefined): number {
const code = currencyCode?.trim().toUpperCase();
if (!code) {
return DEFAULT_DECIMAL_PLACES;
}
const row = getCachedAdminCurrencies().find((item) => item.code === code);
const decimals = row?.decimal_places;
if (typeof decimals === "number" && Number.isFinite(decimals) && decimals >= 0) {
return decimals;
}
return DEFAULT_DECIMAL_PLACES;
}
/** 后台列表统一:最小货币单位 → 主货币展示(默认 2 位小数,与钱包一致) */
export function formatAdminMinorUnits(minor: number, currencyCode = "NPR"): string {
const major = minor / 100;
export function formatAdminMinorUnits(
minor: number,
currencyCode = "NPR",
decimalPlaces?: number,
): string {
const resolvedDecimalPlaces =
typeof decimalPlaces === "number" && Number.isFinite(decimalPlaces) && decimalPlaces >= 0
? decimalPlaces
: getAdminCurrencyDecimalPlaces(currencyCode);
const major = minor / 10 ** resolvedDecimalPlaces;
return `${currencyCode} ${major.toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
minimumFractionDigits: resolvedDecimalPlaces,
maximumFractionDigits: resolvedDecimalPlaces,
})}`;
}

View File

@@ -1,7 +1,7 @@
import type { LucideIcon } from "lucide-react";
import {
CalendarClock,
FileSpreadsheet,
CircleDollarSign,
Landmark,
LayoutDashboard,
LogIn,
@@ -29,11 +29,11 @@ export const adminNavIconBySegment: Record<AdminNavItem["segment"], LucideIcon>
wallet: Wallet,
risk: ShieldAlert,
settlement: Landmark,
reports: FileSpreadsheet,
reconcile: Scale,
audit: ScrollText,
admin_users: ShieldCheck,
admin_roles: ShieldCheck,
currencies: CircleDollarSign,
settings: Settings,
};

View File

@@ -10,11 +10,11 @@ export type AdminNavSegment =
| "risk"
| "settings"
| "settlement"
| "reports"
| "reconcile"
| "audit"
| "admin_users"
| "admin_roles";
| "admin_roles"
| "currencies";
export type AdminNavItem = {
label: string;

View File

@@ -77,6 +77,10 @@ export function AdminRolesConsole(): React.ReactElement {
() => roles.find((role) => role.id === selectedRoleId) ?? null,
[roles, selectedRoleId],
);
const selectedPermissionSet = useMemo(
() => new Set(draftRolePermissions),
[draftRolePermissions],
);
const selectClassName = cn(
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base outline-none transition-colors",
@@ -141,6 +145,16 @@ export function AdminRolesConsole(): React.ReactElement {
});
}
function toggleGroupPermissions(slugs: string[], checked: boolean): void {
setDraftRolePermissions((prev) => {
if (checked) {
return Array.from(new Set([...prev, ...slugs])).sort();
}
const remove = new Set(slugs);
return prev.filter((value) => !remove.has(value));
});
}
function openCreateRole(): void {
setRoleMode("create");
setEditingRoleId(null);
@@ -182,6 +196,20 @@ export function AdminRolesConsole(): React.ReactElement {
}
}
function getGroupSelectionState(slugs: string[]): boolean | "indeterminate" {
if (slugs.length === 0) {
return false;
}
const selectedCount = slugs.filter((slug) => selectedPermissionSet.has(slug)).length;
if (selectedCount === 0) {
return false;
}
if (selectedCount === slugs.length) {
return true;
}
return "indeterminate";
}
async function saveRolePermissions(): Promise<void> {
if (!selectedRole) {
return;
@@ -381,68 +409,94 @@ export function AdminRolesConsole(): React.ReactElement {
<Dialog open={rolePermissionOpen} onOpenChange={handleRolePermissionDialogOpenChange}>
<DialogContent
showCloseButton
className="flex h-[min(86vh,780px)] !max-w-[min(760px,calc(100vw-2rem))] flex-col gap-0 overflow-hidden p-0"
className="flex h-[min(84vh,760px)] !max-w-[min(720px,calc(100vw-2rem))] flex-col gap-0 overflow-hidden rounded-2xl border bg-background p-0 shadow-2xl"
>
<DialogHeader className="shrink-0 space-y-1 border-b bg-background px-5 py-4 pr-12">
<DialogTitle className="text-base">{t("rolePermissionDialog.title")}</DialogTitle>
<DialogDescription>
<DialogTitle className="text-[15px] font-semibold tracking-tight text-foreground">
{t("rolePermissionDialog.title")}
</DialogTitle>
<DialogDescription className="text-sm text-muted-foreground">
{selectedRole ? selectedRole.name : null}
</DialogDescription>
</DialogHeader>
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain bg-muted/25 px-5 py-4">
<div className="space-y-3">
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain bg-muted/15 px-5 py-4">
<div className="overflow-hidden rounded-xl border border-border/70 bg-background">
{directPermissionGroups.map((group) => {
const isOpen = isDirectGroupOpen(group.key);
const groupSlugs = group.permissions.map((permission) => permission.slug);
const selectedCount = group.permissions.filter((permission) =>
draftRolePermissions.includes(permission.slug),
selectedPermissionSet.has(permission.slug),
).length;
const checkedState = getGroupSelectionState(groupSlugs);
return (
<section key={group.key} className="overflow-hidden rounded-lg border bg-background shadow-sm">
<button
type="button"
className="flex w-full items-center gap-3 border-b px-4 py-3 text-left text-sm hover:bg-muted/45"
onClick={() => toggleDirectGroup(group.key)}
>
<ChevronDown
aria-hidden
className={cn(
"size-4 shrink-0 text-muted-foreground transition-transform",
isOpen && "rotate-180",
)}
<div key={group.key} className={cn("border-b border-border/60 last:border-b-0", isOpen && "bg-muted/10")}>
<div className="flex items-center gap-3 px-4 py-3 text-sm transition-colors hover:bg-muted/20">
<button
type="button"
className="flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted"
onClick={() => toggleDirectGroup(group.key)}
aria-label={isOpen ? "收起" : "展开"}
>
<ChevronDown
aria-hidden
className={cn("size-4 transition-transform", isOpen && "rotate-180")}
/>
</button>
<Checkbox
checked={checkedState === true}
indeterminate={checkedState === "indeterminate"}
onCheckedChange={(value) => toggleGroupPermissions(groupSlugs, value === true)}
/>
<span className="min-w-0 flex-1 text-base font-semibold leading-none">
{permissionGroupLabel(group.key, group.label, t)}
</span>
<span className="shrink-0 rounded-full bg-muted px-2.5 py-1 tabular-nums text-xs font-medium text-muted-foreground">
<button
type="button"
className="min-w-0 flex-1 text-left"
onClick={() => toggleDirectGroup(group.key)}
>
<div className="flex min-w-0 items-center gap-2">
<span className="min-w-0 truncate text-[15px] font-medium leading-6 text-foreground">
{permissionGroupLabel(group.key, group.label, t)}
</span>
{group.permissions.length > 0 ? (
<span className="shrink-0 rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground">
{group.permissions.length}
</span>
) : null}
</div>
</button>
<span className="shrink-0 tabular-nums text-xs text-muted-foreground">
{selectedCount}/{group.permissions.length}
</span>
</button>
</div>
{isOpen ? (
<div className="divide-y">
{group.permissions.map((permission) => (
<div className="pb-2">
{group.permissions.map((permission, index) => (
<label
key={permission.slug}
className={cn(
"flex cursor-pointer items-start gap-3 px-4 py-3 text-sm transition-colors hover:bg-muted/35",
draftRolePermissions.includes(permission.slug) && "bg-muted/25",
"flex cursor-pointer items-start gap-3 px-4 py-2.5 text-sm transition-colors hover:bg-muted/20",
index === 0 && "border-t border-border/50",
selectedPermissionSet.has(permission.slug) && "bg-muted/20",
)}
>
<span className="mt-1 flex h-4 w-8 shrink-0 items-center">
<span className="h-px w-full bg-border/70" />
</span>
<Checkbox
className="mt-0.5"
checked={draftRolePermissions.includes(permission.slug)}
checked={selectedPermissionSet.has(permission.slug)}
onCheckedChange={(value) =>
toggleRolePermission(permission.slug, value === true)
}
/>
<span className="min-w-0 whitespace-normal break-words font-medium leading-6 text-foreground">
<span className="min-w-0 whitespace-normal break-words leading-6 text-foreground">
{permissionLabel(permission.slug, permission.name, t)}
</span>
</label>
))}
</div>
) : null}
</section>
</div>
);
})}
</div>

View File

@@ -44,7 +44,7 @@ export function AdminUsersConsole(): React.ReactElement {
const { t } = useTranslation(["adminUsers", "common"]);
const profile = useAdminProfile();
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [keyword, setKeyword] = useState("");
const [query, setQuery] = useState("");
@@ -365,7 +365,7 @@ export function AdminUsersConsole(): React.ReactElement {
<TableHead className="w-20 whitespace-nowrap">{t("table.status")}</TableHead>
<TableHead>{t("table.roles")}</TableHead>
<TableHead>{t("table.effective")}</TableHead>
<TableHead className="min-w-[11rem]">{t("table.actions")}</TableHead>
<TableHead className="w-[15rem] whitespace-nowrap text-center">{t("table.actions")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -414,8 +414,8 @@ export function AdminUsersConsole(): React.ReactElement {
</div>
</TableCell>
<TableCell className="tabular-nums">{row.effective_permissions.length}</TableCell>
<TableCell>
<div className="flex flex-wrap gap-1">
<TableCell className="text-center">
<div className="flex w-full flex-nowrap justify-center gap-1 whitespace-nowrap">
<Button
type="button"
size="sm"

View File

@@ -29,7 +29,7 @@ export function AuditLogsConsole(): React.ReactElement {
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [moduleCode, setModuleCode] = useState("");
const [actionCode, setActionCode] = useState("");
const [operatorType, setOperatorType] = useState("");

View File

@@ -5,41 +5,26 @@ import { usePathname } from "next/navigation";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
const LINKS: { href: string; key: string; match?: "exact" | "prefix" }[] = [
{ href: "/admin/config/plays", key: "plays" },
{ href: "/admin/config/odds", key: "odds" },
{ href: "/admin/config/rebate", key: "rebate" },
{ href: "/admin/config/risk-cap", key: "risk-cap" },
];
function linkActive(pathname: string, href: string, match: "exact" | "prefix"): boolean {
if (match === "exact") {
return pathname === href || pathname === `${href}/`;
}
return pathname === href || pathname.startsWith(`${href}/`);
}
import { CONFIG_NAV_GROUPS } from "@/modules/config/config-nav-model";
export function ConfigSubNav() {
const { t } = useTranslation("config");
const pathname = usePathname();
const links = CONFIG_NAV_GROUPS.flatMap((group) => group.items);
return (
<nav
className="flex flex-wrap gap-2 border-b border-border pb-3 mb-6"
aria-label={t("nav.aria")}
>
{LINKS.map(({ href, key, match = "prefix" }) => {
const active = linkActive(pathname, href, match);
<nav className="flex w-full flex-wrap items-end gap-1 border-b border-border/60 px-1" aria-label={t("nav.aria")}>
{links.map(({ href, key }) => {
const active = pathname === href || pathname.startsWith(`${href}/`);
return (
<Link
key={href}
href={href}
className={cn(
"rounded-md px-3 py-1.5 text-sm transition-colors",
"border-b-2 px-4 py-3 text-sm font-medium transition-colors",
active
? "bg-primary text-primary-foreground"
: "bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground",
? "border-primary text-primary"
: "border-transparent text-muted-foreground hover:border-border/80 hover:text-foreground",
)}
>
{t(`nav.items.${key}`)}

View File

@@ -5,7 +5,6 @@ import { Layers } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import {
Dialog,
DialogContent,
@@ -165,22 +164,23 @@ export function ConfigVersionSwitcher({
</SheetHeader>
</div>
<div className="border-b bg-white px-4 py-3">
<div className="grid grid-cols-3 gap-2">
<div className="flex flex-wrap gap-2">
{statusCounts.map((s) => (
<div key={s.status} className="rounded-xl border bg-white px-3 py-2">
<p className="text-[11px] font-medium text-slate-500">{s.label}</p>
<p className="mt-0.5 text-lg font-semibold tabular-nums text-slate-950">
{s.count}
</p>
<div
key={s.status}
className="inline-flex items-center gap-2 rounded-full border border-border/60 bg-background px-3 py-1.5 text-xs text-muted-foreground"
>
<span className="font-medium text-foreground/80">{s.label}</span>
<span className="font-mono tabular-nums">{s.count}</span>
</div>
))}
</div>
</div>
<div className="flex-1 overflow-auto space-y-5 px-4 py-4">
<div className="flex-1 overflow-auto px-4 py-4">
{sortedVersions.length === 0 ? (
<Card className="border-dashed border-slate-200 bg-white/80 p-5 text-center text-sm text-slate-500 shadow-none">
<div className="rounded-2xl border border-dashed border-border/60 bg-white/70 p-5 text-center text-sm text-muted-foreground">
{t("versionSwitcher.empty", { ns: "config" })}
</Card>
</div>
) : (
STATUS_ORDER.map((status) => {
const rows = groupedVersions.get(status) ?? [];
@@ -188,8 +188,8 @@ export function ConfigVersionSwitcher({
return null;
}
return (
<section key={status} className="space-y-2.5">
<div className="flex items-center justify-between px-1">
<section key={status} className="border-b border-border/60 pb-4 last:border-b-0 last:pb-0">
<div className="mb-2 flex items-center justify-between px-1">
<div className="flex items-center gap-2.5">
<div
className={cn(
@@ -199,111 +199,109 @@ export function ConfigVersionSwitcher({
status === "archived" && "bg-slate-400 shadow-slate-100",
)}
/>
<p className="text-[15px] font-semibold text-slate-950">
<p className="text-[15px] font-semibold text-foreground">
{t(`versionStatus.${status}`, { ns: "config" })}
</p>
</div>
<p className="rounded-full bg-white px-2 py-0.5 text-xs font-medium tabular-nums text-slate-500 ring-1 ring-slate-200">
<p className="rounded-full bg-muted/50 px-2 py-0.5 text-xs font-medium tabular-nums text-muted-foreground">
{t("versionSwitcher.count", { ns: "config", count: rows.length })}
</p>
</div>
<div className="space-y-2.5">
<div className="space-y-1.5">
{rows.map((v) => {
const isCurrent = selectedId === String(v.id);
return (
<Card
<div
key={v.id}
className={cn(
"group overflow-hidden rounded-2xl border bg-white p-0 shadow-none transition-colors hover:border-slate-300",
isCurrent && "border-slate-900 ring-1 ring-slate-900/10",
"group flex gap-3 rounded-xl border border-transparent px-2 py-3 transition-colors hover:bg-muted/30",
isCurrent && "border-border/60 bg-muted/20",
)}
>
<div className="flex gap-3 p-3.5">
<div
className={cn(
"mt-1 h-auto w-1 shrink-0 rounded-full bg-slate-200",
v.status === "draft" && "bg-amber-300",
v.status === "active" && "bg-emerald-400",
v.status === "archived" && "bg-slate-300",
)}
/>
<div className="min-w-0 flex-1 space-y-3">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0 space-y-1.5">
<div className="flex flex-wrap items-center gap-2">
<span className="font-mono text-lg font-semibold leading-none tabular-nums text-slate-950">
v{v.version_no}
</span>
<ConfigStatusBadge status={v.status} />
<span className="rounded-full bg-slate-100 px-2 py-0.5 text-xs font-medium tabular-nums text-slate-500">
#{v.id}
</span>
</div>
<p className="line-clamp-2 text-[13px] leading-5 text-slate-500">
{t("versionSwitcher.effectiveAt", {
ns: "config",
value: v.effective_at ? formatDt(v.effective_at) : "—",
})}
{v.reason
? ` · ${t("versionSwitcher.note", {
ns: "config",
value: v.reason,
})}`
: ""}
</p>
</div>
{isCurrent ? (
<span className="shrink-0 rounded-full bg-slate-950 px-2.5 py-1 text-xs font-medium text-white shadow-sm">
{t("versionSwitcher.current", { ns: "config" })}
<div
className={cn(
"mt-1 h-auto w-1 shrink-0 rounded-full bg-slate-200",
v.status === "draft" && "bg-amber-300",
v.status === "active" && "bg-emerald-400",
v.status === "archived" && "bg-slate-300",
)}
/>
<div className="min-w-0 flex-1 space-y-2">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0 space-y-1.5">
<div className="flex flex-wrap items-center gap-2">
<span className="font-mono text-lg font-semibold leading-none tabular-nums text-foreground">
v{v.version_no}
</span>
) : null}
<ConfigStatusBadge status={v.status} />
<span className="rounded-full bg-muted px-2 py-0.5 text-xs font-medium tabular-nums text-muted-foreground">
#{v.id}
</span>
</div>
<p className="line-clamp-2 text-[13px] leading-5 text-muted-foreground">
{t("versionSwitcher.effectiveAt", {
ns: "config",
value: v.effective_at ? formatDt(v.effective_at) : "—",
})}
{v.reason
? ` · ${t("versionSwitcher.note", {
ns: "config",
value: v.reason,
})}`
: ""}
</p>
</div>
<div className="flex flex-wrap items-center gap-2 border-t border-slate-100 pt-3">
{isCurrent ? (
<span className="shrink-0 rounded-full bg-foreground px-2.5 py-1 text-xs font-medium text-background">
{t("versionSwitcher.current", { ns: "config" })}
</span>
) : null}
</div>
<div className="flex flex-wrap items-center gap-2">
<Button
type="button"
variant={isCurrent ? "secondary" : "outline"}
size="sm"
className={cn(
"h-8 rounded-full px-3 text-xs",
isCurrent && "bg-muted text-muted-foreground hover:bg-muted",
)}
onClick={() => switchTo(v.id)}
>
{isCurrent
? t("versionSwitcher.selected", { ns: "config" })
: t("versionSwitcher.view", { ns: "config" })}
</Button>
{onRollbackVersion && v.status !== "draft" ? (
<Button
type="button"
variant={isCurrent ? "secondary" : "outline"}
variant="ghost"
size="sm"
className={cn(
"h-8 rounded-full px-3 text-xs",
isCurrent && "bg-slate-100 text-slate-500 hover:bg-slate-100",
)}
onClick={() => switchTo(v.id)}
className="rounded-full text-xs text-muted-foreground hover:bg-muted hover:text-foreground"
disabled={rollbackBusy}
onClick={() => {
onRollbackVersion(v);
setSheetOpen(false);
}}
>
{isCurrent
? t("versionSwitcher.selected", { ns: "config" })
: t("versionSwitcher.view", { ns: "config" })}
{t("versionSwitcher.rollback", { ns: "config" })}
</Button>
{onRollbackVersion && v.status !== "draft" ? (
<Button
type="button"
variant="ghost"
size="sm"
className="rounded-full text-xs text-slate-600 hover:bg-slate-100 hover:text-slate-950"
disabled={rollbackBusy}
onClick={() => {
onRollbackVersion(v);
setSheetOpen(false);
}}
>
{t("versionSwitcher.rollback", { ns: "config" })}
</Button>
) : null}
{onDeleteVersion && v.status !== "active" ? (
<Button
type="button"
variant="ghost"
size="sm"
className="rounded-full text-xs text-rose-600 hover:bg-rose-50 hover:text-rose-700"
disabled={deletingId === v.id}
onClick={() => setDeleteTarget(v)}
>
{t("versionSwitcher.delete", { ns: "config" })}
</Button>
) : null}
</div>
) : null}
{onDeleteVersion && v.status !== "active" ? (
<Button
type="button"
variant="ghost"
size="sm"
className="rounded-full text-xs text-rose-600 hover:bg-rose-50 hover:text-rose-700"
disabled={deletingId === v.id}
onClick={() => setDeleteTarget(v)}
>
{t("versionSwitcher.delete", { ns: "config" })}
</Button>
) : null}
</div>
</div>
</Card>
</div>
);
})}
</div>

View File

@@ -1,88 +1,16 @@
"use client";
import type { ReactNode } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
import { CONFIG_NAV_GROUPS } from "@/modules/config/config-nav-model";
function navLinkActive(pathname: string, href: string): boolean {
return pathname === href || pathname.startsWith(`${href}/`);
}
import { ConfigSubNav } from "@/modules/config/config-subnav";
export function ConfigWorkspaceShell({ children }: { children: ReactNode }) {
const { t } = useTranslation("config");
const pathname = usePathname() ?? "";
return (
<div className="mx-auto flex w-full max-w-7xl flex-col gap-6">
<div className="flex flex-col gap-6 lg:flex-row lg:items-start">
<aside className="shrink-0 lg:sticky lg:top-[72px] lg:w-56 lg:self-start">
<div className="rounded-2xl border border-border/70 bg-card/80 p-3 shadow-sm backdrop-blur lg:max-h-[calc(100vh-7rem)] lg:overflow-y-auto">
<div className="mb-3 px-1">
<p className="text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground">
{t("nav.sidebarTitle")}
</p>
</div>
<nav className="hidden space-y-3 lg:block" aria-label={t("nav.aria")}>
{CONFIG_NAV_GROUPS.map((group) => (
<div key={group.id} className="space-y-1.5">
<p className="px-2 text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground">
{t(`nav.groups.${group.id}`)}
</p>
<ul className="space-y-1">
{group.items.map((item) => {
const active = navLinkActive(pathname, item.href);
return (
<li key={item.href}>
<Link
href={item.href}
className={cn(
"block rounded-xl border px-3 py-2.5 text-sm transition-all outline-none ring-offset-background focus-visible:ring-2 focus-visible:ring-ring",
active
? "border-primary/20 bg-primary/10 text-primary shadow-sm"
: "border-transparent bg-transparent text-foreground hover:border-border hover:bg-muted/60",
)}
>
<div className="font-medium">{t(`nav.items.${item.key}`)}</div>
</Link>
</li>
);
})}
</ul>
</div>
))}
</nav>
<div className="lg:hidden overflow-x-auto pb-1 -mx-1 px-1">
<div className="flex w-max gap-2">
{CONFIG_NAV_GROUPS.flatMap((g) => g.items).map((item) => {
const active = navLinkActive(pathname, item.href);
return (
<Link
key={`m-${item.href}`}
href={item.href}
className={cn(
"shrink-0 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors whitespace-nowrap",
active
? "border-primary bg-primary/10 text-primary"
: "border-border bg-background text-foreground hover:bg-muted/60",
)}
>
{t(`nav.items.${item.key}`)}
</Link>
);
})}
</div>
</div>
</div>
</aside>
<div className="min-w-0 flex-1">{children}</div>
<div className="mx-auto flex w-full max-w-[1680px] flex-col gap-6 px-4 py-5 sm:px-6 lg:px-8 lg:py-6">
<div className="sticky top-14 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">
<ConfigSubNav />
</div>
<div className="min-w-0">{children}</div>
</div>
);
}

View File

@@ -445,32 +445,30 @@ export function OddsConfigDocScreen() {
</div>
</div>
<div className="rounded-xl border bg-muted/20 p-3">
<div className="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
<ConfigVersionSwitcher
versions={list}
selectedId={selectedId}
onSelectedIdChange={setSelectedId}
loading={loadingList}
sheetTitle={`${t("nav.items.odds", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
sheetDescription={t("odds.sheetDescription", { ns: "config" })}
onDeleteVersion={handleDeleteVersion}
onRollbackVersion={requestRollback}
rollbackBusy={saving}
className="lg:flex-1"
/>
<div className="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
<ConfigVersionSwitcher
versions={list}
selectedId={selectedId}
onSelectedIdChange={setSelectedId}
loading={loadingList}
sheetTitle={`${t("nav.items.odds", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
sheetDescription={t("odds.sheetDescription", { ns: "config" })}
onDeleteVersion={handleDeleteVersion}
onRollbackVersion={requestRollback}
rollbackBusy={saving}
className="lg:flex-1"
/>
<ConfigVersionActions
isDraft={isDraft}
loadingList={loadingList}
loadingDetail={loadingDetail}
saving={saving}
onRefresh={() => void refreshList()}
onNewDraft={() => void handleNewDraft()}
onSaveDraft={() => void handleSave()}
onPublish={() => void requestPublishConfirm()}
/>
</div>
<ConfigVersionActions
isDraft={isDraft}
loadingList={loadingList}
loadingDetail={loadingDetail}
saving={saving}
onRefresh={() => void refreshList()}
onNewDraft={() => void handleNewDraft()}
onSaveDraft={() => void handleSave()}
onPublish={() => void requestPublishConfirm()}
/>
</div>
{detail ? (

View File

@@ -380,29 +380,27 @@ export function PlayConfigDocScreen() {
<CardTitle className="text-lg">{t("nav.items.plays", { ns: "config" })}</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="rounded-xl border bg-muted/20 p-3">
<div className="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
<ConfigVersionSwitcher
versions={list}
selectedId={selectedId}
onSelectedIdChange={setSelectedId}
loading={loadingList}
sheetTitle={`${t("nav.items.plays", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
onDeleteVersion={handleDeleteVersion}
className="lg:flex-1"
/>
<div className="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
<ConfigVersionSwitcher
versions={list}
selectedId={selectedId}
onSelectedIdChange={setSelectedId}
loading={loadingList}
sheetTitle={`${t("nav.items.plays", { ns: "config" })} ${t("versionSwitcher.sheetTitle", { ns: "config" })}`}
onDeleteVersion={handleDeleteVersion}
className="lg:flex-1"
/>
<ConfigVersionActions
isDraft={isDraft}
loadingList={loadingList}
loadingDetail={loadingDetail}
saving={saving}
onRefresh={() => void refreshList()}
onNewDraft={() => void handleNewDraft()}
onSaveDraft={() => void handleSaveDraft()}
onPublish={() => void handlePublish()}
/>
</div>
<ConfigVersionActions
isDraft={isDraft}
loadingList={loadingList}
loadingDetail={loadingDetail}
saving={saving}
onRefresh={() => void refreshList()}
onNewDraft={() => void handleNewDraft()}
onSaveDraft={() => void handleSaveDraft()}
onPublish={() => void handlePublish()}
/>
</div>
{detail ? (
@@ -423,11 +421,9 @@ export function PlayConfigDocScreen() {
) : null}
{detail ? (
<div className="rounded-xl border bg-muted/20 p-3">
<div className="mb-3 flex flex-wrap items-center justify-between gap-2">
<div>
<p className="text-sm font-medium">{t("play.batchSwitchesTitle", { ns: "config" })}</p>
</div>
<div className="space-y-3">
<div className="flex flex-wrap items-center justify-between gap-2">
<p className="text-sm font-medium">{t("play.batchSwitchesTitle", { ns: "config" })}</p>
{!isDraft ? (
<span className="text-xs text-amber-600 dark:text-amber-400">
{t("play.readOnlyDraftHint", { ns: "config" })}
@@ -438,7 +434,7 @@ export function PlayConfigDocScreen() {
{batchSwitchStates.map((group) => (
<div
key={group.key}
className="flex items-center gap-2 rounded-lg border bg-background px-3 py-2"
className="flex items-center gap-2 rounded-xl border border-border/60 bg-background/70 px-3 py-2"
>
<div className="min-w-[92px]">
<p className="text-sm font-medium">{group.label}</p>
@@ -474,8 +470,7 @@ export function PlayConfigDocScreen() {
{loadingDetail ? (
<p className="text-sm text-muted-foreground">{t("states.loading", { ns: "common" })}</p>
) : (
<div className="overflow-x-auto rounded-md border">
<Table>
<Table>
<TableHeader>
<TableRow>
<TableHead className="text-center">{t("play.table.playCode", { ns: "config" })}</TableHead>
@@ -606,8 +601,7 @@ export function PlayConfigDocScreen() {
</TableRow>
))}
</TableBody>
</Table>
</div>
</Table>
)}
</CardContent>

View File

@@ -365,7 +365,7 @@ export function RebateConfigDocScreen() {
</div>
</div>
<div className="flex items-start gap-3 rounded-lg border bg-muted/30 p-4">
<div className="flex items-start gap-3 px-1">
<Checkbox
id="win-enjoy"
checked

View File

@@ -374,7 +374,7 @@ export function RiskCapDocScreen() {
{error ? <p className="text-sm text-destructive">{error}</p> : null}
<section className="space-y-3 rounded-lg border bg-muted/20 p-4">
<section className="space-y-3">
<h3 className="text-sm font-medium">{t("riskCap.defaultCap.title", { ns: "config" })}</h3>
<div className="flex flex-wrap items-end gap-2">
<div className="grid gap-1">
@@ -422,8 +422,7 @@ export function RiskCapDocScreen() {
) : specialRows.length === 0 ? (
<p className="text-sm text-muted-foreground">{t("riskCap.noDetailRows", { ns: "config" })}</p>
) : (
<div className="overflow-x-auto rounded-md border">
<Table>
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[110px]">{t("riskCap.table.number", { ns: "config" })}</TableHead>
@@ -492,9 +491,8 @@ export function RiskCapDocScreen() {
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</TableBody>
</Table>
)}
</section>
@@ -522,8 +520,7 @@ export function RiskCapDocScreen() {
{t("riskCap.actions.exportCsv", { ns: "config" })}
</Button>
</div>
<div className="overflow-x-auto rounded-md border">
<Table>
<Table>
<TableHeader>
<TableRow>
<TableHead>{t("riskCap.table.number", { ns: "config" })}</TableHead>
@@ -551,7 +548,6 @@ export function RiskCapDocScreen() {
))}
</TableBody>
</Table>
</div>
</section>
</CardContent>

View File

@@ -42,7 +42,11 @@ interface Draft {
outMax: string;
}
export function WalletConfigDocScreen() {
type WalletConfigDocScreenProps = {
embedded?: boolean;
};
export function WalletConfigDocScreen({ embedded = false }: WalletConfigDocScreenProps) {
const { t } = useTranslation(["config", "adminUsers"]);
const [draft, setDraft] = useState<Draft>({
inMin: "",
@@ -109,83 +113,91 @@ export function WalletConfigDocScreen() {
}
};
const content = (
<>
<div className="grid gap-5 sm:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="in-min">{t("wallet.fields.inMin", { ns: "config" })}</Label>
<Input
id="in-min"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.min", { ns: "config" })}
value={draft.inMin}
onChange={(e) => handleChange("inMin", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="in-max">{t("wallet.fields.inMax", { ns: "config" })}</Label>
<Input
id="in-max"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.max", { ns: "config" })}
value={draft.inMax}
onChange={(e) => handleChange("inMax", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="out-min">{t("wallet.fields.outMin", { ns: "config" })}</Label>
<Input
id="out-min"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.min", { ns: "config" })}
value={draft.outMin}
onChange={(e) => handleChange("outMin", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="out-max">{t("wallet.fields.outMax", { ns: "config" })}</Label>
<Input
id="out-max"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.max", { ns: "config" })}
value={draft.outMax}
onChange={(e) => handleChange("outMax", e.target.value)}
disabled={loading || saving}
/>
</div>
</div>
<div className="flex items-center gap-4 pt-2">
<Button onClick={() => void handleSave()} disabled={!dirty || loading || saving}>
{saving ? t("saving", { ns: "adminUsers" }) : t("actions.save", { ns: "adminUsers" })}
</Button>
{dirty && (
<Button
variant="outline"
onClick={() => {
setDraft(saved);
setDirty(false);
}}
>
{t("wallet.discard", { ns: "config" })}
</Button>
)}
</div>
</>
);
if (embedded) {
return content;
}
return (
<Card>
<CardHeader>
<CardTitle>{t("wallet.title", { ns: "config" })}</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<div className="grid gap-6 sm:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="in-min">{t("wallet.fields.inMin", { ns: "config" })}</Label>
<Input
id="in-min"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.min", { ns: "config" })}
value={draft.inMin}
onChange={(e) => handleChange("inMin", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="in-max">{t("wallet.fields.inMax", { ns: "config" })}</Label>
<Input
id="in-max"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.max", { ns: "config" })}
value={draft.inMax}
onChange={(e) => handleChange("inMax", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="out-min">{t("wallet.fields.outMin", { ns: "config" })}</Label>
<Input
id="out-min"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.min", { ns: "config" })}
value={draft.outMin}
onChange={(e) => handleChange("outMin", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="out-max">{t("wallet.fields.outMax", { ns: "config" })}</Label>
<Input
id="out-max"
type="number"
min="0"
step="0.01"
placeholder={t("wallet.placeholders.max", { ns: "config" })}
value={draft.outMax}
onChange={(e) => handleChange("outMax", e.target.value)}
disabled={loading || saving}
/>
</div>
</div>
<div className="flex items-center gap-4">
<Button onClick={() => void handleSave()} disabled={!dirty || loading || saving}>
{saving ? t("saving", { ns: "adminUsers" }) : t("actions.save", { ns: "adminUsers" })}
</Button>
{dirty && (
<Button
variant="outline"
onClick={() => {
setDraft(saved);
setDirty(false);
}}
>
{t("wallet.discard", { ns: "config" })}
</Button>
)}
</div>
</CardContent>
<CardContent className="space-y-6">{content}</CardContent>
</Card>
);
}

View File

@@ -10,7 +10,6 @@ import {
ClipboardList,
Diamond,
FileSearch,
FileSpreadsheet,
Gift,
RefreshCw,
ScrollText,
@@ -25,6 +24,8 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button, buttonVariants } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { formatAdminMinorUnits, getAdminCurrencyDecimalPlaces } from "@/lib/money";
import { cn } from "@/lib/utils";
import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminDrawFinanceSummaryData } from "@/types/api/admin-draw-finance";
@@ -42,20 +43,18 @@ type SoldOutBuckets = {
};
function formatMoneyMinor(minor: number, currencyCode: string | null): string {
const major = minor / 100;
const code = (currencyCode ?? "CNY").toUpperCase();
const code = (currencyCode ?? "NPR").toUpperCase();
const decimals = getAdminCurrencyDecimalPlaces(code);
const major = minor / 10 ** decimals;
try {
return new Intl.NumberFormat("zh-CN", {
style: "currency",
currency: code,
maximumFractionDigits: 2,
minimumFractionDigits: decimals,
maximumFractionDigits: decimals,
}).format(major);
} catch {
return new Intl.NumberFormat("zh-CN", {
style: "currency",
currency: "CNY",
maximumFractionDigits: 2,
}).format(major);
return formatAdminMinorUnits(minor, code, decimals);
}
}
@@ -251,6 +250,7 @@ function SoldOutDonut({ buckets }: { buckets: SoldOutBuckets }): ReactElement {
export function DashboardConsole(): ReactElement {
const { t } = useTranslation(["dashboard", "common"]);
useAdminCurrencyCatalog();
const [todayLabel] = useState(() => format(new Date(), "yyyy-MM-dd EEEE", { locale: zhCN }));
const [loading, setLoading] = useState(true);
const [refreshing, setRefreshing] = useState(false);
@@ -352,7 +352,6 @@ export function DashboardConsole(): ReactElement {
},
{ href: "/admin/tickets", label: t("quickLinks.tickets"), icon: <Shield className="size-5" /> },
{ href: "/admin/wallet/transactions", label: t("quickLinks.walletTransactions"), icon: <Wallet className="size-5" /> },
{ href: "/admin/reports", label: t("quickLinks.reports"), icon: <FileSpreadsheet className="size-5" /> },
{ href: "/admin/audit-logs", label: t("quickLinks.auditLogs"), icon: <ScrollText className="size-5" /> },
];

View File

@@ -76,7 +76,7 @@ export function DrawsIndexConsole() {
const [appliedDrawNo, setAppliedDrawNo] = useState("");
const [appliedStatus, setAppliedStatus] = useState("");
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState<number>(20);
const [perPage, setPerPage] = useState<number>(10);
const [generating, setGenerating] = useState(false);
const drawStatusTriggerLabel = useMemo(

View File

@@ -35,11 +35,11 @@ export function JackpotRecordsConsole() {
const [payouts, setPayouts] = useState<AdminJackpotPayoutLogsData | null>(null);
const [pPage, setPPage] = useState(1);
const [pPer, setPPer] = useState(15);
const [pPer, setPPer] = useState(10);
const [contribs, setContribs] = useState<AdminJackpotContributionsData | null>(null);
const [cPage, setCPage] = useState(1);
const [cPer, setCPer] = useState(15);
const [cPer, setCPer] = useState(10);
const [loadingP, setLoadingP] = useState(true);
const [loadingC, setLoadingC] = useState(true);

View File

@@ -41,6 +41,8 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { formatAdminMinorUnits } from "@/lib/money";
import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminPlayerRow } from "@/types/api/admin-player";
@@ -60,11 +62,6 @@ function playerStatusVariant(
return "default";
}
function formatMinorUnits(minor: number, currencyCode: string): string {
const major = minor / 100;
return `${major.toFixed(2)} ${currencyCode}`;
}
const PLAYER_STATUS_OPTIONS = [
{ value: 0, label: "statusNormal" },
{ value: 1, label: "statusFrozen" },
@@ -74,9 +71,10 @@ const PLAYER_STATUS_OPTIONS = [
export function PlayersConsole(): React.ReactElement {
const { t } = useTranslation(["players", "common"]);
const profile = useAdminProfile();
useAdminCurrencyCatalog();
const canManagePlayers = adminHasAnyPermission(profile?.permissions, ["prd.users.manage"]);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [keyword, setKeyword] = useState("");
const [query, setQuery] = useState("");
@@ -206,6 +204,9 @@ export function PlayersConsole(): React.ReactElement {
if (formNickname !== editingPlayer?.nickname) {
body.nickname = formNickname.trim() || null;
}
if (formDefaultCurrency !== editingPlayer?.default_currency) {
body.default_currency = formDefaultCurrency.trim().toUpperCase();
}
if (formStatus !== editingPlayer?.status) {
body.status = formStatus;
}
@@ -344,12 +345,12 @@ export function PlayersConsole(): React.ReactElement {
<TableCell>{row.default_currency}</TableCell>
<TableCell className="whitespace-nowrap text-right tabular-nums text-xs">
{row.wallets.length > 0
? formatMinorUnits(row.wallets[0].balance, row.wallets[0].currency_code)
? formatAdminMinorUnits(row.wallets[0].balance, row.wallets[0].currency_code)
: "—"}
</TableCell>
<TableCell className="whitespace-nowrap text-right tabular-nums text-xs">
{row.wallets.length > 0
? formatMinorUnits(row.wallets[0].available_balance, row.wallets[0].currency_code)
? formatAdminMinorUnits(row.wallets[0].available_balance, row.wallets[0].currency_code)
: "—"}
</TableCell>
<TableCell>

View File

@@ -9,19 +9,15 @@ import {
getAdminReconcileJobs,
postAdminReconcileJob,
} from "@/api/admin-reconcile";
import { getAdminPlayers } from "@/api/admin-player";
import { AdminDateRangeField } from "@/components/admin/admin-date-range-field";
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import {
Table,
TableBody,
@@ -30,11 +26,12 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { Textarea } from "@/components/ui/textarea";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { cn } from "@/lib/utils";
import { useAdminProfile } from "@/stores/admin-session";
import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminPlayerRow } from "@/types/api/admin-player";
import type {
AdminReconcileItemsData,
AdminReconcileJobListData,
@@ -43,12 +40,7 @@ import type {
const MANAGE = ["prd.wallet_reconcile.manage"] as const;
/** 与后端 reconcile_type 对齐;扩展时在 API 与下拉同步增加 */
const RECONCILE_TYPE_OPTIONS = [{ value: "wallet_transfer", label: "walletTransfer" }] as const;
function reconcileTypeLabel(slug: string, t: (key: string) => string): string {
const hit = RECONCILE_TYPE_OPTIONS.find((o) => o.value === slug);
return hit ? t(hit.label) : slug;
}
const RECONCILE_TYPE = "wallet_transfer" as const;
function jobStatusLabel(status: string, t: (key: string) => string): string {
switch (status) {
@@ -76,34 +68,13 @@ function itemStatusLabel(status: string, t: (key: string) => string): string {
}
}
function toIsoFromDatetimeLocal(local: string): string | null {
const t = local.trim();
if (t === "") {
return null;
function reconcileTypeLabel(type: string, t: (key: string) => string): string {
switch (type) {
case "wallet_transfer":
return t("reconcileTypeWalletTransfer");
default:
return type;
}
const d = new Date(t);
if (Number.isNaN(d.getTime())) {
return null;
}
return d.toISOString();
}
function scopeLinesToItems(
raw: string,
): NonNullable<Parameters<typeof postAdminReconcileJob>[0]["items"]> | undefined {
const lines = raw
.split(/\r?\n/)
.map((s) => s.trim())
.filter(Boolean);
if (lines.length === 0) {
return undefined;
}
return lines.map((side_a_ref) => ({
side_a_ref,
side_b_ref: null,
difference_amount: 0,
status: "pending_check",
}));
}
export function ReconcileConsole(): React.ReactElement {
@@ -116,18 +87,21 @@ export function ReconcileConsole(): React.ReactElement {
const [jobsLoading, setJobsLoading] = useState(true);
const [jobsErr, setJobsErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [selectedId, setSelectedId] = useState<number | null>(null);
const [detailOpen, setDetailOpen] = useState(false);
const [items, setItems] = useState<AdminReconcileItemsData | null>(null);
const [itemsPage, setItemsPage] = useState(1);
const [itemsPerPage, setItemsPerPage] = useState(50);
const [itemsPerPage, setItemsPerPage] = useState(10);
const [itemsLoading, setItemsLoading] = useState(false);
const [reconcileType, setReconcileType] = useState<string>(RECONCILE_TYPE_OPTIONS[0].value);
const [periodStartLocal, setPeriodStartLocal] = useState("");
const [periodEndLocal, setPeriodEndLocal] = useState("");
const [scopeLines, setScopeLines] = useState("");
const [dateFrom, setDateFrom] = useState("");
const [dateTo, setDateTo] = useState("");
const [playerSearch, setPlayerSearch] = useState("");
const [playerResults, setPlayerResults] = useState<AdminPlayerRow[]>([]);
const [playerLoading, setPlayerLoading] = useState(false);
const [selectedPlayer, setSelectedPlayer] = useState<AdminPlayerRow | null>(null);
const [submitting, setSubmitting] = useState(false);
const loadJobs = useCallback(async () => {
@@ -176,35 +150,59 @@ export function ReconcileConsole(): React.ReactElement {
});
}, [loadItems]);
const loadPlayers = useCallback(async (keyword: string) => {
const q = keyword.trim();
if (q === "") {
setPlayerResults([]);
return;
}
setPlayerLoading(true);
try {
const data = await getAdminPlayers({ page: 1, per_page: 8, keyword: q });
setPlayerResults(data.items);
} catch {
setPlayerResults([]);
} finally {
setPlayerLoading(false);
}
}, []);
useEffect(() => {
const q = playerSearch.trim();
if (q === "") {
return;
}
const timer = window.setTimeout(() => {
void loadPlayers(q);
}, 250);
return () => window.clearTimeout(timer);
}, [loadPlayers, playerSearch]);
async function onCreate(): Promise<void> {
if (!periodStartLocal.trim() || !periodEndLocal.trim()) {
if (!dateFrom.trim() || !dateTo.trim()) {
toast.error(t("periodRequired"));
return;
}
const periodStartIso = toIsoFromDatetimeLocal(periodStartLocal);
const periodEndIso = toIsoFromDatetimeLocal(periodEndLocal);
if (periodStartIso == null || periodEndIso == null) {
toast.error(t("periodInvalid"));
return;
}
if (new Date(periodStartIso).getTime() > new Date(periodEndIso).getTime()) {
if (dateFrom > dateTo) {
toast.error(t("periodOrderInvalid"));
return;
}
const itemsPayload = scopeLinesToItems(scopeLines);
setSubmitting(true);
try {
await postAdminReconcileJob({
reconcile_type: reconcileType,
period_start: periodStartIso,
period_end: periodEndIso,
items: itemsPayload,
reconcile_type: RECONCILE_TYPE,
date_from: dateFrom,
date_to: dateTo,
player_id: selectedPlayer ? selectedPlayer.id : null,
});
toast.success(t("createSuccess"));
setPage(1);
setScopeLines("");
setDateFrom("");
setDateTo("");
setPlayerSearch("");
setSelectedPlayer(null);
setPlayerResults([]);
await loadJobs();
} catch (e) {
toast.error(e instanceof LotteryApiBizError ? e.message : t("createFailed"));
@@ -215,6 +213,7 @@ export function ReconcileConsole(): React.ReactElement {
const jm = jobs?.meta;
const im = items?.meta;
const selectedJob = jobs?.items.find((job) => job.id === selectedId) ?? null;
return (
<div className="flex w-full max-w-none flex-col gap-6">
@@ -222,65 +221,104 @@ export function ReconcileConsole(): React.ReactElement {
<Card className="admin-list-card">
<CardHeader className="admin-list-header">
<CardTitle className="admin-list-title">{t("createTitle")}</CardTitle>
<CardDescription className="mt-1">{t("createDesc")}</CardDescription>
</CardHeader>
<CardContent className="admin-list-content pt-4">
<div className="grid gap-4 lg:grid-cols-[minmax(220px,0.9fr)_minmax(180px,0.7fr)_minmax(180px,0.7fr)_auto] lg:items-end">
<div className="grid gap-4 lg:grid-cols-[minmax(220px,0.9fr)_minmax(220px,0.95fr)_auto] lg:items-end">
<div className="grid gap-1.5">
<Label htmlFor="rc-type">{t("reconcileType")}</Label>
<Select
modal={false}
value={reconcileType}
onValueChange={(v) => {
if (v != null && v !== "") {
setReconcileType(v);
}
}}
>
<SelectTrigger id="rc-type" className="w-full">
<SelectValue>{reconcileTypeLabel(reconcileType, t)}</SelectValue>
</SelectTrigger>
<SelectContent align="start">
{RECONCILE_TYPE_OPTIONS.map((o) => (
<SelectItem key={o.value} value={o.value}>
{t(o.label)}
</SelectItem>
))}
</SelectContent>
</Select>
<Label htmlFor="rc-type">{t("reconcileType")}</Label>
<Input id="rc-type" value={t("reconcileTypeFixed")} readOnly className="bg-muted/30" />
</div>
<div className="grid gap-1.5">
<Label htmlFor="rc-start">{t("startTime")}</Label>
<Input
id="rc-start"
type="datetime-local"
value={periodStartLocal}
onChange={(e) => setPeriodStartLocal(e.target.value)}
/>
</div>
<div className="grid gap-1.5">
<Label htmlFor="rc-end">{t("endTime")}</Label>
<Input
id="rc-end"
type="datetime-local"
value={periodEndLocal}
onChange={(e) => setPeriodEndLocal(e.target.value)}
<AdminDateRangeField
id="rc-date-range"
label={t("dateRange")}
from={dateFrom}
to={dateTo}
onRangeChange={({ from, to }) => {
setDateFrom(from);
setDateTo(to);
}}
/>
</div>
<Button type="button" className="w-full lg:w-auto" onClick={() => void onCreate()} disabled={submitting}>
{submitting ? t("submitting") : t("createTask")}
</Button>
</div>
<div className="grid gap-1.5">
<Label htmlFor="rc-scope">{t("scope")}</Label>
<Textarea
id="rc-scope"
value={scopeLines}
onChange={(e) => setScopeLines(e.target.value)}
rows={3}
placeholder={t("scopePlaceholder")}
className="min-h-20 text-sm"
<div className="grid gap-1.5 pt-4">
<Label htmlFor="rc-player-search">{t("playerSearch")}</Label>
<Input
id="rc-player-search"
value={playerSearch}
onChange={(e) => setPlayerSearch(e.target.value)}
placeholder={t("playerSearchPlaceholder")}
/>
{selectedPlayer ? (
<div className="flex items-center justify-between gap-3 rounded-lg border bg-muted/20 px-3 py-2 text-sm">
<div className="min-w-0">
<div className="truncate font-medium text-foreground">
{selectedPlayer.site_player_id}
{selectedPlayer.nickname ? ` · ${selectedPlayer.nickname}` : ""}
{selectedPlayer.username ? ` · ${selectedPlayer.username}` : ""}
</div>
</div>
<Button
type="button"
size="sm"
variant="outline"
onClick={() => {
setSelectedPlayer(null);
setPlayerSearch("");
setPlayerResults([]);
}}
>
{t("playerClear")}
</Button>
</div>
) : null}
{playerSearch.trim() !== "" || playerResults.length > 0 || playerLoading ? (
<div className="rounded-lg border bg-background">
<div className="max-h-56 overflow-y-auto">
{playerLoading ? (
<div className="px-3 py-2 text-sm text-muted-foreground">{t("loadingPlayers")}</div>
) : playerResults.length === 0 ? (
<div className="px-3 py-2 text-sm text-muted-foreground">{t("playerNoResults")}</div>
) : (
<div className="divide-y">
{playerResults.map((player) => {
const active = selectedPlayer?.id === player.id;
return (
<button
key={player.id}
type="button"
className={cn(
"flex w-full items-start justify-between gap-3 px-3 py-2.5 text-left text-sm transition-colors hover:bg-muted/25",
active && "bg-muted/30",
)}
onClick={() => {
setSelectedPlayer(player);
setPlayerSearch(player.site_player_id);
}}
>
<div className="min-w-0">
<div className="truncate font-medium text-foreground">
{player.site_player_id}
{player.nickname ? ` · ${player.nickname}` : ""}
</div>
<div className="truncate text-xs text-muted-foreground">
{player.username ?? "—"} · {player.site_code}
</div>
</div>
<span className="shrink-0 text-xs text-muted-foreground">
{active ? t("playerSelectedShort") : t("playerChoose")}
</span>
</button>
);
})}
</div>
)}
</div>
</div>
) : null}
</div>
</CardContent>
</Card>
@@ -292,7 +330,6 @@ export function ReconcileConsole(): React.ReactElement {
<CardHeader className="admin-list-header flex flex-row flex-wrap items-end justify-between gap-4">
<div>
<CardTitle className="admin-list-title">{t("jobsTitle")}</CardTitle>
<CardDescription className="mt-1.5">{t("jobsDesc")}</CardDescription>
</div>
<Button type="button" variant="secondary" size="sm" onClick={() => void loadJobs()}>
{t("refresh")}
@@ -309,37 +346,37 @@ export function ReconcileConsole(): React.ReactElement {
<Table id="reconcile-jobs-table">
<TableHeader>
<TableRow>
<TableHead className="w-24">{t("table.id", { ns: "common" })}</TableHead>
<TableHead>{t("jobNo")}</TableHead>
<TableHead className="sticky left-0 z-20 w-24 bg-muted/20 shadow-[1px_0_0_rgba(203,213,225,0.7)]">
{t("table.id", { ns: "common" })}
</TableHead>
<TableHead className="sticky left-24 z-20 min-w-[14rem] bg-muted/20 shadow-[1px_0_0_rgba(203,213,225,0.7)]">
{t("jobNo")}
</TableHead>
<TableHead>{t("type")}</TableHead>
<TableHead>{t("status")}</TableHead>
<TableHead>{t("period")}</TableHead>
<TableHead>{t("createdAt")}</TableHead>
<TableHead className="sticky right-0 z-20 w-28 bg-muted/20 text-center shadow-[-1px_0_0_rgba(203,213,225,0.7)]">
{t("operate")}
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{jobs.items.length === 0 ? (
<TableRow>
<TableCell colSpan={6} className="text-muted-foreground">
<TableCell colSpan={7} className="text-muted-foreground">
{t("states.noData", { ns: "common" })}
</TableCell>
</TableRow>
) : (
jobs.items.map((row) => (
<TableRow
key={row.id}
className={
selectedId === row.id
? "bg-muted/60 cursor-pointer"
: "cursor-pointer hover:bg-muted/40"
}
onClick={() => {
setSelectedId(row.id);
setItemsPage(1);
}}
>
<TableCell className="tabular-nums">{row.id}</TableCell>
<TableCell className="font-mono text-xs">{row.job_no}</TableCell>
<TableRow key={row.id}>
<TableCell className="sticky left-0 z-10 bg-card tabular-nums shadow-[1px_0_0_rgba(226,232,240,0.9)]">
{row.id}
</TableCell>
<TableCell className="sticky left-24 z-10 min-w-[14rem] bg-card font-mono text-xs shadow-[1px_0_0_rgba(226,232,240,0.9)]">
{row.job_no}
</TableCell>
<TableCell className="text-sm">{reconcileTypeLabel(row.reconcile_type, t)}</TableCell>
<TableCell>
<Badge variant="secondary">{jobStatusLabel(row.status, t)}</Badge>
@@ -353,6 +390,20 @@ export function ReconcileConsole(): React.ReactElement {
<TableCell className="whitespace-nowrap font-mono text-[11px] text-muted-foreground">
{formatTs(row.created_at)}
</TableCell>
<TableCell className="sticky right-0 z-10 bg-card text-center shadow-[-1px_0_0_rgba(226,232,240,0.9)]">
<Button
type="button"
size="sm"
variant="outline"
onClick={() => {
setSelectedId(row.id);
setItemsPage(1);
setDetailOpen(true);
}}
>
{t("view")}
</Button>
</TableCell>
</TableRow>
))
)}
@@ -379,23 +430,41 @@ export function ReconcileConsole(): React.ReactElement {
</CardContent>
</Card>
{selectedId != null ? (
<Card className="admin-list-card">
<CardHeader className="admin-list-header">
<CardTitle className="admin-list-title">{t("detailsTitle")}</CardTitle>
<CardDescription className="font-mono text-xs">#{selectedId}</CardDescription>
</CardHeader>
<CardContent className="admin-list-content pt-4">
<Dialog
open={detailOpen}
onOpenChange={(open) => {
setDetailOpen(open);
if (!open) {
setSelectedId(null);
setItems(null);
}
}}
>
<DialogContent
showCloseButton
className="flex h-[min(86vh,780px)] !max-w-[min(920px,calc(100vw-2rem))] flex-col gap-0 overflow-hidden p-0"
>
<DialogHeader className="shrink-0 space-y-1 border-b bg-background px-5 py-4 pr-12">
<DialogTitle className="text-base">{t("detailsTitle")}</DialogTitle>
<DialogDescription className="font-mono text-xs">
{selectedJob ? `${selectedJob.job_no} · #${selectedJob.id}` : selectedId != null ? `#${selectedId}` : ""}
</DialogDescription>
</DialogHeader>
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain bg-muted/15 px-5 py-4">
{itemsLoading && !items ? (
<p className="text-sm text-muted-foreground">{t("states.loading", { ns: "common" })}</p>
) : null}
{items ? (
<>
{items.job_no ? (
<p className="font-mono text-sm text-muted-foreground">{t("jobNo")} {items.job_no}</p>
) : null}
<div className="admin-table-shell">
<Table id={`reconcile-items-table-${selectedId ?? "none"}`}>
<div className="mb-3 flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
<span>{t("jobNo")} {items.job_no}</span>
<span>·</span>
<span>{t("status")} {selectedJob ? jobStatusLabel(selectedJob.status, t) : "—"}</span>
<span>·</span>
<span>{t("period")} {selectedJob ? `${selectedJob.period_start ? formatTs(selectedJob.period_start) : "—"} ~ ${selectedJob.period_end ? formatTs(selectedJob.period_end) : "—"}` : "—"}</span>
</div>
<div className="rounded-lg border bg-background">
<Table id={`reconcile-items-table-${selectedId ?? "none"}`}>
<TableHeader>
<TableRow>
<TableHead className="w-20">{t("table.id", { ns: "common" })}</TableHead>
@@ -427,25 +496,27 @@ export function ReconcileConsole(): React.ReactElement {
</Table>
</div>
{im ? (
<AdminListPaginationFooter
selectId="reconcile-items-per-page"
total={im.total}
page={im.current_page}
lastPage={Math.max(1, im.last_page)}
perPage={im.per_page}
loading={itemsLoading}
onPerPageChange={(n) => {
setItemsPerPage(n);
setItemsPage(1);
}}
onPageChange={setItemsPage}
/>
<div className="pt-4">
<AdminListPaginationFooter
selectId="reconcile-items-per-page"
total={im.total}
page={im.current_page}
lastPage={Math.max(1, im.last_page)}
perPage={im.per_page}
loading={itemsLoading}
onPerPageChange={(n) => {
setItemsPerPage(n);
setItemsPage(1);
}}
onPageChange={setItemsPage}
/>
</div>
) : null}
</>
) : null}
</CardContent>
</Card>
) : null}
</div>
</DialogContent>
</Dialog>
</div>
);
}

View File

@@ -1,5 +0,0 @@
export const reportsModuleMeta = {
segment: "reports",
title: "报表导出",
description: "",
} as const;

View File

@@ -1,298 +0,0 @@
"use client";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import {
downloadAdminReportJob,
getAdminReportJobs,
postAdminReportJob,
} from "@/api/admin-reports";
import { AdminListPaginationFooter } from "@/components/admin/admin-list-pagination-footer";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { Textarea } from "@/components/ui/textarea";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminReportJobListData } from "@/types/api/admin-reports";
const REPORT_TYPES = [
{ value: "draw_profit_summary" },
{ value: "daily_profit_summary" },
{ value: "player_win_loss" },
{ value: "wallet_transfer_report" },
{ value: "hot_number_risk_report" },
{ value: "play_dimension_report" },
{ value: "sold_out_number_report" },
{ value: "rebate_commission_report" },
{ value: "audit_operation_report" },
{ value: "wallet_txns_daily" },
{ value: "transfer_orders_daily" },
] as const;
export function ReportsConsole(): React.ReactElement {
const { t } = useTranslation(["reports", "common"]);
const formatTs = useAdminDateTimeFormatter();
const [data, setData] = useState<AdminReportJobListData | null>(null);
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [reportType, setReportType] = useState<string>(REPORT_TYPES[0].value);
const [exportFormat, setExportFormat] = useState<"csv" | "xlsx">("csv");
const [filterJsonText, setFilterJsonText] = useState('{\n "currency_code": "NPR"\n}');
const [submitting, setSubmitting] = useState(false);
const load = useCallback(async () => {
setLoading(true);
setErr(null);
try {
const d = await getAdminReportJobs({ page, per_page: perPage });
setData(d);
} catch (e) {
setErr(e instanceof LotteryApiBizError ? e.message : t("errors.loadFailed", { ns: "common" }));
setData(null);
} finally {
setLoading(false);
}
}, [page, perPage, t]);
useEffect(() => {
queueMicrotask(() => {
void load();
});
}, [load]);
async function onCreate(): Promise<void> {
let filter_json: Record<string, unknown> | null = null;
const trimmed = filterJsonText.trim();
if (trimmed !== "") {
try {
filter_json = JSON.parse(trimmed) as Record<string, unknown>;
} catch {
toast.error(t("parseFilterFailed"));
return;
}
}
setSubmitting(true);
try {
await postAdminReportJob({
report_type: reportType,
export_format: exportFormat,
parameters: filter_json,
filter_json,
});
toast.success(t("createSuccess"));
setPage(1);
await load();
} catch (e) {
toast.error(e instanceof LotteryApiBizError ? e.message : t("createFailed"));
} finally {
setSubmitting(false);
}
}
async function onDownload(rowId: number): Promise<void> {
try {
const blob = await downloadAdminReportJob(rowId);
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "";
a.click();
URL.revokeObjectURL(url);
} catch {
toast.error(t("downloadFailed"));
}
}
const meta = data?.meta;
const lastPage = meta
? Math.max(1, meta.last_page)
: 1;
const reportFormatLabel = (value: string) =>
t(`formatOptions.${value}`, { defaultValue: value.toUpperCase() });
const reportStatusLabel = (value: string) => t(`statusOptions.${value}`, { defaultValue: value });
return (
<div className="flex w-full max-w-none flex-col gap-8">
<Card>
<CardHeader>
<CardTitle>{t("createExport")}</CardTitle>
</CardHeader>
<CardContent className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<div className="grid gap-1.5">
<Label>{t("reportType")}</Label>
<Select
modal={false}
value={reportType}
onValueChange={(v) => {
if (v) {
setReportType(v);
}
}}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
{REPORT_TYPES.map((o) => (
<SelectItem key={o.value} value={o.value}>
{t(`reportTypes.${o.value}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="grid gap-1.5">
<Label>{t("exportFormat")}</Label>
<Select
modal={false}
value={exportFormat}
onValueChange={(v) => {
if (v === "csv" || v === "xlsx") {
setExportFormat(v);
}
}}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="csv">{t("formatOptions.csv")}</SelectItem>
<SelectItem value="xlsx">{t("formatOptions.xlsx")}</SelectItem>
</SelectContent>
</Select>
</div>
<div className="sm:col-span-2 lg:col-span-3 grid gap-1.5">
<Label htmlFor="report-filter-json">{t("filterJson")}</Label>
<Textarea
id="report-filter-json"
value={filterJsonText}
onChange={(e) => setFilterJsonText(e.target.value)}
rows={5}
className="font-mono text-xs"
/>
</div>
<div className="sm:col-span-2 lg:col-span-3">
<Button type="button" onClick={() => void onCreate()} disabled={submitting}>
{submitting ? t("actions.submitting", { ns: "common" }) : t("actions.createTask", { ns: "common" })}
</Button>
</div>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row flex-wrap items-end justify-between gap-4">
<div>
<CardTitle>{t("taskList")}</CardTitle>
</div>
<Button type="button" variant="secondary" size="sm" onClick={() => void load()}>
{t("actions.refresh", { ns: "common" })}
</Button>
</CardHeader>
<CardContent className="space-y-4">
{err ? <p className="text-sm text-red-600 dark:text-red-400">{err}</p> : null}
{loading && !data ? (
<p className="text-muted-foreground text-sm">{t("states.loading", { ns: "common" })}</p>
) : null}
{data ? (
<>
<div className="rounded-md border">
<Table id="reports-table">
<TableHeader>
<TableRow>
<TableHead className="w-24">{t("id")}</TableHead>
<TableHead>{t("jobId")}</TableHead>
<TableHead>{t("type")}</TableHead>
<TableHead>{t("format")}</TableHead>
<TableHead>{t("status")}</TableHead>
<TableHead>{t("output")}</TableHead>
<TableHead>{t("download")}</TableHead>
<TableHead>{t("createdAt")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data.items.length === 0 ? (
<TableRow>
<TableCell colSpan={8} className="text-muted-foreground">
{t("empty")}
</TableCell>
</TableRow>
) : (
data.items.map((row) => (
<TableRow key={row.id}>
<TableCell className="tabular-nums">{row.id}</TableCell>
<TableCell className="font-mono text-xs">{row.job_no}</TableCell>
<TableCell className="text-sm">
{t(`reportTypes.${row.report_type}`, {
defaultValue: row.report_type,
})}
</TableCell>
<TableCell>{reportFormatLabel(row.export_format)}</TableCell>
<TableCell>
<Badge variant="secondary">{reportStatusLabel(row.status)}</Badge>
</TableCell>
<TableCell className="max-w-[12rem] truncate text-xs text-muted-foreground">
{row.output_path ?? "—"}
</TableCell>
<TableCell>
<Button
type="button"
variant="secondary"
size="sm"
onClick={() => void onDownload(row.id)}
>
{t("actions.download", { ns: "common" })}
</Button>
</TableCell>
<TableCell className="whitespace-nowrap font-mono text-[11px] text-muted-foreground">
{formatTs(row.created_at)}
</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</div>
{meta ? (
<AdminListPaginationFooter
selectId="report-jobs-per-page"
total={meta.total}
page={meta.current_page}
lastPage={lastPage}
perPage={meta.per_page}
loading={loading}
onPerPageChange={(n) => {
setPerPage(n);
setPage(1);
}}
onPageChange={setPage}
/>
) : null}
</>
) : null}
</CardContent>
</Card>
</div>
);
}

View File

@@ -53,7 +53,7 @@ export function RiskIndexConsole() {
const [error, setError] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [drawNoInput, setDrawNoInput] = useState("");
const [drawNoQuery, setDrawNoQuery] = useState("");
const [statusFilter, setStatusFilter] = useState("");

View File

@@ -25,6 +25,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { formatAdminMinorUnits } from "@/lib/money";
import { LotteryApiBizError } from "@/types/api/errors";
@@ -50,9 +51,10 @@ function riskActionLabel(
export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
const { t } = useTranslation(["risk", "common"]);
useAdminCurrencyCatalog();
const formatDt = useAdminDateTimeFormatter();
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [data, setData] = useState<AdminRiskLockLogListData | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -184,7 +186,7 @@ export function RiskLockLogsConsole({ drawId }: { drawId: number }) {
{riskActionLabel(row.action_type, t)}
</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{formatAdminMinorUnits(row.amount)}
{formatAdminMinorUnits(row.amount, data?.currency_code ?? "NPR")}
</TableCell>
<TableCell className="text-xs text-muted-foreground">
{row.source_reason ?? "—"}

View File

@@ -17,6 +17,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { formatAdminMinorUnits } from "@/lib/money";
import { cn } from "@/lib/utils";
@@ -31,9 +32,10 @@ export function RiskPoolDetailConsole({
number4d: string;
}) {
const { t } = useTranslation(["risk", "common"]);
useAdminCurrencyCatalog();
const formatDt = useAdminDateTimeFormatter();
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(20);
const [perPage, setPerPage] = useState(10);
const [data, setData] = useState<AdminRiskPoolShowData | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -88,6 +90,7 @@ export function RiskPoolDetailConsole({
}
const { pool, logs } = data;
const currencyCode = data.currency_code ?? "NPR";
return (
<div className="space-y-6">
@@ -111,19 +114,19 @@ export function RiskPoolDetailConsole({
<div className="rounded-lg border bg-muted/40 p-3">
<p className="text-xs text-muted-foreground">{t("totalCap")}</p>
<p className="mt-1 font-mono text-sm font-medium tabular-nums">
{formatAdminMinorUnits(pool.total_cap_amount)}
{formatAdminMinorUnits(pool.total_cap_amount, currencyCode)}
</p>
</div>
<div className="rounded-lg border bg-muted/40 p-3">
<p className="text-xs text-muted-foreground">{t("lockedWorstCase")}</p>
<p className="mt-1 font-mono text-sm font-medium tabular-nums">
{formatAdminMinorUnits(pool.locked_amount)}
{formatAdminMinorUnits(pool.locked_amount, currencyCode)}
</p>
</div>
<div className="rounded-lg border bg-muted/40 p-3">
<p className="text-xs text-muted-foreground">{t("remainingSellable")}</p>
<p className="mt-1 font-mono text-sm font-medium tabular-nums">
{formatAdminMinorUnits(pool.remaining_amount)}
{formatAdminMinorUnits(pool.remaining_amount, currencyCode)}
</p>
</div>
<div className="rounded-lg border bg-muted/40 p-3">
@@ -169,7 +172,7 @@ export function RiskPoolDetailConsole({
</TableCell>
<TableCell className="text-sm">{row.action_type}</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{formatAdminMinorUnits(row.amount)}
{formatAdminMinorUnits(row.amount, currencyCode)}
</TableCell>
<TableCell className="text-xs text-muted-foreground">
{row.source_reason ?? "—"}

View File

@@ -32,6 +32,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { formatAdminMinorUnits } from "@/lib/money";
import { cn } from "@/lib/utils";
import { LotteryApiBizError } from "@/types/api/errors";
@@ -71,11 +72,12 @@ export function RiskPoolsConsole({
allowSortChange = false,
}: RiskPoolsConsoleProps) {
const { t } = useTranslation(["risk", "common"]);
useAdminCurrencyCatalog();
const [sort, setSort] = useState(defaultSort);
const [filter, setFilter] = useState<RiskFilter>(soldOutOnly ? "sold_out" : "all");
const [number, setNumber] = useState("");
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [data, setData] = useState<AdminRiskPoolListData | null>(null);
const [loading, setLoading] = useState(true);
const [actingNumber, setActingNumber] = useState<string | null>(null);
@@ -241,6 +243,7 @@ export function RiskPoolsConsole({
{(data?.items ?? []).map((row: AdminRiskPoolRow) => {
const highRisk = (row.usage_ratio ?? 0) >= 0.8;
const acting = actingNumber === row.normalized_number;
const currencyCode = data?.currency_code ?? "NPR";
return (
<TableRow
@@ -255,13 +258,13 @@ export function RiskPoolsConsole({
>
<TableCell className="font-mono font-medium">{row.normalized_number}</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{formatAdminMinorUnits(row.total_cap_amount)}
{formatAdminMinorUnits(row.total_cap_amount, currencyCode)}
</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{formatAdminMinorUnits(row.locked_amount)}
{formatAdminMinorUnits(row.locked_amount, currencyCode)}
</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{formatAdminMinorUnits(row.remaining_amount)}
{formatAdminMinorUnits(row.remaining_amount, currencyCode)}
</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{row.usage_ratio != null ? `${(row.usage_ratio * 100).toFixed(2)}%` : "—"}

View File

@@ -0,0 +1,11 @@
"use client";
import { CurrencySettingsPanel } from "@/modules/settings/currency-settings-panel";
export function CurrencyManagementScreen() {
return (
<div className="flex w-full max-w-none flex-col gap-6">
<CurrencySettingsPanel />
</div>
);
}

View File

@@ -0,0 +1,377 @@
"use client";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import {
deleteAdminCurrency,
getAdminCurrencies,
postAdminCurrency,
putAdminCurrency,
} from "@/api/admin-currencies";
import { Button } from "@/components/ui/button";
import { AdminTableExportButton } from "@/components/admin/admin-table-export-button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { useAdminProfile } from "@/stores/admin-session";
import { LotteryApiBizError } from "@/types/api/errors";
import type { AdminCurrencyRow } from "@/types/api/admin-currency";
type CurrencyFormState = {
code: string;
name: string;
decimal_places: string;
is_enabled: boolean;
is_bettable: boolean;
};
const EMPTY_FORM: CurrencyFormState = {
code: "",
name: "",
decimal_places: "2",
is_enabled: true,
is_bettable: false,
};
function toFormState(row: AdminCurrencyRow): CurrencyFormState {
return {
code: row.code,
name: row.name,
decimal_places: String(row.decimal_places),
is_enabled: row.is_enabled,
is_bettable: row.is_enabled && row.is_bettable,
};
}
export function CurrencySettingsPanel() {
const { t } = useTranslation(["config", "adminUsers"]);
const profile = useAdminProfile();
const canManage = adminHasAnyPermission(profile?.permissions, ["prd.currency.manage"]);
const [items, setItems] = useState<AdminCurrencyRow[]>([]);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [dialogOpen, setDialogOpen] = useState(false);
const [mode, setMode] = useState<"create" | "edit">("create");
const [editingCode, setEditingCode] = useState<string | null>(null);
const [form, setForm] = useState<CurrencyFormState>(EMPTY_FORM);
const [deleteTarget, setDeleteTarget] = useState<AdminCurrencyRow | null>(null);
const [deleteBusy, setDeleteBusy] = useState(false);
const load = useCallback(async () => {
if (!canManage) {
setItems([]);
setLoading(false);
return;
}
setLoading(true);
try {
const data = await getAdminCurrencies();
setItems(data.items);
} catch (error) {
toast.error(
error instanceof LotteryApiBizError
? error.message
: t("currencies.loadFailed", { ns: "config" }),
);
} finally {
setLoading(false);
}
}, [canManage, t]);
useEffect(() => {
queueMicrotask(() => {
void load();
});
}, [load]);
function openCreate(): void {
setMode("create");
setEditingCode(null);
setForm(EMPTY_FORM);
setDialogOpen(true);
}
function openEdit(row: AdminCurrencyRow): void {
setMode("edit");
setEditingCode(row.code);
setForm(toFormState(row));
setDialogOpen(true);
}
function updateForm<K extends keyof CurrencyFormState>(key: K, value: CurrencyFormState[K]): void {
setForm((prev) => {
const next = { ...prev, [key]: value };
if (key === "is_enabled" && value === false) {
next.is_bettable = false;
}
return next;
});
}
async function handleSubmit(): Promise<void> {
const payload = {
name: form.name.trim(),
decimal_places: Number.parseInt(form.decimal_places || "0", 10),
is_enabled: form.is_enabled,
is_bettable: form.is_enabled && form.is_bettable,
};
if (mode === "create") {
if (form.code.trim() === "" || payload.name === "") {
toast.error(t("currencies.form.required", { ns: "config" }));
return;
}
}
if (!Number.isFinite(payload.decimal_places) || payload.decimal_places < 0) {
toast.error(t("currencies.form.decimalInvalid", { ns: "config" }));
return;
}
setSaving(true);
try {
if (mode === "create") {
await postAdminCurrency({
code: form.code.trim().toUpperCase(),
...payload,
});
toast.success(t("currencies.createSuccess", { ns: "config" }));
} else if (editingCode !== null) {
await putAdminCurrency(editingCode, payload);
toast.success(t("currencies.updateSuccess", { ns: "config" }));
}
setDialogOpen(false);
await load();
} catch (error) {
toast.error(
error instanceof LotteryApiBizError
? error.message
: t(mode === "create" ? "currencies.createFailed" : "currencies.updateFailed", { ns: "config" }),
);
} finally {
setSaving(false);
}
}
async function confirmDelete(): Promise<void> {
if (deleteTarget === null) {
return;
}
setDeleteBusy(true);
try {
await deleteAdminCurrency(deleteTarget.code);
toast.success(t("currencies.deleteSuccess", { ns: "config", code: deleteTarget.code }));
setDeleteTarget(null);
await load();
} catch (error) {
toast.error(
error instanceof LotteryApiBizError
? error.message
: t("currencies.deleteFailed", { ns: "config" }),
);
} finally {
setDeleteBusy(false);
}
}
if (!canManage) {
return null;
}
return (
<Card className="admin-list-card">
<CardHeader className="admin-list-header flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div className="space-y-1">
<CardTitle className="admin-list-title">{t("currencies.title", { ns: "config" })}</CardTitle>
<p className="text-sm text-muted-foreground">
{t("currencies.description", { ns: "config" })}
</p>
</div>
<div className="flex items-center gap-2">
<AdminTableExportButton tableId="admin-currencies-table" filename="币种管理" sheetName="币种管理" />
<Button onClick={openCreate}>{t("currencies.actions.create", { ns: "config" })}</Button>
</div>
</CardHeader>
<CardContent className="admin-list-content">
<div className="admin-table-shell">
<Table id="admin-currencies-table">
<TableHeader>
<TableRow>
<TableHead className="whitespace-nowrap">{t("currencies.table.code", { ns: "config" })}</TableHead>
<TableHead>{t("currencies.table.name", { ns: "config" })}</TableHead>
<TableHead className="whitespace-nowrap">{t("currencies.table.decimals", { ns: "config" })}</TableHead>
<TableHead className="whitespace-nowrap">{t("currencies.table.enabled", { ns: "config" })}</TableHead>
<TableHead className="whitespace-nowrap">{t("currencies.table.bettable", { ns: "config" })}</TableHead>
<TableHead className="whitespace-nowrap text-center">{t("currencies.table.actions", { ns: "config" })}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{loading ? (
<TableRow>
<TableCell colSpan={6} className="text-center text-sm text-muted-foreground">
{t("currencies.loading", { ns: "config" })}
</TableCell>
</TableRow>
) : items.length === 0 ? (
<TableRow>
<TableCell colSpan={6} className="text-center text-sm text-muted-foreground">
{t("currencies.empty", { ns: "config" })}
</TableCell>
</TableRow>
) : (
items.map((row) => (
<TableRow key={row.code}>
<TableCell className="font-mono">{row.code}</TableCell>
<TableCell>{row.name}</TableCell>
<TableCell>{row.decimal_places}</TableCell>
<TableCell>{row.is_enabled ? t("system.states.enabled", { ns: "config" }) : t("system.states.disabled", { ns: "config" })}</TableCell>
<TableCell>{row.is_bettable ? t("system.states.enabled", { ns: "config" }) : t("system.states.disabled", { ns: "config" })}</TableCell>
<TableCell className="text-center">
<div className="flex items-center justify-center gap-2">
<Button variant="outline" size="sm" onClick={() => openEdit(row)}>
{t("currencies.actions.edit", { ns: "config" })}
</Button>
<Button variant="destructive" size="sm" onClick={() => setDeleteTarget(row)}>
{t("currencies.actions.delete", { ns: "config" })}
</Button>
</div>
</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</div>
</CardContent>
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
<DialogContent showCloseButton className="sm:max-w-md">
<DialogHeader>
<DialogTitle>
{t(mode === "create" ? "currencies.dialog.createTitle" : "currencies.dialog.editTitle", {
ns: "config",
})}
</DialogTitle>
<DialogDescription>
{t("currencies.dialog.description", { ns: "config" })}
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="currency-code">{t("currencies.form.code", { ns: "config" })}</Label>
<Input
id="currency-code"
value={form.code}
onChange={(e) => updateForm("code", e.target.value.toUpperCase())}
disabled={saving || mode === "edit"}
/>
</div>
<div className="space-y-2">
<Label htmlFor="currency-name">{t("currencies.form.name", { ns: "config" })}</Label>
<Input
id="currency-name"
value={form.name}
onChange={(e) => updateForm("name", e.target.value)}
disabled={saving}
/>
</div>
<div className="space-y-2">
<Label htmlFor="currency-decimals">{t("currencies.form.decimals", { ns: "config" })}</Label>
<Input
id="currency-decimals"
type="number"
min="0"
max="12"
step="1"
value={form.decimal_places}
onChange={(e) => updateForm("decimal_places", e.target.value)}
disabled={saving}
/>
</div>
<div className="flex items-center justify-between rounded-xl border border-border/70 p-3">
<div className="space-y-1">
<p className="text-sm font-medium">{t("currencies.form.enabled", { ns: "config" })}</p>
<p className="text-xs text-muted-foreground">{t("currencies.form.enabledHint", { ns: "config" })}</p>
</div>
<Checkbox
checked={form.is_enabled}
onCheckedChange={(checked) => updateForm("is_enabled", checked === true)}
disabled={saving}
/>
</div>
<div className="flex items-center justify-between rounded-xl border border-border/70 p-3">
<div className="space-y-1">
<p className="text-sm font-medium">{t("currencies.form.bettable", { ns: "config" })}</p>
<p className="text-xs text-muted-foreground">{t("currencies.form.bettableHint", { ns: "config" })}</p>
</div>
<Checkbox
checked={form.is_enabled && form.is_bettable}
onCheckedChange={(checked) => updateForm("is_bettable", checked === true)}
disabled={saving || !form.is_enabled}
/>
</div>
<div className="flex justify-end gap-3">
<Button variant="outline" onClick={() => setDialogOpen(false)} disabled={saving}>
{t("actions.cancel", { ns: "adminUsers" })}
</Button>
<Button onClick={() => void handleSubmit()} disabled={saving}>
{saving ? t("saving", { ns: "adminUsers" }) : t("actions.save", { ns: "adminUsers" })}
</Button>
</div>
</div>
</DialogContent>
</Dialog>
<Dialog open={deleteTarget !== null} onOpenChange={(open) => !open && setDeleteTarget(null)}>
<DialogContent showCloseButton className="sm:max-w-md">
<DialogHeader>
<DialogTitle>{t("currencies.deleteDialog.title", { ns: "config" })}</DialogTitle>
<DialogDescription>
{t("currencies.deleteDialog.description", {
ns: "config",
code: deleteTarget?.code ?? "",
})}
</DialogDescription>
</DialogHeader>
<div className="flex justify-end gap-3">
<Button variant="outline" onClick={() => setDeleteTarget(null)} disabled={deleteBusy}>
{t("actions.cancel", { ns: "adminUsers" })}
</Button>
<Button variant="destructive" onClick={() => void confirmDelete()} disabled={deleteBusy}>
{deleteBusy ? t("deleting", { ns: "adminUsers" }) : t("currencies.actions.delete", { ns: "config" })}
</Button>
</div>
</DialogContent>
</Dialog>
</Card>
);
}

View File

@@ -11,7 +11,6 @@ import {
import { WalletConfigDocScreen } from "@/modules/config/doc/wallet-config-doc-screen";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { LotteryApiBizError } from "@/types/api/errors";
@@ -31,6 +30,45 @@ interface RuntimeDraft {
autoSettlement: boolean;
}
function BinaryChoice({
active,
disabled,
onChange,
leftLabel,
rightLabel,
}: {
active: boolean;
disabled: boolean;
onChange: (value: boolean) => void;
leftLabel: string;
rightLabel: string;
}) {
return (
<div className="inline-flex rounded-full border border-border/60 bg-background p-1">
<Button
type="button"
size="sm"
variant={!active ? "default" : "ghost"}
className={!active ? "h-8 rounded-full px-3" : "h-8 rounded-full px-3 text-muted-foreground"}
disabled={disabled}
onClick={() => onChange(false)}
>
{leftLabel}
</Button>
<Button
type="button"
size="sm"
variant={active ? "default" : "ghost"}
className={active ? "h-8 rounded-full px-3" : "h-8 rounded-full px-3 text-muted-foreground"}
disabled={disabled}
onClick={() => onChange(true)}
>
{rightLabel}
</Button>
</div>
);
}
export function SystemSettingsScreen() {
const { t } = useTranslation(["common", "config", "adminUsers"]);
const [draft, setDraft] = useState<RuntimeDraft>({
@@ -120,82 +158,89 @@ export function SystemSettingsScreen() {
</CardTitle>
</div>
</CardHeader>
</Card>
<Card>
<CardHeader>
<CardTitle>{t("system.title", { ns: "config" })}</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<div className="grid gap-6 md:grid-cols-2">
<div className="space-y-3 rounded-xl border border-border/70 p-4">
<Label htmlFor="manual-review">{t("system.fields.manualReview", { ns: "config" })}</Label>
<div className="flex items-center gap-3">
<Checkbox
id="manual-review"
checked={draft.requireManualReview}
onCheckedChange={(checked) => updateDraft("requireManualReview", checked === true)}
disabled={loading || saving}
/>
<Label htmlFor="manual-review" className="text-sm font-medium">
{draft.requireManualReview
? t("system.states.enabled", { ns: "config" })
: t("system.states.disabled", { ns: "config" })}
</Label>
<CardContent className="space-y-8">
<section className="space-y-4">
<div className="flex flex-wrap items-end justify-between gap-3">
<div className="space-y-1">
<h3 className="text-base font-semibold">{t("system.title", { ns: "config" })}</h3>
</div>
</div>
<div className="space-y-3 rounded-xl border border-border/70 p-4">
<Label htmlFor="auto-settlement">{t("system.fields.autoSettlement", { ns: "config" })}</Label>
<div className="flex items-center gap-3">
<Checkbox
id="auto-settlement"
checked={draft.autoSettlement}
onCheckedChange={(checked) => updateDraft("autoSettlement", checked === true)}
<div className="space-y-5 rounded-2xl border border-border/60 bg-muted/10 px-4 py-4">
<div className="flex flex-wrap items-center justify-between gap-3">
<div className="space-y-1">
<Label className="text-sm font-medium">{t("system.fields.manualReview", { ns: "config" })}</Label>
</div>
<BinaryChoice
active={draft.requireManualReview}
disabled={loading || saving}
onChange={(value) => updateDraft("requireManualReview", value)}
leftLabel={t("system.states.disabled", { ns: "config" })}
rightLabel={t("system.states.enabled", { ns: "config" })}
/>
<Label htmlFor="auto-settlement" className="text-sm font-medium">
{draft.autoSettlement
? t("system.states.enabled", { ns: "config" })
: t("system.states.disabled", { ns: "config" })}
</div>
<div className="h-px bg-border/60" />
<div className="flex flex-wrap items-center justify-between gap-3">
<div className="space-y-1">
<Label className="text-sm font-medium">{t("system.fields.autoSettlement", { ns: "config" })}</Label>
</div>
<BinaryChoice
active={draft.autoSettlement}
disabled={loading || saving}
onChange={(value) => updateDraft("autoSettlement", value)}
leftLabel={t("system.states.disabled", { ns: "config" })}
rightLabel={t("system.states.enabled", { ns: "config" })}
/>
</div>
<div className="h-px bg-border/60" />
<div className="grid gap-2">
<Label htmlFor="cooldown-minutes" className="text-sm font-medium">
{t("system.fields.cooldownMinutes", { ns: "config" })}
</Label>
<Input
id="cooldown-minutes"
type="number"
min="0"
step="1"
value={draft.cooldownMinutes}
onChange={(e) => updateDraft("cooldownMinutes", e.target.value)}
disabled={loading || saving}
className="max-w-[240px]"
/>
</div>
<div className="flex items-center gap-4 pt-2">
<Button onClick={() => void handleSave()} disabled={!dirty || loading || saving}>
{saving ? t("saving", { ns: "adminUsers" }) : t("actions.save", { ns: "adminUsers" })}
</Button>
{dirty && (
<Button
variant="outline"
onClick={() => {
setDraft(saved);
setDirty(false);
}}
>
{t("system.discard", { ns: "config" })}
</Button>
)}
</div>
</div>
</div>
</section>
<div className="space-y-2">
<Label htmlFor="cooldown-minutes">{t("system.fields.cooldownMinutes", { ns: "config" })}</Label>
<Input
id="cooldown-minutes"
type="number"
min="0"
step="1"
value={draft.cooldownMinutes}
onChange={(e) => updateDraft("cooldownMinutes", e.target.value)}
disabled={loading || saving}
/>
</div>
<div className="flex items-center gap-4">
<Button onClick={() => void handleSave()} disabled={!dirty || loading || saving}>
{saving ? t("saving", { ns: "adminUsers" }) : t("actions.save", { ns: "adminUsers" })}
</Button>
{dirty && (
<Button
variant="outline"
onClick={() => {
setDraft(saved);
setDirty(false);
}}
>
{t("system.discard", { ns: "config" })}
</Button>
)}
</div>
<section className="space-y-4 border-t border-border/60 pt-6">
<div className="space-y-1">
<h3 className="text-base font-semibold">{t("wallet.title", { ns: "config" })}</h3>
</div>
<WalletConfigDocScreen embedded />
</section>
</CardContent>
</Card>
<WalletConfigDocScreen />
</div>
);
}

View File

@@ -35,6 +35,7 @@ import {
TableRow,
} from "@/components/ui/table";
import { Textarea } from "@/components/ui/textarea";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { formatAdminMinorUnits } from "@/lib/money";
@@ -69,6 +70,7 @@ function settlementReviewStatusText(value: string | null, t: (key: string) => st
export function SettlementBatchDetailsConsole({ batchId }: Props) {
const { t } = useTranslation(["settlement", "common"]);
const profile = useAdminProfile();
useAdminCurrencyCatalog();
const canReviewSettlement = adminHasAnyPermission(profile?.permissions, [PRD_PAYOUT_REVIEW]);
const canManagePayout = adminHasAnyPermission(profile?.permissions, [PRD_PAYOUT_MANAGE]);
const formatDt = useAdminDateTimeFormatter();
@@ -77,7 +79,7 @@ export function SettlementBatchDetailsConsole({ batchId }: Props) {
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(25);
const [perPage, setPerPage] = useState(10);
const [acting, setActing] = useState<string | null>(null);
const [pendingAction, setPendingAction] = useState<SettlementAction | null>(null);
const [reviewRemark, setReviewRemark] = useState("");
@@ -224,20 +226,26 @@ export function SettlementBatchDetailsConsole({ batchId }: Props) {
</p>
<p>
<span className="text-muted-foreground">{t("totalBet")}</span>{" "}
<span className="font-mono tabular-nums">{formatAdminMinorUnits(summary.total_bet_amount)}</span>
<span className="font-mono tabular-nums">
{formatAdminMinorUnits(summary.total_bet_amount, summary.currency_code ?? "NPR")}
</span>
</p>
<p>
<span className="text-muted-foreground">{t("actualDeduct")}</span>{" "}
<span className="font-mono tabular-nums">{formatAdminMinorUnits(summary.total_actual_deduct)}</span>
<span className="font-mono tabular-nums">
{formatAdminMinorUnits(summary.total_actual_deduct, summary.currency_code ?? "NPR")}
</span>
</p>
<p>
<span className="text-muted-foreground">{t("payoutAmount")}</span>{" "}
<span className="font-mono tabular-nums">{formatAdminMinorUnits(summary.total_payout_amount)}</span>
<span className="font-mono tabular-nums">
{formatAdminMinorUnits(summary.total_payout_amount, summary.currency_code ?? "NPR")}
</span>
</p>
<p>
<span className="text-muted-foreground">{t("jackpotPayout")}</span>{" "}
<span className="font-mono tabular-nums">
{formatAdminMinorUnits(summary.total_jackpot_payout_amount)}
{formatAdminMinorUnits(summary.total_jackpot_payout_amount, summary.currency_code ?? "NPR")}
</span>
</p>
<p>
@@ -248,7 +256,7 @@ export function SettlementBatchDetailsConsole({ batchId }: Props) {
summary.platform_profit < 0 ? "text-destructive" : "text-emerald-700",
)}
>
{formatAdminMinorUnits(summary.platform_profit)}
{formatAdminMinorUnits(summary.platform_profit, summary.currency_code ?? "NPR")}
</span>
</p>
<p>
@@ -322,10 +330,13 @@ export function SettlementBatchDetailsConsole({ batchId }: Props) {
</TableCell>
<TableCell className="text-xs">{r.matched_prize_tier ?? "—"}</TableCell>
<TableCell className="text-right font-mono text-xs tabular-nums">
{formatAdminMinorUnits(r.win_amount)}
{formatAdminMinorUnits(r.win_amount, r.currency_code ?? summary.currency_code ?? "NPR")}
</TableCell>
<TableCell className="text-right font-mono text-xs tabular-nums">
{formatAdminMinorUnits(r.jackpot_allocation_amount)}
{formatAdminMinorUnits(
r.jackpot_allocation_amount,
r.currency_code ?? summary.currency_code ?? "NPR",
)}
</TableCell>
</TableRow>
))}
@@ -375,9 +386,9 @@ export function SettlementBatchDetailsConsole({ batchId }: Props) {
<div className="space-y-3">
<p className="rounded-md border bg-muted/30 p-3 text-sm">
{t("confirmAmountLine", {
actual: formatAdminMinorUnits(summary.total_actual_deduct),
payout: formatAdminMinorUnits(summary.total_payout_amount),
profit: formatAdminMinorUnits(summary.platform_profit),
actual: formatAdminMinorUnits(summary.total_actual_deduct, summary.currency_code ?? "NPR"),
payout: formatAdminMinorUnits(summary.total_payout_amount, summary.currency_code ?? "NPR"),
profit: formatAdminMinorUnits(summary.platform_profit, summary.currency_code ?? "NPR"),
})}
</p>
{pendingAction !== "payout" ? (

View File

@@ -42,6 +42,7 @@ import {
TableRow,
} from "@/components/ui/table";
import { Textarea } from "@/components/ui/textarea";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { formatAdminMinorUnits } from "@/lib/money";
import { cn } from "@/lib/utils";
@@ -84,6 +85,7 @@ function settlementReviewStatusText(value: string | null, t: (key: string) => st
export function SettlementBatchesConsole() {
const { t } = useTranslation(["settlement", "common"]);
const profile = useAdminProfile();
useAdminCurrencyCatalog();
const canReviewSettlement = adminHasAnyPermission(profile?.permissions, [PRD_PAYOUT_REVIEW]);
const canManagePayout = adminHasAnyPermission(profile?.permissions, [PRD_PAYOUT_MANAGE]);
const [data, setData] = useState<AdminSettlementBatchListData | null>(null);
@@ -94,7 +96,7 @@ export function SettlementBatchesConsole() {
const [draftStatus, setDraftStatus] = useState(STATUS_ALL);
const [appliedStatus, setAppliedStatus] = useState(STATUS_ALL);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(20);
const [perPage, setPerPage] = useState(10);
const [actingId, setActingId] = useState<number | null>(null);
const [pendingAction, setPendingAction] = useState<PendingAction | null>(null);
const [reviewRemark, setReviewRemark] = useState("");
@@ -252,13 +254,13 @@ export function SettlementBatchesConsole() {
<TableCell className="font-mono text-xs">{row.id}</TableCell>
<TableCell className="font-mono text-sm">{row.draw_no ?? "—"}</TableCell>
<TableCell className="text-right font-mono text-xs tabular-nums">
{formatAdminMinorUnits(row.total_bet_amount)}
{formatAdminMinorUnits(row.total_bet_amount, row.currency_code ?? "NPR")}
</TableCell>
<TableCell className="text-right font-mono text-xs tabular-nums">
{formatAdminMinorUnits(row.total_actual_deduct)}
{formatAdminMinorUnits(row.total_actual_deduct, row.currency_code ?? "NPR")}
</TableCell>
<TableCell className="text-right font-mono text-xs tabular-nums">
{formatAdminMinorUnits(row.total_payout_amount)}
{formatAdminMinorUnits(row.total_payout_amount, row.currency_code ?? "NPR")}
</TableCell>
<TableCell
className={cn(
@@ -266,7 +268,7 @@ export function SettlementBatchesConsole() {
row.platform_profit < 0 ? "text-destructive" : "text-emerald-700",
)}
>
{formatAdminMinorUnits(row.platform_profit)}
{formatAdminMinorUnits(row.platform_profit, row.currency_code ?? "NPR")}
</TableCell>
<TableCell className="text-xs text-muted-foreground">
{settlementReviewStatusText(row.review_status, t)}
@@ -368,9 +370,18 @@ export function SettlementBatchesConsole() {
<div className="space-y-3">
<p className="rounded-md border bg-muted/30 p-3 text-sm">
{t("confirmAmountLine", {
actual: formatAdminMinorUnits(pendingAction.row.total_actual_deduct),
payout: formatAdminMinorUnits(pendingAction.row.total_payout_amount),
profit: formatAdminMinorUnits(pendingAction.row.platform_profit),
actual: formatAdminMinorUnits(
pendingAction.row.total_actual_deduct,
pendingAction.row.currency_code ?? "NPR",
),
payout: formatAdminMinorUnits(
pendingAction.row.total_payout_amount,
pendingAction.row.currency_code ?? "NPR",
),
profit: formatAdminMinorUnits(
pendingAction.row.platform_profit,
pendingAction.row.currency_code ?? "NPR",
),
})}
</p>
{pendingAction.action !== "payout" ? (

View File

@@ -95,7 +95,7 @@ export function PlayerTicketsConsole(): React.ReactElement {
const [loading, setLoading] = useState(false);
const [err, setErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(20);
const [perPage, setPerPage] = useState(10);
const load = useCallback(async () => {
setLoading(true);

View File

@@ -36,7 +36,9 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { useAdminCurrencyCatalog } from "@/hooks/use-admin-currency-catalog";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { formatAdminMinorUnits } from "@/lib/money";
import { LotteryApiBizError } from "@/types/api/errors";
import type {
AdminPlayerWalletsData,
@@ -44,11 +46,6 @@ import type {
AdminWalletTxnListData,
} from "@/types/api/admin-wallet";
function formatMinorUnits(minor: number, currencyCode: string): string {
const major = minor / 100;
return `${major.toFixed(2)} ${currencyCode}`;
}
/** 长单号/流水号:单行截断;点击复制全文,悬停可看全文 */
function CellMonoId({
value,
@@ -227,12 +224,13 @@ function canManuallyProcessTransferOrder(row: {
export function TransferOrdersPanel(): React.ReactElement {
const { t } = useTranslation(["wallet", "common"]);
useAdminCurrencyCatalog();
const formatTs = useAdminDateTimeFormatter();
const [data, setData] = useState<AdminTransferOrderListData | null>(null);
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(20);
const [perPage, setPerPage] = useState(10);
const [draft, setDraft] = useState<TransferFilters>(emptyTransferFilters);
const [applied, setApplied] = useState<TransferFilters>(emptyTransferFilters);
const [actionLoading, setActionLoading] = useState<Set<string>>(new Set());
@@ -475,7 +473,7 @@ export function TransferOrdersPanel(): React.ReactElement {
</TableCell>
<TableCell>{row.direction}</TableCell>
<TableCell className="tabular-nums">
{formatMinorUnits(row.amount, row.currency_code)}
{formatAdminMinorUnits(row.amount, row.currency_code)}
</TableCell>
<TableCell>
<Badge variant={statusBadgeVariant(row.status)}>{statusLabelT(row.status, t)}</Badge>
@@ -552,7 +550,7 @@ export function WalletTxnsPanel(): React.ReactElement {
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string | null>(null);
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(20);
const [perPage, setPerPage] = useState(10);
const [draft, setDraft] = useState<TxnFilters>(emptyTxnFilters);
const [applied, setApplied] = useState<TxnFilters>(emptyTxnFilters);
@@ -836,6 +834,7 @@ export function WalletTxnsPanel(): React.ReactElement {
export function PlayerWalletPanel(): React.ReactElement {
const { t } = useTranslation(["wallet", "common"]);
useAdminCurrencyCatalog();
const [playerId, setPlayerId] = useState("");
const [result, setResult] = useState<AdminPlayerWalletsData | null>(null);
const [err, setErr] = useState<string | null>(null);
@@ -918,7 +917,7 @@ export function PlayerWalletPanel(): React.ReactElement {
<TableCell>{w.currency_code}</TableCell>
<TableCell className="font-mono tabular-nums">{w.balance}</TableCell>
<TableCell className="tabular-nums">
{formatMinorUnits(w.available_balance, w.currency_code)}
{formatAdminMinorUnits(w.available_balance, w.currency_code)}
</TableCell>
</TableRow>
))

View File

@@ -4,8 +4,8 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { cn } from "@/lib/utils";
import { useAdminProfile } from "@/stores/admin-session";
const RECONCILE_PERMS = [
@@ -28,27 +28,38 @@ export function WalletSubnav(): React.ReactElement {
return (
<nav
aria-label={t("subnavLabel")}
className="mb-6 flex flex-wrap gap-2 border-b border-border pb-3"
className="flex w-full flex-wrap items-end gap-1 border-b border-border/60 px-1"
>
{tabs.map((tab) => {
const allowed = adminHasAnyPermission(perms, [...tab.requiredAny]);
const active = pathname === tab.href || pathname.startsWith(`${tab.href}/`);
const className = cn(
"rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",
active
? "bg-primary text-primary-foreground"
: "bg-muted/60 text-foreground hover:bg-muted",
!allowed && "cursor-not-allowed opacity-45",
);
if (!allowed) {
return (
<span key={tab.href} className={className} title={t("noPermission")}>
<span
key={tab.href}
className={cn(
"border-b-2 border-transparent px-4 py-3 text-sm font-medium text-muted-foreground/45",
"cursor-not-allowed",
)}
title={t("noPermission")}
>
{t(tab.label)}
</span>
);
}
return (
<Link key={tab.href} href={tab.href} className={className}>
<Link
key={tab.href}
href={tab.href}
className={cn(
"border-b-2 px-4 py-3 text-sm font-medium transition-colors",
active
? "border-primary text-primary"
: "border-transparent text-muted-foreground hover:border-border/80 hover:text-foreground",
)}
>
{t(tab.label)}
</Link>
);

View File

@@ -0,0 +1,35 @@
export type AdminCurrencyRow = {
id: number;
code: string;
name: string;
decimal_places: number;
is_enabled: boolean;
is_bettable: boolean;
created_at: string | null;
updated_at: string | null;
};
export type AdminCurrencyListData = {
items: AdminCurrencyRow[];
};
export type AdminCurrencyDeleteResult = {
deleted: boolean;
id: number;
code: string;
};
export type AdminCurrencyCreatePayload = {
code: string;
name: string;
decimal_places?: number;
is_enabled?: boolean;
is_bettable?: boolean;
};
export type AdminCurrencyUpdatePayload = {
name?: string;
decimal_places?: number;
is_enabled?: boolean;
is_bettable?: boolean;
};

View File

@@ -42,6 +42,7 @@ export type AdminPlayerCreatePayload = {
export type AdminPlayerUpdatePayload = {
username?: string;
nickname?: string | null;
default_currency?: string;
status?: number;
};

View File

@@ -1,30 +0,0 @@
export type AdminReportJobRow = {
id: number;
job_no: string;
admin_user_id: number | null;
report_type: string;
export_format: string;
filter_json: Record<string, unknown> | null;
status: string;
output_path: string | null;
error_message: string | null;
finished_at: string | null;
created_at: string | null;
};
export type AdminReportJobListData = {
items: AdminReportJobRow[];
meta: {
current_page: number;
per_page: number;
total: number;
last_page: number;
};
};
export type AdminReportJobCreateResponse = {
id: number;
job_no: string;
status: string;
output_path: string | null;
};

View File

@@ -19,6 +19,7 @@ export type AdminRiskPoolRow = {
export type AdminRiskPoolListData = {
draw_id: number;
draw_no: string;
currency_code: string | null;
items: AdminRiskPoolRow[];
meta: AdminRiskPoolListMeta;
};
@@ -39,6 +40,7 @@ export type AdminRiskLockLogRow = {
export type AdminRiskLockLogListData = {
draw_id: number;
draw_no: string;
currency_code: string | null;
items: AdminRiskLockLogRow[];
meta: AdminRiskPoolListMeta;
};
@@ -58,6 +60,7 @@ export type AdminRiskPoolDetailLogRow = {
export type AdminRiskPoolShowData = {
draw_id: number;
draw_no: string;
currency_code: string | null;
pool: AdminRiskPoolRow;
logs: {
items: AdminRiskPoolDetailLogRow[];

View File

@@ -2,6 +2,7 @@ export type AdminSettlementBatchRow = {
id: number;
draw_id: number;
draw_no: string | null;
currency_code: string | null;
result_batch_id: number;
settle_version: number;
status: string;
@@ -34,6 +35,7 @@ export type AdminSettlementBatchShowData = {
id: number;
draw_id: number;
draw_no: string | null;
currency_code: string | null;
draw_status: string | null;
result_batch_id: number;
result_batch_version: number | null;
@@ -62,6 +64,7 @@ export type AdminSettlementDetailRow = {
ticket_item_id: number;
ticket_no: string | null;
play_code: string | null;
currency_code: string | null;
player_id: number | null;
player_username: string | null;
site_player_id: string | null;

View File

@@ -35,11 +35,6 @@ export type {
AdminWalletTxnItem,
AdminWalletTxnListData,
} from "./admin-wallet";
export type {
AdminReportJobCreateResponse,
AdminReportJobListData,
AdminReportJobRow,
} from "./admin-reports";
export type {
AdminReconcileItemRow,
AdminReconcileItemsData,