Blame view

src/store/store.js 2.2 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
          role: null,
68d742034   Neeraj Sharma   implement new des...
18
19
20
          // schoolId: null,
          schoolToken: null,
          schoolRole: null
03dcbf0c1   Neeraj Sharma   fix all api and r...
21
22
23
      },
      // serve as the one and only way to change the state of the data in the state object
      mutations: {
37150e7c1   Neeraj Sharma   implement school ...
24
          setToken(state, token) {
03dcbf0c1   Neeraj Sharma   fix all api and r...
25
              state.token = token
37150e7c1   Neeraj Sharma   implement school ...
26
27
28
29
30
31
                  //state.isUserLoggedIn = !!(token)
              if (token != null) {
                  state.isUserLoggedIn = true
              } else {
                  state.isUserLoggedIn = false
              }
03dcbf0c1   Neeraj Sharma   fix all api and r...
32
          },
68d742034   Neeraj Sharma   implement new des...
33
34
35
36
37
38
39
40
41
          setSchoolToken(state, schoolToken) {
              state.schoolToken = schoolToken
                  //state.isUserLoggedIn = !!(token)
              if (schoolToken != null) {
                  state.isSchoolLoggedIn = true
              } else {
                  state.isSchoolLoggedIn = false
              }
          },
37150e7c1   Neeraj Sharma   implement school ...
42
          setUser(state, data) {
03dcbf0c1   Neeraj Sharma   fix all api and r...
43
44
              state.data = data
          },
37150e7c1   Neeraj Sharma   implement school ...
45
46
          Id(state, id) {
              state.id = id
03dcbf0c1   Neeraj Sharma   fix all api and r...
47
          },
37150e7c1   Neeraj Sharma   implement school ...
48
49
          Role(state, role) {
              state.role = role
99cd79184   Neeraj Sharma   implement all tas...
50
          },
68d742034   Neeraj Sharma   implement new des...
51
52
53
54
55
56
          setSchoolRole(state, schoolRole) {
              state.schoolRole = schoolRole
          },
          // SchoolId(state, schoolId) {
          //     state.schoolId = schoolId
          // }
37150e7c1   Neeraj Sharma   implement school ...
57
      },
03dcbf0c1   Neeraj Sharma   fix all api and r...
58
59
      //Action methods are referred to as being "dispatched"
      actions: {
37150e7c1   Neeraj Sharma   implement school ...
60
          setToken({ commit }, token) {
03dcbf0c1   Neeraj Sharma   fix all api and r...
61
62
              commit('setToken', token)
          },
68d742034   Neeraj Sharma   implement new des...
63
64
65
          setSchoolToken({ commit }, schoolToken) {
              commit('setSchoolToken', schoolToken)
          },
37150e7c1   Neeraj Sharma   implement school ...
66
          setUser({ commit }, data) {
03dcbf0c1   Neeraj Sharma   fix all api and r...
67
68
              commit('setUser', data)
          },
37150e7c1   Neeraj Sharma   implement school ...
69
          Id({ commit }, id) {
e3e2a04c6   Neeraj Sharma   first commit
70
              commit('Id', id)
37150e7c1   Neeraj Sharma   implement school ...
71
72
73
          },
          Role({ commit }, role) {
              commit('Role', role)
99cd79184   Neeraj Sharma   implement all tas...
74
          },
68d742034   Neeraj Sharma   implement new des...
75
76
77
78
79
80
          setSchoolRole({ commit }, schoolRole) {
              commit('setSchoolRole', schoolRole)
          },
          // SchoolId({ commit }, schoolId) {
          //     commit('SchoolId', schoolId)
          // }
03dcbf0c1   Neeraj Sharma   fix all api and r...
81
82
  
      }
37150e7c1   Neeraj Sharma   implement school ...
83

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