/ Basic nuxt setup (some areas still broken)

This commit is contained in:
Alexis
2021-03-26 12:23:54 +01:00
parent 19ee29b936
commit 5ca4f4eceb
56 changed files with 19612 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# STORE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Vuex Store files.
Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).

View File

@@ -0,0 +1,50 @@
import toastStore from './toasts'
export default {
state: () => ({
user: {
avatarUrl: '',
favourites: []
}
}),
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)
}
},
mutations: {
addFav: (state, celestialId) => {
state.user.favourites.push({ id: celestialId })
},
removeFav: (state, celestialId) => {
state.user.favourites = state.user.favourites.filter(
fav => fav.id !== celestialId
)
}
},
actions: {
toggleFav: ({ commit, getters }, celestialId) => {
// If the celestial is not faved
if (!getters.isFav(celestialId)) {
// ... favs it
commit('addFav', celestialId)
} else {
// ...else unfavs
commit('removeFav', celestialId)
}
}
},
modules: {
toasts: {
namespaced: true,
state: toastStore.state,
mutations: toastStore.mutations,
actions: toastStore.actions
}
}
}

View File

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