import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'
import AuthModule from '@/store/modules/auth'
import LocalModule from '@/store/modules/local'

Vue.use(Vuex)

const vuexLocal = new VuexPersistence({
  key: 'local:shipnity',
  storage: window.localStorage,
  reducer: (state) => ({
    version: '0.0.1',
    local: state.local
  })
})

const store = new Vuex.Store({
  modules: {
    auth: AuthModule,
    local: LocalModule
  },
  plugins: [
    vuexLocal.plugin
  ]
})
export { AuthModule, LocalModule }
export default store
