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:
@@ -61,13 +61,13 @@ export async function middleware(req: NextRequest) {
|
||||
|
||||
console.log("Middleware: Auth check successful");
|
||||
|
||||
// Admin-only protection for /admin routes
|
||||
if (pathname.startsWith('/admin')) {
|
||||
// Admin-only protection for /dashboard/admin routes
|
||||
if (pathname.startsWith('/dashboard/admin')) {
|
||||
try {
|
||||
const user = await res.json();
|
||||
const username = user?.vendor?.username;
|
||||
if (username !== 'admin1') {
|
||||
console.log("Middleware: Non-admin attempted to access /admin, redirecting");
|
||||
console.log("Middleware: Non-admin attempted to access /dashboard/admin, redirecting");
|
||||
return NextResponse.redirect(new URL("/dashboard", req.url));
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -84,5 +84,5 @@ export async function middleware(req: NextRequest) {
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/dashboard/:path*", "/admin/:path*", "/auth/reset-password/:path*"],
|
||||
matcher: ["/dashboard/:path*", "/auth/reset-password/:path*"],
|
||||
};
|
||||
Reference in New Issue
Block a user