43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import type { PageAccess, minisidebar } from "@/types/menuAkses/access";
|
|
|
|
export const useHakAksesStore = defineStore("hakAksesMenu", {
|
|
state: () => ({
|
|
role: "",
|
|
pageAccess: [] as PageAccess[], //Array halaman dari backend
|
|
iconItem: [] as minisidebar[],
|
|
mergedSidebar: [],
|
|
permissionPage: [], //hasil merge halaman dengan permissions
|
|
}),
|
|
|
|
actions: {
|
|
setAccess(payload: {
|
|
role: string;
|
|
pages: PageAccess[];
|
|
icons: minisidebar[];
|
|
}) {
|
|
this.role = payload.role;
|
|
this.pageAccess = payload.pages;
|
|
this.iconItem = payload.icons;
|
|
},
|
|
|
|
resetAccess() {
|
|
this.role = "";
|
|
this.pageAccess = [];
|
|
this.mergedSidebar = [];
|
|
},
|
|
|
|
setMergedSidebar(sidebar: any) {
|
|
this.mergedSidebar = sidebar;
|
|
},
|
|
|
|
setPermissionPage(permission: any) {
|
|
this.permissionPage = permission;
|
|
},
|
|
},
|
|
// persist: {
|
|
// storage: piniaPluginPersistedstate.localStorage(),
|
|
// },
|
|
// persist: true,
|
|
});
|