mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
import Vuex from 'vuex'
|
|
import Vue from 'vue'
|
|
import createPersistedState from 'vuex-persistedstate'
|
|
import CONFIG from '../config'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
export const mutations = {
|
|
openCreationsPlus: (state, i) => {
|
|
state.openCreations += i
|
|
},
|
|
openCreationsMinus: (state, i) => {
|
|
state.openCreations -= i
|
|
},
|
|
resetOpenCreations: (state) => {
|
|
state.openCreations = 0
|
|
},
|
|
token: (state, token) => {
|
|
state.token = token
|
|
},
|
|
setOpenCreations: (state, openCreations) => {
|
|
state.openCreations = openCreations
|
|
},
|
|
moderator: (state, moderator) => {
|
|
state.moderator = moderator
|
|
},
|
|
}
|
|
|
|
export const actions = {
|
|
logout: ({ commit, state }) => {
|
|
commit('token', null)
|
|
commit('moderator', null)
|
|
window.localStorage.clear()
|
|
},
|
|
}
|
|
|
|
const store = new Vuex.Store({
|
|
plugins: [
|
|
createPersistedState({
|
|
storage: window.localStorage,
|
|
}),
|
|
],
|
|
state: {
|
|
token: CONFIG.DEBUG_DISABLE_AUTH ? 'validToken' : null,
|
|
moderator: null,
|
|
openCreations: 0,
|
|
},
|
|
// Syncronous mutation of the state
|
|
mutations,
|
|
actions,
|
|
})
|
|
|
|
export default store
|