updating openingdate parcours fixed

This commit is contained in:
Julie Lenaerts 2022-04-19 15:09:25 +02:00
parent 65e6471a02
commit bc550ea42a
3 changed files with 21 additions and 13 deletions

View File

@ -5,9 +5,9 @@
</h2>
<div>
<div class="mb-3 row">
<label class="col-form-label col-sm-4">{{ $t('startdate.date') }}</label>
<div class="col-sm-8">
<input class="form-control" type="date" v-model="startDate" @change="updateStartDate" />
<div class="col-sm-12 date-update">
<input class="form-control" type="date" id="startDate" v-model="startDate">
<button class="btn btn-save date-update-btn" type="submit" @click="updateStartDate"></button>
</div>
</div>
</div>
@ -23,10 +23,12 @@ import { mapState, mapGetters } from 'vuex';
export default {
name: 'startDate',
methods: {
updateStartDate(event) {
const date = event.target.value;
// console.log(date)
updateStartDate(e) {
e.preventDefault();
const date = e.target.previousSibling.value;
this.$store.dispatch('updateStartDate', date)
.then(this.$toast.open({type: 'success', message: this.$t('startdate.update')}))
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
@ -43,4 +45,14 @@ export default {
}
}
</script>
</script>
<style lang="scss" scoped>
.date-update {
display: flex;
justify-content: space-between;
&-btn {
margin-left: 1rem;
}
}
</style>

View File

@ -153,7 +153,7 @@ const appMessages = {
},
startdate: {
change: "Date d'ouverture",
date: "Date d'ouverture",
update: "La nouvelle date d'ouverture a été bien enregistrée"
},
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",

View File

@ -322,7 +322,6 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
}
},
updateStartDate(state, date) {
console.log('new state date', date)
state.accompanyingCourse.openingDate = date;
}
},
@ -814,11 +813,8 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
})
},
updateStartDate({commit}, payload) {
console.log('payload', payload)
const date = ISOToDate(payload);
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }};
console.log('body', body)
const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(ISOToDate(payload)) }};
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateStartDate', response.openingDate);