Sudah fix menunya, superadmin bisa memilihkan menu untuk user
This commit is contained in:
@@ -138,7 +138,7 @@ export default function Validasi() {
|
||||
});
|
||||
|
||||
cleanupStorage();
|
||||
router.replace('/waiting-room');
|
||||
window.location.href = '/waiting-room';
|
||||
};
|
||||
|
||||
// ✅ Verifikasi OTP untuk LOGIN
|
||||
@@ -167,7 +167,7 @@ export default function Validasi() {
|
||||
cleanupStorage();
|
||||
|
||||
if (!isActive) {
|
||||
router.replace('/waiting-room');
|
||||
window.location.href = '/waiting-room';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
// src/app/admin/(dashboard)/user&role/_com/dynamicNavbar.ts
|
||||
import { devBar, navBar, role1, role2, role3 } from '@/app/admin/_com/list_PageAdmin';
|
||||
|
||||
// ✅ Helper: normalisasi ID menu agar konsisten
|
||||
const normalizeMenuId = (id: string): string => {
|
||||
return id.trim().toLowerCase();
|
||||
};
|
||||
|
||||
export function getNavbar({
|
||||
roleId,
|
||||
menuIds,
|
||||
}: {
|
||||
roleId: number; // pastikan number
|
||||
menuIds?: string[] | null; // opsional
|
||||
roleId: number;
|
||||
menuIds?: string[] | null;
|
||||
}) {
|
||||
// Prioritas: menuIds > roleId
|
||||
// ✅ Jika menuIds tersedia, gunakan untuk filter — dengan normalisasi
|
||||
if (menuIds && menuIds.length > 0) {
|
||||
return navBar.filter(section => menuIds.includes(section.id));
|
||||
// Normalisasi semua menuIds dari DB/state
|
||||
const normalizedMenuSet = new Set(menuIds.map(id => normalizeMenuId(id)));
|
||||
|
||||
return navBar.filter(section => {
|
||||
const normalizedSectionId = normalizeMenuId(section.id);
|
||||
return normalizedMenuSet.has(normalizedSectionId);
|
||||
});
|
||||
}
|
||||
|
||||
// Fallback ke role-based
|
||||
// 🔁 Fallback ke role-based navigation
|
||||
if (roleId === 0) return devBar;
|
||||
if (roleId === 1) return navBar;
|
||||
if (roleId === 2) return role1;
|
||||
|
||||
Reference in New Issue
Block a user