address selection: use API points for Country and PostalCode + remove obsolet Address Controller

This commit is contained in:
nobohan
2021-05-12 12:21:19 +02:00
parent 0afcf3d79e
commit fee37b5af3
4 changed files with 63 additions and 122 deletions

View File

@@ -1,26 +1,32 @@
/*
* Endpoint countries GET
* TODO
* method GET, get Country Object
* @returns {Promise} a promise containing all Country object
*/
const fetchCountries = () => {
console.log('<<< fetching countries');
return [
{id: 1, name: 'France', countryCode: 'FR'},
{id: 2, name: 'Belgium', countryCode: 'BE'}
];
const url = `/api/1.0/main/country.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/*
* Endpoint cities GET
* Endpoint cities GET
* TODO
*/
const fetchCities = (country) => {
const fetchCities = (country) => {
console.log('<<< fetching cities for', country);
return [
{id: 1, name: 'Bruxelles', code: '1000', country: 'BE'},
{id: 2, name: 'Aisne', code: '85045', country: 'FR'},
{id: 3, name: 'Saint-Gervais', code: '85230', country: 'FR'}
];
//TODO use country
const url = `/api/1.0/main/postal-code.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/*
@@ -30,7 +36,7 @@ const fetchCities = (country) => {
*/
const fetchReferenceAddresses = (city) => {
console.log('<<< fetching references addresses for', city); // city n'est pas utilisé pour le moment
const url = `/api/1.0/main/address-reference.json`;
return fetch(url)
.then(response => {