fix(pages): scope order views to the active role

This commit is contained in:
zetaloop
2026-04-24 08:58:35 +08:00
parent 3b82602c38
commit ffb420f7e7
3 changed files with 120 additions and 81 deletions
+3 -2
View File
@@ -50,6 +50,7 @@ export function Header() {
const ownerShop = useShopStore((state) =>
user ? state.shops.find((shop) => shop.owner.id === user.id) : undefined,
)
const canOpenDashboard = currentRole === "player" || currentRole === "owner"
const navLinks =
currentRole === "consumer"
@@ -64,7 +65,7 @@ export function Header() {
{ href: "/community", label: "社区" },
{ href: "/orders", label: "订单" },
{ href: "/chat", label: "消息" },
{ href: "/dashboard", label: "管理后台" },
...(canOpenDashboard ? [{ href: "/dashboard", label: "管理后台" }] : []),
]
const availableRoles = (Object.entries(roleLabels) as [UserRole, string][]).filter(([role]) =>
@@ -209,7 +210,7 @@ export function Header() {
</Link>
</DropdownMenuItem>
{(currentRole === "player" || currentRole === "owner") && (
{canOpenDashboard && (
<DropdownMenuItem asChild>
<Link href="/dashboard">
<Gamepad2 className="mr-2 h-4 w-4" />