import roleService from "../services/roleService"; const state = { roles: [], // Store the roles here }; const mutations = { setUserRole(state, roles) { state.roles = roles; }, }; const actions = { async fetchUserRoles({ commit }) { try { // Pass commit to the service await roleService.fetchAndCommitRoles(commit); } catch (error) { } }, }; const getters = { isAdmin: (state) => state.roles.includes("admin"), canAccessPreviousEvent: (state) => (state.roles.includes("Ligne") == false) && (state.roles.includes("ligne") == false), }; export default { namespaced: true, state, mutations, actions, getters, };