import { useHakAksesStore } from '@/stores/sidebarMenuAkses/useMenuAksesStore'
import { mergeSidebar, mergeSidebarIcon } from '~/composables/sidebarMenu/mergeSidebar';
import sidebarRole from "@/stores/rolePages"; // data dummy
import sidebarItems from '~/components/layout/full/vertical-sidebar/sidebarItem'; //sidebar static dari template
import MiniSideIcons from '~/components/layout/full/vertical-sidebar/MinIconItems';


export function useSidebarAccess(data: any) {
  const sidebarMenu = shallowRef(sidebarItems);
  const sidebarMiniSideIcons = shallowRef(MiniSideIcons);
  
  const userRole = "admin";
  const roleSidebarItems = sidebarRole.filter(item => item.role === userRole);
  const mergedPages = mergeSidebar(sidebarMenu.value, roleSidebarItems[0].pages)
  data = mergeSidebarIcon(sidebarMiniSideIcons.value, roleSidebarItems[0].pages)
  console.log('mergedPages useSidebarAccess', mergedPages);

  return data
}











// export function useAccess() {

//   const store = useHakAksesStore()
//   const getRole = () => store.role
//   const getPages = () => store.pageAccess

//   const getPermissionsByPath = (path: string): string[] => {
//     const match = store.pageAccess.find(p => p.path === path)
//     return match?.permissions || []
//   }

//   return {
//     getRole,
//     getPages,
//     getPermissionsByPath
//   }
// }
