-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Need2Watch/store-rework
Store reworked & modularized
- Loading branch information
Showing
19 changed files
with
165 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,23 @@ | ||
import Vue from 'vue'; | ||
import Vuex from 'vuex'; | ||
import VuexPersistence from 'vuex-persist' | ||
import VuexPersistence from 'vuex-persist'; | ||
import loggedUser from './modules/loggedUser.store'; | ||
import movies from './modules/movies.store'; | ||
import currentMovie from './modules/currentMovie.store'; | ||
import scheduledEvents from './modules/scheduledEvents.store'; | ||
|
||
Vue.use(Vuex); | ||
|
||
const vuexLocal = new VuexPersistence({ | ||
storage: window.localStorage | ||
}) | ||
storage: window.localStorage, | ||
}); | ||
|
||
export default new Vuex.Store({ | ||
state: { | ||
loggedUser: { | ||
firstName: '', | ||
lastName: '', | ||
username: '', | ||
email: '', | ||
password: '', | ||
user_id: '', | ||
country: '', | ||
city: '', | ||
profilePicture: '', | ||
}, | ||
movies: [], | ||
currentMovie: {}, | ||
scheduledEvents: {}, | ||
}, | ||
getters: {}, | ||
mutations: { | ||
loadUser(state, payload) { | ||
state.loggedUser.firstName = payload.first_name; | ||
state.loggedUser.lastName = payload.last_name; | ||
state.loggedUser.username = payload.username; | ||
state.loggedUser.email = payload.email; | ||
state.loggedUser.password = payload.password; | ||
state.loggedUser.user_id = payload.user_id; | ||
state.loggedUser.country = payload.country; | ||
state.loggedUser.city = payload.city; | ||
state.loggedUser.profilePicture = payload.profile_picture; | ||
}, | ||
loadMovies(state, payload) { | ||
state.movies = payload; | ||
}, | ||
loadMovie(state, payload) { | ||
state.currentMovie = payload; | ||
}, | ||
followMovie(state) { | ||
state.currentMovie.following = !state.currentMovie.following; | ||
}, | ||
watchMovie(state) { | ||
state.currentMovie.watched = !state.currentMovie.watched; | ||
}, | ||
scheduleEvents(state, payload) { | ||
state.scheduledEvents = payload; | ||
} | ||
modules: { | ||
loggedUser, | ||
movies, | ||
currentMovie, | ||
scheduledEvents, | ||
}, | ||
actions: {}, | ||
plugins: [vuexLocal.plugin], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const state = { | ||
currentMovie: {}, | ||
}; | ||
|
||
const actions = { | ||
loadMovie({ commit }, payload) { | ||
commit('LOAD_MOVIE', payload); | ||
}, | ||
followMovie({ commit }) { | ||
commit('FOLLOW_MOVIES'); | ||
}, | ||
watchMovie({ commit }) { | ||
commit('WATCH_MOVIES'); | ||
}, | ||
}; | ||
|
||
const mutations = { | ||
LOAD_MOVIE(state, payload) { | ||
this.state.currentMovie = payload; | ||
}, | ||
FOLLOW_MOVIES(state) { | ||
this.state.currentMovie.following = !state.currentMovie.following; | ||
}, | ||
WATCH_MOVIES(state) { | ||
this.state.currentMovie.watched = !state.currentMovie.watched; | ||
}, | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
actions, | ||
state, | ||
mutations, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const state = { | ||
firstName: '', | ||
lastName: '', | ||
username: '', | ||
email: '', | ||
password: '', | ||
userId: '', | ||
country: '', | ||
city: '', | ||
profilePicture: '', | ||
}; | ||
|
||
const actions = { | ||
loadUser({ commit }, payload) { | ||
commit('LOAD_USER', payload); | ||
}, | ||
}; | ||
|
||
const mutations = { | ||
LOAD_USER(state, payload) { | ||
state.firstName = payload.first_name; | ||
state.lastName = payload.last_name; | ||
state.username = payload.username; | ||
state.email = payload.email; | ||
state.password = payload.password; | ||
state.userId = payload.user_id; | ||
state.country = payload.country; | ||
state.city = payload.city; | ||
state.profilePicture = payload.profile_picture; | ||
}, | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
actions, | ||
state, | ||
mutations, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const state = { | ||
movies: '', | ||
}; | ||
|
||
const actions = { | ||
loadMovies({ commit }, payload) { | ||
commit('LOAD_MOVIES', payload); | ||
}, | ||
}; | ||
|
||
const mutations = { | ||
LOAD_MOVIES(state, payload) { | ||
this.state.movies = payload; | ||
}, | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
actions, | ||
state, | ||
mutations, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const state = { | ||
scheduledEvents: {}, | ||
}; | ||
|
||
const actions = { | ||
scheduleEvents({ commit }, payload) { | ||
commit('SCHEDULE_EVENTS', payload); | ||
}, | ||
}; | ||
|
||
const mutations = { | ||
SCHEDULE_EVENTS(state, payload) { | ||
this.state.scheduledEvents = payload; | ||
}, | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
actions, | ||
state, | ||
mutations, | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.