Fix Middleware
Fix Layout sesuai role, dan superadmin bisa menambahkan menu ke user jika diperlukan Penambahan menu di user & role : menu access
This commit is contained in:
22
src/app/admin/(dashboard)/user&role/_com/dynamicNavbar.ts
Normal file
22
src/app/admin/(dashboard)/user&role/_com/dynamicNavbar.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// src/app/admin/(dashboard)/user&role/_com/dynamicNavbar.ts
|
||||
import { navBar, role1, role2, role3 } from '@/app/admin/_com/list_PageAdmin';
|
||||
|
||||
export function getNavbar({
|
||||
roleId,
|
||||
menuIds,
|
||||
}: {
|
||||
roleId: number; // pastikan number
|
||||
menuIds?: string[] | null; // opsional
|
||||
}) {
|
||||
// Prioritas: menuIds > roleId
|
||||
if (menuIds && menuIds.length > 0) {
|
||||
return navBar.filter(section => menuIds.includes(section.id));
|
||||
}
|
||||
|
||||
// Fallback ke role-based
|
||||
if (roleId === 0) return navBar;
|
||||
if (roleId === 1) return role1;
|
||||
if (roleId === 2) return role2;
|
||||
if (roleId === 3) return role3;
|
||||
return [];
|
||||
}
|
||||
Reference in New Issue
Block a user