| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import api from '../../utils/api'
-
- const state = {
- all: [],
- loaded: false,
- singleExhibition: null,
- }
-
- const getters = {
- allExhibitions: state => state.all,
- allExhibitionsLoaded: state => state.loaded,
- }
-
- const actions = {
- getAllExhibitions({ commit }, sortType) {
- commit('CLEAR_EXHIBITIONS')
- commit('EXHIBITIONS_LOADED', false)
- return api.getByType('exhibitions', sortType, exhibitions => {
- commit('STORE_FETCHED_EXHIBITIONS', { exhibitions })
- commit('EXHIBITIONS_LOADED', true)
- })
- },
- getSingleExhibition({ commit }, id) {
- commit('CLEAR_SINGLE_EXHIBITION')
- commit('EXHIBITIONS_LOADED', false)
- api.getSingleType('exhibitions', id, exhibition => {
- commit('STORE_FETCHED_SINGLE_EXHIBITION', exhibition)
- commit('EXHIBITIONS_LOADED', true)
- })
- },
- }
-
- const mutations = {
- STORE_FETCHED_EXHIBITIONS(state, { exhibitions }) {
- state.all = exhibitions
- },
- STORE_FETCHED_SINGLE_EXHIBITION(state, exhibition) {
- state.singleExhibition = exhibition
- },
- CLEAR_EXHIBITIONS(state) {
- state.all = []
- },
- CLEAR_SINGLE_EXHIBITION(state) {
- state.singleExhibition = null
- },
- EXHIBITIONS_LOADED(state, val) {
- state.loaded = val
- },
- }
-
- export default { state, getters, actions, mutations }
|