Created
September 19, 2022 13:19
-
-
Save KatarinaT/10f788afae9c7a1cb037ce5377366d2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>>>> actions.js | |
############################### | |
import Api from "@/helpers/api"; | |
export const actions = { | |
async loadEvents(context, payload) { | |
let result; | |
try { | |
result = (await Api.getEventsList(payload.page, payload.perPage))?.data; | |
} catch (e) { | |
console.error("events list getting error: ", e); | |
result = []; | |
} | |
context.commit('setEvents', result); | |
}, | |
async loadEventsByDates(context, payload) { | |
let result; | |
try { | |
result = (await Api.getEventsByFilters(payload.start, payload.end))?.data; | |
} catch (e) { | |
console.error("events list by dates getting error: ", e); | |
} | |
context.commit('setEvents', result); | |
} | |
} | |
>>>>> mutations.js | |
############################### | |
export const mutations = { | |
setEvents(state, eventList) { | |
state.events = eventList; | |
} | |
}; | |
>>>>> getters.js | |
############################### | |
import {EventConverter} from "@/helpers/eventConverter"; | |
export const getters = { | |
getEvents: state => { | |
return EventConverter.getConvertedEvents(state.events); | |
} | |
} | |
>>>>> index.js | |
############################### | |
import Vue from 'vue'; | |
import Vuex from 'vuex'; | |
import {actions} from './action'; | |
import {getters} from './getters'; | |
import {mutations} from './mutations'; | |
Vue.use(Vuex); | |
export const store = new Vuex.Store({ | |
state: { | |
events: [] | |
}, | |
actions, | |
getters, | |
mutations | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment