diff options
author | Mateja <mail@matejamaric.com> | 2021-03-21 18:05:38 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-03-21 18:05:38 +0100 |
commit | 2809ccf7272d4b77c5eb3f3d6599143dc4678d70 (patch) | |
tree | 1c46dd969ecbdb4b89e69051cab2395e2e510afe /resources/js/store.js | |
parent | 09ee04d39911f169457567c869d732a11387651a (diff) | |
download | yota-laravel-2809ccf7272d4b77c5eb3f3d6599143dc4678d70.tar.gz yota-laravel-2809ccf7272d4b77c5eb3f3d6599143dc4678d70.zip |
Work on `reservation.vue` component.
- Move Lodash cloneDeep to Vuex store.
Diffstat (limited to 'resources/js/store.js')
-rw-r--r-- | resources/js/store.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/resources/js/store.js b/resources/js/store.js index 345b866..e0c4383 100644 --- a/resources/js/store.js +++ b/resources/js/store.js @@ -17,6 +17,9 @@ export default new Vuex.Store({ }, getData(state) { return state.data; + }, + getDataRow(state) { + return (index) => _.cloneDeep(state.data[index]); } }, mutations: { @@ -28,6 +31,12 @@ export default new Vuex.Store({ }, setData(state, data) { state.data = data; + }, + setDataRow(state, row) { + state.data[row.index] = _.cloneDeep(row.data); + }, + removeDataRow(state, index) { + state.data.splice(index, 1); } }, actions: { @@ -54,6 +63,15 @@ export default new Vuex.Store({ }).catch(error => { console.log(error); }); + }, + async pushReservation(context, data) { + context.commit('setDataRow', { + index: data.index, + data: data.reservation + }); + }, + async removeReservation(context, index) { + context.commit('removeDataRow', index); } } }); |