osm_my_commerce/store/index.js

57 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-01-21 12:34:21 +01:00
/**
* see VueX docs
*/
2020-12-17 12:09:28 +01:00
export const state = () => ({
2023-03-02 09:53:23 +01:00
counter: 0,
isFetching: false,
searchInput: 'librairie interlignes',
2021-01-21 12:34:21 +01:00
selectedResult: null,
2023-03-02 09:53:23 +01:00
fetchedData: {
osm_data: '',
addok_data: '',
},
2023-03-02 09:53:23 +01:00
list: [],
formConfig: {
name: '',
2021-01-21 12:34:21 +01:00
delivery: false,
2023-03-02 09:53:23 +01:00
hours: ['a', 'b'],
tags: [],
2021-01-21 12:34:21 +01:00
},
2020-12-17 12:09:28 +01:00
})
export const mutations = {
2021-01-28 13:12:24 +01:00
increment(state) {
2020-12-17 12:09:28 +01:00
state.counter++
},
2021-01-28 13:12:24 +01:00
add(state, text) {
2020-12-17 12:09:28 +01:00
state.list.push({
text,
done: false,
})
},
2021-01-28 13:12:24 +01:00
remove(state, { todo }) {
2023-03-02 09:53:23 +01:00
state.list.splice(state.list.indexOf(todo), 1)
2020-12-17 12:09:28 +01:00
},
2021-01-28 13:12:24 +01:00
setFormField(state, { field }) {
2023-03-02 09:53:23 +01:00
state.formConfig[state.formConfig.indexOf(field)] = field
},
setFetchedDataOsm(state, { data }) {
2023-03-02 09:53:23 +01:00
state.fetchedData.osm_data = data
},
setFetchedDataAddok(state, { data }) {
2023-03-02 09:53:23 +01:00
state.fetchedData.addok_data = data
2020-12-17 12:09:28 +01:00
},
2021-01-28 13:12:24 +01:00
setTag(state, { field }) {
2023-03-02 09:53:23 +01:00
state.formConfig.tags[state.formConfig.tags.indexOf(field)] = field
},
setSelectedResult(state, { data }) {
2023-03-02 09:53:23 +01:00
state.selectedResult = data
},
setFetching(state, { data }) {
2023-03-02 09:53:23 +01:00
state.isFetching = data
},
setAllTag(state, { tags }) {
2023-03-02 09:53:23 +01:00
state.formConfig.tags = tags
2021-01-21 12:34:21 +01:00
},
2020-12-17 12:09:28 +01:00
}