mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 01:55:01 +00:00
refactoring AddAddress component
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Endpoint countries GET
|
||||
*/
|
||||
const fetchCountries = () => {
|
||||
console.log('<<< fetching countries');
|
||||
return [
|
||||
{id: 1, name: 'France', countryCode: 'FR'},
|
||||
{id: 2, name: 'Belgium', countryCode: 'BE'}
|
||||
];
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint cities GET
|
||||
*/
|
||||
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'}
|
||||
];
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint chill_main_address_reference_api_show
|
||||
* method GET, get AddressReference Object
|
||||
* @returns {Promise} a promise containing all AddressReference object
|
||||
*/
|
||||
const fetchReferenceAddresses = (city) => {
|
||||
console.log('<<< fetching references addresses for', city);
|
||||
const url = `/api/1.0/main/address-reference.json`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
fetchCountries,
|
||||
fetchCities,
|
||||
fetchReferenceAddresses
|
||||
};
|
Reference in New Issue
Block a user