mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
location: treat 422 error when POSTing new location
This commit is contained in:
parent
c7b9a1a3fe
commit
fa0b9271c2
@ -78,7 +78,8 @@
|
|||||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
|
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
|
||||||
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
import { getLocationTypes, postLocation } from "../../api";
|
import { getLocationTypes } from "../../api";
|
||||||
|
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "NewLocation",
|
name: "NewLocation",
|
||||||
@ -220,7 +221,6 @@ export default {
|
|||||||
},
|
},
|
||||||
saveNewLocation() {
|
saveNewLocation() {
|
||||||
if (this.checkForm()) {
|
if (this.checkForm()) {
|
||||||
console.log('saveNewLocation', this.selected);
|
|
||||||
let body = {
|
let body = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
name: this.selected.name,
|
name: this.selected.name,
|
||||||
@ -239,29 +239,28 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
postLocation(body)
|
|
||||||
.then(
|
|
||||||
location => new Promise(resolve => {
|
|
||||||
|
|
||||||
this.$store.dispatch('addAvailableLocationGroup', {
|
makeFetch('POST', '/api/1.0/main/location.json', body)
|
||||||
locationGroup: 'Localisations nouvellement créées',
|
.then(response => {
|
||||||
locations: [location]
|
this.$store.dispatch('addAvailableLocationGroup', {
|
||||||
});
|
locationGroup: 'Localisations nouvellement créées',
|
||||||
|
locations: [response]
|
||||||
this.$store.dispatch('updateLocation', location);
|
});
|
||||||
|
this.$store.dispatch('updateLocation', response);
|
||||||
resolve();
|
this.modal.showModal = false;
|
||||||
this.modal.showModal = false;
|
})
|
||||||
})
|
.catch((error) => {
|
||||||
).catch(
|
if (error.name === 'ValidationException') {
|
||||||
err => {
|
for (let v of error.violations) {
|
||||||
this.errors.push(err.message);
|
this.errors.push(v);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.errors.push('An error occurred');
|
||||||
}
|
}
|
||||||
);
|
})
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
submitNewAddress(payload) {
|
submitNewAddress(payload) {
|
||||||
console.log('submitNewAddress', payload);
|
|
||||||
this.selected.addressId = payload.addressId;
|
this.selected.addressId = payload.addressId;
|
||||||
this.addAddress.context.addressId = payload.addressId;
|
this.addAddress.context.addressId = payload.addressId;
|
||||||
this.addAddress.context.edit = true;
|
this.addAddress.context.edit = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user