Blame view

src/store/store.js 1.14 KB
03dcbf0c1   Neeraj Sharma   fix all api and r...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  import Vue from 'vue'
  import Vuex from 'vuex'
  import createPersistedState from 'vuex-persistedstate'
  
  Vue.use(Vuex)
  
  export default new Vuex.Store({
      strict:true,
      plugins:[
          createPersistedState() 
      ],
      state: {
          token: null,
          data: null,
          isUserLoggedIn: false,
e3e2a04c6   Neeraj Sharma   first commit
16
          id: null,
03dcbf0c1   Neeraj Sharma   fix all api and r...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
      },
      // serve as the one and only way to change the state of the data in the state object
      mutations: {
          setToken (state, token) {
              state.token = token
              //state.isUserLoggedIn = !!(token)
          if (token != null) {
              state.isUserLoggedIn = true
             } else {
              state.isUserLoggedIn = false
          } 
          },
          setUser (state, data) {
              state.data = data
          },
e3e2a04c6   Neeraj Sharma   first commit
32
33
          Id (state, id) {
                state.id = id
03dcbf0c1   Neeraj Sharma   fix all api and r...
34
          },
03dcbf0c1   Neeraj Sharma   fix all api and r...
35
36
37
38
39
40
41
42
43
      }, 
      //Action methods are referred to as being "dispatched"
      actions: {
          setToken ({commit}, token) {
              commit('setToken', token)
          },
          setUser ({commit}, data) {
              commit('setUser', data)
          },
e3e2a04c6   Neeraj Sharma   first commit
44
45
          Id ({commit}, id) {
              commit('Id', id)
eba96ec51   Neeraj Sharma   set login name on...
46
          }
03dcbf0c1   Neeraj Sharma   fix all api and r...
47
48
49
50
  
      }
    
  })