fix(FE) : fix store token

This commit is contained in:
Yusron alamsyah
2026-02-24 14:33:16 +07:00
parent b122aa6dad
commit 23f668ae3f
7 changed files with 134 additions and 101 deletions
@@ -7,57 +7,9 @@ import { Icon } from "@iconify/vue";
import { useRoute } from "vue-router";
// MiniSidebar Icons
import MiniSideIcons from "./MinIconItems";
import { useHakAkses } from "~/composables/useHakAkses";
const route = useRoute();
const { getAllowedPages } = useHakAkses();
const allowedPages = ref<string[]>([]);
const isLoadingAccess = ref(true);
// Fetch allowed pages on mount
onMounted(async () => {
try {
allowedPages.value = await getAllowedPages();
console.log('Allowed pages for user:', allowedPages.value);
} catch (error) {
console.error('Error loading allowed pages:', error);
} finally {
isLoadingAccess.value = false;
}
});
// Filter sidebar items based on user's allowed pages
const filteredSidebarItems = computed(() => {
if (isLoadingAccess.value) {
return [];
}
// If no allowed pages, return empty (no access)
if (allowedPages.value.length === 0) {
return [];
}
return sidebarItems.map(section => {
// Filter children based on allowed pages
const filteredChildren = section.children?.filter(child => {
if (child.to) {
return allowedPages.value.includes(child.to);
}
return false;
});
// Only include section if it has visible children
if (filteredChildren && filteredChildren.length > 0) {
return {
...section,
children: filteredChildren
};
}
return null;
}).filter(item => item !== null);
});
const findTitleByPath = (items: any, path: any) => {
let title = "";