diff --git a/app/(main)/components/sidebar.tsx b/app/(main)/components/sidebar.tsx new file mode 100644 index 0000000..22443f8 --- /dev/null +++ b/app/(main)/components/sidebar.tsx @@ -0,0 +1,80 @@ +import Link from 'next/link'; +import { createClient } from '@/app/lib/supabase/server-client'; + +type Role = 'default' | 'requestor' | 'admin' | 'superadmin' | 'owner'; + +type SidebarLink = { + label: string; + href: string; + allowedRoles: Role[]; +}; + +export default async function Sidebar() { + const supabase = await createClient(); + + // Get user claims (JWT) + const { data } = await supabase.auth.getClaims(); + const role = data?.claims?.user_role as Role | undefined; + + // Not logged in → no sidebar + if (!role) return null; + + const links: SidebarLink[] = [ + { + label: 'Home', + href: '/home', + allowedRoles: ['default', 'requestor', 'admin', 'superadmin', 'owner'], + }, + { + label: 'Profile', + href: '/profile', + allowedRoles: ['requestor', 'admin', 'superadmin', 'owner'], + }, + { + label: 'Request', + href: '/request', + allowedRoles: ['requestor', 'admin', 'superadmin', 'owner'], + }, + { + label: 'Outgoing Tickets', + href: '/outgoing-tickets', + allowedRoles: ['requestor', 'admin', 'superadmin', 'owner'], + }, + { + label: 'Manage', + href: '/manage', + allowedRoles: ['admin', 'superadmin', 'owner'], + }, + { + label: 'Incoming Tickets', + href: '/incoming-tickets', + allowedRoles: ['admin', 'superadmin', 'owner'], + }, + { + label: 'Team', + href: '/team', + allowedRoles: ['requestor', 'admin', 'superadmin', 'owner'], + }, + { + label: 'HQ', + href: '/hq', + allowedRoles: ['superadmin', 'owner'], + }, + ]; + + return ( + + ); +} diff --git a/app/(main)/hq/page.tsx b/app/(main)/hq/page.tsx new file mode 100644 index 0000000..496af6e --- /dev/null +++ b/app/(main)/hq/page.tsx @@ -0,0 +1,8 @@ +export default function HQPage() { + return ( +
+

HQ

+

This page is accessible to SUPERADMIN and OWNER users.

+
+ ); +} diff --git a/app/(main)/incoming-tickets/page.tsx b/app/(main)/incoming-tickets/page.tsx new file mode 100644 index 0000000..1bc80b0 --- /dev/null +++ b/app/(main)/incoming-tickets/page.tsx @@ -0,0 +1,8 @@ +export default function IncomingTicketsPage() { + return ( +
+

Incoming Tickets

+

Manage incoming requests, to be completed.

+
+ ); +} diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx new file mode 100644 index 0000000..9c3befb --- /dev/null +++ b/app/(main)/layout.tsx @@ -0,0 +1,20 @@ +import type { ReactNode } from 'react'; +import Sidebar from './components/sidebar'; + +export default function MainLayout({ + children, +}: { + children: ReactNode; +}) { + return ( +
+ {/* Sidebar */} + + + {/* Main page content */} +
+ {children} +
+
+ ); +} diff --git a/app/(main)/manage/page.tsx b/app/(main)/manage/page.tsx new file mode 100644 index 0000000..a55525e --- /dev/null +++ b/app/(main)/manage/page.tsx @@ -0,0 +1,8 @@ +export default function ManagePage() { + return ( +
+

Manage

+

Manage page, to be completed.

+
+ ); +} diff --git a/app/(main)/request/page.tsx b/app/(main)/request/page.tsx new file mode 100644 index 0000000..5fcb02b --- /dev/null +++ b/app/(main)/request/page.tsx @@ -0,0 +1,8 @@ +export default function RequestPage() { + return ( +
+

Request

+

Request page, to be completed.

+
+ ); +} diff --git a/app/(main)/team/page.tsx b/app/(main)/team/page.tsx new file mode 100644 index 0000000..cf6045a --- /dev/null +++ b/app/(main)/team/page.tsx @@ -0,0 +1,8 @@ +export default function TeamPage() { + return ( +
+

Team

+

Team page, to be completed.

+
+ ); +}