blob: 9dbf288b43be6b7f15796e6be05b7b32cfe24b7b [file] [log] [blame]
import {createStore} from 'vuex';
import {KillSwitchServicePromiseClient} from '../api_proto/kill_switch_grpc_web_pb.js';
export const store = createStore({
state() {
return {
jwtToken: localStorage.getItem('jwtToken'),
client: null,
};
},
mutations: {
setJwtToken(state, token) {
if (token == null)
localStorage.removeItem('jwtToken');
else
localStorage.jwtToken = token;
state.jwtToken = token;
},
},
getters: {
getJwtToken(state) {
return state.jwtToken;
},
isSignedIn(state) {
return state.jwtToken != null;
},
},
actions: {
connectClient(store, host) {
store.state.client = new KillSwitchServicePromiseClient(host, null, null);
},
},
});