import Vue from 'vue'
import Vuex from 'vuex'
import sdk from "../sdk/index"

Vue.use(Vuex)

export default new Vuex.Store({
	strict: true,
	state: {
		token: localStorage.getItem("token")
	},
	getters: {
		token: state => state.token,
	},
	mutations: {
		setToken(state, token) {
			state.token = token
		}
	},
	actions: {
		login({ commit }, token) {
			commit('setToken', token)
			// commit('route/ROUTE_CHANGED',{to: {path: '/'}})
		},
		fetch({ state }, params) {
			sdk.fetch(params, state.token)
		},
		upload({ state }, params) {
			return sdk.uploadCustom(params, state.token)
		}
	}
})
