OnTheFly modal, Person Sub-component: create/edit form, show

This commit is contained in:
2021-06-02 22:20:19 +02:00
parent 4562ed46db
commit 4d0cfbb396
10 changed files with 319 additions and 41 deletions

View File

@@ -0,0 +1,48 @@
/*
* GET a person by id
*/
const getPerson = (id) => {
const url = `/api/1.0/person/person/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/*
* GET a thirdparty by id
* TODO move in ChillThirdpartyAssets !!
*/
const getThirdparty = (id) => {
const url = `/api/1.0/thirdparty/thirdparty/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/*
* POST a person
*/
const postPerson = (body) => {
const url = `/api/1.0/person/person.json`;
return fetch(url, {
method: 'POST',
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 {
getPerson,
getThirdparty,
postPerson
};