lty/qy-lty-admin/components/dashboard-shell.tsx
pmc bd95ba470c feat: update admin panel, API modules, and add migrations
- Update food, outfits, props, home-decor pages and components
- Add permissions page and sidebar updates
- Update API client and all API modules (auth, food, dances, etc.)
- Add card model migrations for optional fields
- Update Django views, serializers, and authentication
- Add affinity level migrations and user app updates
- Add project documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 13:06:50 +08:00

50 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client"
import type React from "react"
import { useEffect, useState } from "react"
import { usePathname } from "next/navigation"
import { cn } from "@/lib/utils"
import { Sidebar } from "@/components/sidebar"
import { hasPathPermission, getUserRole } from "@/lib/permissions"
import { Button } from "@/components/ui/button"
import { ShieldX } from "lucide-react"
import Link from "next/link"
interface DashboardShellProps extends React.HTMLAttributes<HTMLDivElement> {}
export function DashboardShell({ children, className, ...props }: DashboardShellProps) {
const pathname = usePathname()
const [allowed, setAllowed] = useState<boolean | null>(null)
useEffect(() => {
setAllowed(hasPathPermission(pathname))
}, [pathname])
const showAccessDenied = allowed === false
return (
<div className="grid min-h-screen w-full md:grid-cols-[280px_1fr] bg-gradient-to-br from-gray-50 to-white">
<Sidebar />
<main className={cn("flex flex-col relative overflow-hidden", className)} {...props}>
<div className="flex-1 space-y-6 p-8 pt-6">
{showAccessDenied ? (
<div className="flex flex-col items-center justify-center h-[60vh]">
<ShieldX className="h-16 w-16 text-red-400 mb-4" />
<h1 className="text-2xl font-bold mb-2">访</h1>
<p className="text-gray-500 mb-2">
{getUserRole()}访
</p>
<p className="text-gray-400 text-sm mb-6"></p>
<Button asChild>
<Link href="/"></Link>
</Button>
</div>
) : (
children
)}
</div>
</main>
</div>
)
}