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' 'type': 'household'
}; };
const address = { const address = {
'type': 'address',
'id': data.addressId 'id': data.addressId
}; };
makeFetch('POST', '/api/1.0/person/household.json', household) makeFetch('POST', '/api/1.0/person/household.json', household)
.then(responseHousehold => { .then(responseHousehold => {
console.log(responseHousehold);
const member = { const member = {
'concerned': [ 'concerned': [
{ {
@ -305,25 +302,27 @@ export default {
'type': 'person', 'type': 'person',
'id': responsePerson.id 'id': responsePerson.id
}, },
"position": { 'position': {
"type": "household_position", "type": "household_position",
"id": 4 //TODO, which 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': { 'destination': {
'type': 'household', 'type': 'household',
'id': responseHousehold.id 'id': responseHousehold.id
} },
'composition': null
}; };
console.log(member);
makeFetch('POST', '/api/1.0/person/household/members/move.json', member) makeFetch('POST', '/api/1.0/person/household/members/move.json', member)
.then(response => { .then(_response => {
console.log(response);
makeFetch('POST', `/api/1.0/person/household/${responseHousehold.id}/address.json`, address) makeFetch('POST', `/api/1.0/person/household/${responseHousehold.id}/address.json`, address)
.then(response => { .then(_response => {})
console.log(response);
})
.catch((error) => { .catch((error) => {
if (error.name === 'ValidationException') { if (error.name === 'ValidationException') {
for (let v of error.violations) { for (let v of error.violations) {