export const Modes = { VIEW: "VIEW", ADD: "ADD", EDIT: "EDIT" } export const dataStore = Vuex.createStore({ state () { mode : Modes.VIEW; oldStudent : new Object(); selectedStudent : new Object(); }, mutations: { add(state) { state.selectedStudent = new Object(); state.mode = Modes.ADD; }, edit(state, student) { state.selectedStudent = student; state.oldStudent = student; state.mode = Modes.EDIT; }, view(state, student) { state.selectedStudent = student; state.mode = Modes.VIEW; }, oldStudent(state) { state.selectedStudent = state.oldStudent; state.mode = Modes.VIEW; } }, plugins: [window.createPersistedState({storage: window.sessionStorage})] })