person: add address when creating person in AddPerson: fix POSTing household

This commit is contained in:
nobohan 2022-04-19 09:54:42 +02:00
parent 57ed90a696
commit 355c5cf8fd

View File

@ -291,13 +291,10 @@ export default {
'type': 'household'
};
const address = {
'type': 'address',
'id': data.addressId
};
makeFetch('POST', '/api/1.0/person/household.json', household)
.then(responseHousehold => {
console.log(responseHousehold);
const member = {
'concerned': [
{
@ -305,25 +302,27 @@ export default {
'type': 'person',
'id': responsePerson.id
},
"position": {
'position': {
"type": "household_position",
"id": 4 //TODO, which position?
},
'start_date': {
'datetime': `${new Date().toISOString().split('T')[0]}T00:00:00+02:00`
},
'holder': false, //TODO true or false?
'comment': null
}
],
'destination': {
'type': 'household',
'id': responseHousehold.id
}
},
'composition': null
};
console.log(member);
makeFetch('POST', '/api/1.0/person/household/members/move.json', member)
.then(response => {
console.log(response);
.then(_response => {
makeFetch('POST', `/api/1.0/person/household/${responseHousehold.id}/address.json`, address)
.then(response => {
console.log(response);
})
.then(_response => {})
.catch((error) => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {