refactor(dashboard): extract RoleGuard and unify mobile nav with Button

This commit is contained in:
zetaloop
2026-02-25 15:18:20 +08:00
parent f8659b5ebc
commit 37d83d8805
5 changed files with 86 additions and 51 deletions
@@ -42,10 +42,6 @@ export default function ServicesPage() {
const scopedPlayerIdSet = new Set(scopedPlayerIds)
const scopedServices = services.filter((service) => scopedPlayerIdSet.has(service.playerId))
if (currentRole !== "player" && currentRole !== "owner") {
return <div className="text-sm text-muted-foreground"></div>
}
return (
<div className="container mx-auto max-w-6xl px-4 py-8 space-y-8">
<div className="flex items-center justify-between">
+2 -15
View File
@@ -1,16 +1,11 @@
"use client"
import Link from "next/link"
import { AuthGuard } from "@/components/auth-guard"
import { DashboardSidebar } from "@/components/dashboard-sidebar"
import { Header } from "@/components/header"
import { Button } from "@/components/ui/button"
import { useAuthStore } from "@/store/auth"
import { RoleGuard } from "@/components/role-guard"
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
const isAuthenticated = useAuthStore((state) => state.isAuthenticated)
const currentRole = useAuthStore((state) => state.currentRole)
return (
<div className="flex min-h-screen flex-col">
<Header />
@@ -20,15 +15,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
</div>
<main className="flex-1 p-6">
<AuthGuard>
{isAuthenticated && currentRole === "consumer" ? (
<div className="flex min-h-[50vh] items-center justify-center">
<Button asChild>
<Link href="/"></Link>
</Button>
</div>
) : (
children
)}
<RoleGuard>{children}</RoleGuard>
</AuthGuard>
</main>
</div>