NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exhibition.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import api from '../../utils/api'
  2. const state = {
  3. all: [],
  4. loaded: false,
  5. singleExhibition: null,
  6. }
  7. const getters = {
  8. allExhibitions: state => state.all,
  9. allExhibitionsLoaded: state => state.loaded,
  10. }
  11. const actions = {
  12. getAllExhibitions({ commit }, sortType) {
  13. commit('CLEAR_EXHIBITIONS')
  14. commit('EXHIBITIONS_LOADED', false)
  15. return api.getByType('exhibitions', sortType, exhibitions => {
  16. commit('STORE_FETCHED_EXHIBITIONS', { exhibitions })
  17. commit('EXHIBITIONS_LOADED', true)
  18. })
  19. },
  20. getSingleExhibition({ commit }, id) {
  21. commit('CLEAR_SINGLE_EXHIBITION')
  22. commit('EXHIBITIONS_LOADED', false)
  23. api.getSingleType('exhibitions', id, exhibition => {
  24. commit('STORE_FETCHED_SINGLE_EXHIBITION', exhibition)
  25. commit('EXHIBITIONS_LOADED', true)
  26. })
  27. },
  28. }
  29. const mutations = {
  30. STORE_FETCHED_EXHIBITIONS(state, { exhibitions }) {
  31. state.all = exhibitions
  32. },
  33. STORE_FETCHED_SINGLE_EXHIBITION(state, exhibition) {
  34. state.singleExhibition = exhibition
  35. },
  36. CLEAR_EXHIBITIONS(state) {
  37. state.all = []
  38. },
  39. CLEAR_SINGLE_EXHIBITION(state) {
  40. state.singleExhibition = null
  41. },
  42. EXHIBITIONS_LOADED(state, val) {
  43. state.loaded = val
  44. },
  45. }
  46. export default { state, getters, actions, mutations }