* Moved nuxt app to main app

This commit is contained in:
Alexis
2021-03-29 11:17:51 +02:00
parent e819e00822
commit d31a9aad7b
113 changed files with 10463 additions and 26133 deletions

46
store/index.js Normal file
View File

@@ -0,0 +1,46 @@
export const state = () => ({
user: {
avatarUrl: '',
favourites: []
}
})
export const getters = {
// Returns the number of favs for the user
favCount: (state) => {
return state.user.favourites.length
},
// Returns true if celestial is fav
isFav: state => (celestialId) => {
return state.user.favourites.find(fav => fav.id === celestialId)
}
}
export const mutations = {
addFav: (state, celestialId) => {
state.user.favourites.push({ id: celestialId })
},
removeFav: (state, celestialId) => {
state.user.favourites = state.user.favourites.filter(
fav => fav.id !== celestialId
)
}
}
export const actions = {
toggleFav: ({ commit, getters }, celestialId) => {
// If the celestial is not faved
if (!getters.isFav(celestialId)) {
commit('addFav', celestialId)
} else {
commit('removeFav', celestialId)
}
}
}
export default {
state,
getters,
mutations,
actions
}

27
store/toasts.js Normal file
View File

@@ -0,0 +1,27 @@
export const state = () => ({
queue: []
})
export const mutations = {
pushToast: (state, toast) => {
state.queue.push(toast)
},
purgeToast: (state, toastId) => {
state.queue = state.queue.filter(toast => toast.id !== toastId)
}
}
export const actions = {
pushToast: ({ commit }, toast) => {
commit('pushToast', toast)
},
purgeToast: ({ commit }, toastId) => {
commit('purgeToast', toastId)
}
}
export default {
state,
mutations,
actions
}