Files
lotteryAdmin/src/modules/wallet/wallet-subnav.tsx
kang 2dfffd1fd1 feat: 新增玩家管理模块,完善钱包转账单操作能力
1. 重构玩家模块导航与元信息,将原玩家查询改为玩家列表
2. 新增完整的玩家CRUD API与前端管理页面,支持搜索、新建、编辑、删除玩家
3. 为转账单新增冲正与人工处理操作,补充状态显示与对应枚举
4. 优化用户列表表格空值展示与样式细节
5. 调整钱包子导航,移除旧的玩家钱包入口
2026-05-14 10:42:43 +08:00

57 lines
1.8 KiB
TypeScript

"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { cn } from "@/lib/utils";
import { adminHasAnyPermission } from "@/lib/admin-permissions";
import { useAdminProfile } from "@/stores/admin-session";
const RECONCILE_PERMS = [
"prd.wallet_reconcile.manage",
"prd.wallet_reconcile.view",
"prd.wallet_reconcile.view_cs",
] as const;
const tabs: { href: string; label: string; requiredAny: readonly string[] }[] = [
{ href: "/admin/wallet/transactions", label: "钱包流水", requiredAny: RECONCILE_PERMS },
{ href: "/admin/wallet/transfer-orders", label: "转账单", requiredAny: RECONCILE_PERMS },
];
export function WalletSubnav(): React.ReactElement {
const pathname = usePathname();
const profile = useAdminProfile();
const perms = profile?.permissions;
return (
<nav
aria-label="钱包子页"
className="mb-6 flex flex-wrap gap-2 border-b border-border pb-3"
>
{tabs.map((t) => {
const allowed = adminHasAnyPermission(perms, [...t.requiredAny]);
const active = pathname === t.href || pathname.startsWith(`${t.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={t.href} className={className} title="当前账号无访问该页的权限">
{t.label}
</span>
);
}
return (
<Link key={t.href} href={t.href} className={className}>
{t.label}
</Link>
);
})}
</nav>
);
}