From 0587656ba65e083e3db04684762744a13fea164b Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Fri, 18 Dec 2020 19:34:02 +0100 Subject: [PATCH] - Store files --- client/src/components/timeline/timeline.vue | 307 ++++++++++++++++++++ client/src/store/index.js | 19 ++ client/src/store/modules/spell.store.js | 23 ++ client/src/store/modules/user.store.js | 59 ++++ 4 files changed, 408 insertions(+) create mode 100644 client/src/components/timeline/timeline.vue create mode 100644 client/src/store/index.js create mode 100644 client/src/store/modules/spell.store.js create mode 100644 client/src/store/modules/user.store.js diff --git a/client/src/components/timeline/timeline.vue b/client/src/components/timeline/timeline.vue new file mode 100644 index 0000000..458c53d --- /dev/null +++ b/client/src/components/timeline/timeline.vue @@ -0,0 +1,307 @@ + + + + + \ No newline at end of file diff --git a/client/src/store/index.js b/client/src/store/index.js new file mode 100644 index 0000000..22d2bb0 --- /dev/null +++ b/client/src/store/index.js @@ -0,0 +1,19 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; + +import VueCookies from 'vue-cookies'; +Vue.use(VueCookies); +Vue.$cookies.config('30d','',''); + +Vue.use(Vuex); + +import user from './modules/user.store'; + +const debug = process.env.NODE_ENV !== 'production'; + +export default new Vuex.Store({ + modules: { + user + }, + strict: debug +}); \ No newline at end of file diff --git a/client/src/store/modules/spell.store.js b/client/src/store/modules/spell.store.js new file mode 100644 index 0000000..0547e28 --- /dev/null +++ b/client/src/store/modules/spell.store.js @@ -0,0 +1,23 @@ +const state = { + +} + +const getters = { + +} + +const actions = { + +} + +const mutations = { + +} + +export default { + namespaced: true, + state, + getters, + actions, + mutations, +} \ No newline at end of file diff --git a/client/src/store/modules/user.store.js b/client/src/store/modules/user.store.js new file mode 100644 index 0000000..80f1e8e --- /dev/null +++ b/client/src/store/modules/user.store.js @@ -0,0 +1,59 @@ +// API +import { RepositoryFactory } from "~/api/repositories" +const Users = RepositoryFactory.get('users') + +export const namespaced = true + +const state = { + status: { + logged: false, + user_token: null, + } +}; + +const getters = { + getUserToken: state => { + if (state.status.logged) { + return state.status.user_token + } else { + return false + } + } +}; + +const mutations = { + loginUser(state, user_token) { + state.status.user_token = user_token; + state.status.logged = true; + }, + logoutUser(state) { + state.status.user_token = null; + state.status.logged = false; + } +}; + +const actions = { + user_login ({ commit }, data) { + return new Promise((resolve, reject) => { + Users.login(data) + .then(v => { + let user_token = v.data.token; + commit('loginUser', user_token); + resolve(user_token); + }) + .catch(() => { + reject(); + }); + }) + }, + user_logout ({ commit }) { + commit('logoutUser'); + } +}; + +export default { + state, + getters, + actions, + mutations, +};