aboutsummaryrefslogtreecommitdiff
path: root/resources/js
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-03-21 19:44:08 +0100
committerMateja <mail@matejamaric.com>2021-03-21 19:44:08 +0100
commit668b6005f0ce55f1c9c8d2cdcdf48903d6207dc7 (patch)
tree9fdb2ed6500526b9940ac2363358d23056be93b9 /resources/js
parent2809ccf7272d4b77c5eb3f3d6599143dc4678d70 (diff)
downloadyota-laravel-668b6005f0ce55f1c9c8d2cdcdf48903d6207dc7.tar.gz
yota-laravel-668b6005f0ce55f1c9c8d2cdcdf48903d6207dc7.zip
api: update and delete reservations
Diffstat (limited to 'resources/js')
-rw-r--r--resources/js/store.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/resources/js/store.js b/resources/js/store.js
index e0c4383..117db93 100644
--- a/resources/js/store.js
+++ b/resources/js/store.js
@@ -65,13 +65,32 @@ export default new Vuex.Store({
});
},
async pushReservation(context, data) {
- context.commit('setDataRow', {
- index: data.index,
- data: data.reservation
+ await axios.post('/api/reservations', {
+ action: 'update',
+ ...data.reservation
+ }).then(() => {
+ context.commit('setDataRow', {
+ index: data.index,
+ data: data.reservation
+ });
+ }).catch(error => {
+ console.log(error);
+ alert("Couldn't update reservation! Bad data!");
});
},
async removeReservation(context, index) {
- context.commit('removeDataRow', index);
+ let data = {
+ action: 'delete',
+ ...this.state.data[index]
+ };
+ if (confirm(`Are you sure you want to delete reservation #${data.id} made by ${data.operatorCall}?`) === true) {
+ await axios.post('/api/reservations', data).then(() => {
+ context.commit('removeDataRow', index);
+ }).catch(error => {
+ console.log(error);
+ alert('Unable to remove reservation!');
+ });
+ }
}
}
});