prepare vue Address to be used too in accompanyingCourse context

i18n is managed by root component:
* ok for person and household implementation (=> they use Address root component)
* but must be imported in vue i18n file if called from another component

submitAddress is emit to parent, it allow to control final action:
* casting final submitNewAddress with POST requests (for person or household entity);
* or dispatching changes from store, casting only payload to be used.

remove and simplify some options: backurl is always used with person/household,
and never if called from another vue component.
This commit is contained in:
2021-08-13 15:43:37 +02:00
parent 4b69f97e2f
commit 2f28e02f65
4 changed files with 79 additions and 59 deletions

View File

@@ -48,4 +48,32 @@ const postAddressToHousehold = (householdId, addressId) => {
};
export { postAddressToPerson, postAddressToHousehold };
/*
* Endpoint AccompanyingPeriod
* method POST, post AccompanyingPeriod AddressLocation (temporary address)
*
* @id integer - id of AccompanyingPeriod
* @body Object - dictionary with changes to post
*/
const patchAddressToAccompanyingPeriod = (accompanyingPeriodId, addressId) => {
const body = {
'type': 'accompanying_period',
'id': accompanyingPeriodId,
'personLocation': null,
'addressLocation': {
'id': addressId
}
};
const url = `/api/1.0/person/accompanying-course/${accompanyingPeriodId}.json`;
return fetch (url, {
method: 'PATCH',
headers: {'Content-Type': 'application/json;charset=utf-8'},
body: JSON.stringify(body)
})
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
export { postAddressToPerson, postAddressToHousehold, patchAddressToAccompanyingPeriod };