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.

carousel.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import axios from 'axios';
  2. export default {
  3. namespaced: true,
  4. state: {
  5. carouselList: [],
  6. carousel: {
  7. id: 0,
  8. propertyID: 0,
  9. timeshareID: 0,
  10. header: '',
  11. image: '',
  12. },
  13. },
  14. mutations: {
  15. setCarouselItem(state, item) {
  16. state.carousel = item;
  17. },
  18. setCarouselList(state, items) {
  19. state.carouselList = items;
  20. },
  21. addToCarouselList(state, item) {
  22. state.carouselList.push(item);
  23. },
  24. removeCarousel(state, id) {
  25. state.carouselList.pop(state.carouselList.find(p => p.id === id));
  26. },
  27. },
  28. getters: {},
  29. actions: {
  30. getCarouselItem({ commit }, id) {
  31. axios
  32. .get(`/api/Carousel/${id}`)
  33. .then(result => commit('setCarouselItem', result.data))
  34. .catch(console.error);
  35. },
  36. getCarouselList({ commit }) {
  37. axios
  38. .get('/api/Carousel')
  39. .then(result => commit('setCarouselList', result.data))
  40. .catch(console.error);
  41. },
  42. saveCarouselItem({ commit }, item) {
  43. axios
  44. .post('/api/Carousel', item)
  45. .then(result => commit('addToCarouselList', result.data))
  46. .catch(console.error);
  47. },
  48. deleteCarousel({ commit }, id) {
  49. axios
  50. .delete(`/api/Carousel/${id}`)
  51. .then(commit('removeCarousel', id))
  52. .catch(console.error);
  53. },
  54. },
  55. };