From 40cdd2777c30eb2e2466aa4d34c76afa72e667d8 Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 18 Nov 2025 01:43:34 +0100 Subject: [PATCH] fix: replace 'as const' with explicit type annotation for NAV_ITEMS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove 'as const' assertion from NAV_ITEMS and add explicit type annotation with Array<'CLIENT' | 'EMPLOYEE' | 'ADMIN'> for roles property. This allows TypeScript to properly type-check the includes() method in Navbar component without requiring type assertions. Also revert the 'as any' workaround in Navbar.tsx since the proper typing is now in place. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- components/Navbar.tsx | 2 +- utils/constants.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 35f6291..48ca3f4 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -13,7 +13,7 @@ export default function Navbar() { const filteredNavItems = NAV_ITEMS.filter((item) => { if (!user) return false; - return item.roles.includes(user.role as any); + return item.roles.includes(user.role); }); const isActive = (href: string) => pathname === href; diff --git a/utils/constants.ts b/utils/constants.ts index b4c7da5..dbc366c 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -101,7 +101,11 @@ export const ROUTES = { } as const; // Role-based Navigation -export const NAV_ITEMS = [ +export const NAV_ITEMS: Array<{ + label: string; + href: string; + roles: Array<'CLIENT' | 'EMPLOYEE' | 'ADMIN'>; +}> = [ { label: 'Accueil', href: ROUTES.HOME, @@ -167,7 +171,7 @@ export const NAV_ITEMS = [ href: ROUTES.ADMIN_DRAWS, roles: ['ADMIN'], }, -] as const; +]; // Ticket Status export const TICKET_STATUS = {