Files
lotteryAdmin/src/modules/reports/reports-definitions.ts
2026-07-10 10:23:46 +08:00

153 lines
3.2 KiB
TypeScript

import type { LucideIcon } from "lucide-react";
import {
CalendarDays,
Building2,
FileSpreadsheet,
ListFilter,
ShieldAlert,
ShieldCheck,
Ticket,
Users,
WalletCards,
} from "lucide-react";
import {
PRD_AUDIT_VIEW,
PRD_REPORT_VIEW,
PRD_RISK_ACCESS_ANY,
PRD_WALLET_TRANSFER_ACCESS_ANY,
} from "@/lib/admin-prd";
export type ReportCategory = "profit" | "wallet" | "risk" | "audit";
export const REPORT_CATEGORY_ORDER: readonly ReportCategory[] = [
"profit",
"wallet",
"risk",
"audit",
] as const;
export type FilterKind =
| "draw"
| "date"
| "player_period"
| "draw_number"
| "play"
| "play_period"
| "operator_period";
export type FieldKey = "drawNo" | "number" | "player" | "play" | "operator" | "period";
export type ReportKey =
| "draw_profit"
| "daily_profit"
| "player_win_loss"
| "player_transfer"
| "hot_number_risk"
| "play_dimension"
| "provider_profit"
| "sold_out_number"
| "admin_audit";
export type ReportDefinition = {
key: ReportKey;
category: ReportCategory;
icon: LucideIcon;
filterKind: FilterKind;
fields: FieldKey[];
connected: boolean;
requiredAny: readonly string[];
};
const PRD_REPORTS_VIEW_ACCESS_ANY = [PRD_REPORT_VIEW] as const;
export const REPORT_DEFINITIONS: ReportDefinition[] = [
{
key: "provider_profit",
category: "profit",
icon: Building2,
filterKind: "date",
fields: ["period"],
connected: true,
requiredAny: PRD_REPORTS_VIEW_ACCESS_ANY,
},
{
key: "draw_profit",
category: "profit",
icon: Ticket,
filterKind: "draw",
fields: ["drawNo"],
connected: true,
requiredAny: PRD_REPORTS_VIEW_ACCESS_ANY,
},
{
key: "daily_profit",
category: "profit",
icon: CalendarDays,
filterKind: "date",
fields: ["period"],
connected: true,
requiredAny: PRD_REPORTS_VIEW_ACCESS_ANY,
},
{
key: "player_win_loss",
category: "profit",
icon: Users,
filterKind: "player_period",
fields: ["player", "period"],
connected: true,
requiredAny: PRD_REPORTS_VIEW_ACCESS_ANY,
},
{
key: "play_dimension",
category: "profit",
icon: ListFilter,
filterKind: "play_period",
fields: ["play", "period"],
connected: true,
requiredAny: PRD_REPORTS_VIEW_ACCESS_ANY,
},
{
key: "player_transfer",
category: "wallet",
icon: WalletCards,
filterKind: "player_period",
fields: ["player", "period"],
connected: true,
requiredAny: PRD_WALLET_TRANSFER_ACCESS_ANY,
},
{
key: "hot_number_risk",
category: "risk",
icon: ShieldAlert,
filterKind: "draw_number",
fields: ["drawNo", "number"],
connected: true,
requiredAny: PRD_RISK_ACCESS_ANY,
},
{
key: "sold_out_number",
category: "risk",
icon: ShieldCheck,
filterKind: "draw",
fields: ["drawNo"],
connected: true,
requiredAny: PRD_RISK_ACCESS_ANY,
},
{
key: "admin_audit",
category: "audit",
icon: FileSpreadsheet,
filterKind: "operator_period",
fields: ["operator", "period"],
connected: true,
requiredAny: [PRD_AUDIT_VIEW],
},
];
export const CATEGORY_SHORTCUT_HREF: Partial<Record<ReportCategory, string>> = {
wallet: "/admin/wallet/transfer-orders",
risk: "/admin/risk",
audit: "/admin/audit-logs",
};