Add admin dashboard pages and restructure admin route

Introduces new admin dashboard pages for alerts, bans, invites, orders, settings, status, and vendors under app/dashboard/admin/. Moves the main admin page to the new dashboard structure and adds a shared admin layout. Updates sidebar configuration and adds supporting components and hooks for admin features.
This commit is contained in:
NotII
2025-10-18 15:19:10 +01:00
parent 03a2e37502
commit bfc60012cf
16 changed files with 2074 additions and 13 deletions

View File

@@ -2,17 +2,43 @@
import { useState } from "react"
import Link from "next/link"
import { useRouter } from "next/navigation"
import { ShoppingCart, LogOut } from "lucide-react"
import { useRouter, usePathname } from "next/navigation"
import { ShoppingCart, LogOut, Shield } from "lucide-react"
import { NavItem } from "./nav-item"
import { Button } from "@/components/ui/button"
import { sidebarConfig } from "@/config/sidebar"
import { adminSidebarConfig } from "@/config/admin-sidebar"
import { logoutUser } from "@/lib/utils/auth"
import { toast } from "sonner"
import { useUser } from "@/hooks/useUser"
const Sidebar: React.FC = () => {
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false)
const router = useRouter()
const pathname = usePathname()
const { isAdmin } = useUser()
// Determine if we're in admin area
const isAdminArea = pathname?.startsWith('/dashboard/admin')
// Filter sidebar config based on admin status
const getFilteredConfig = () => {
if (isAdminArea) {
return adminSidebarConfig
}
// Filter out admin section for non-admin users
return sidebarConfig.filter(section => {
if (section.title === "Administration") {
return isAdmin
}
return true
})
}
const currentConfig = getFilteredConfig()
const homeLink = isAdminArea ? '/dashboard/admin' : '/dashboard'
const icon = isAdminArea ? Shield : ShoppingCart
const handleLogout = async () => {
try {
@@ -39,15 +65,15 @@ const Sidebar: React.FC = () => {
`}
>
<div className="h-full flex flex-col">
<Link href="/dashboard" className="h-16 px-6 flex items-center border-b border-border">
<Link href={homeLink} className="h-16 px-6 flex items-center border-b border-border">
<div className="flex items-center gap-3">
<ShoppingCart className="h-6 w-6 text-foreground" />
{icon === Shield ? <Shield className="h-6 w-6 text-foreground" /> : <ShoppingCart className="h-6 w-6 text-foreground" />}
<span className="text-lg font-semibold text-foreground">Ember</span>
</div>
</Link>
<div className="flex-1 overflow-y-auto py-4 px-4 space-y-6">
{sidebarConfig.map((section, index) => (
{currentConfig.map((section, index) => (
<div key={index}>
<div className="px-3 mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
{section.title}