Blame view

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

03dcbf0c1   Neeraj Sharma   fix all api and r...
64
  })