fix: replace 'as const' with explicit type annotation for NAV_ITEMS

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 <noreply@anthropic.com>
This commit is contained in:
soufiane 2025-11-18 01:43:34 +01:00
parent a363e0ab7f
commit 40cdd2777c
2 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -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 = {