Skip to content

Commit

Permalink
Merge pull request #1164 from coopTilleuls/fix/change-api-address
Browse files Browse the repository at this point in the history
fix: use tilleuls address api instead of other api
  • Loading branch information
davy-beauzil authored Feb 27, 2024
2 parents 93d99da + fbc49f8 commit 59a40b4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 15 deletions.
1 change: 1 addition & 0 deletions pwa/components/dashboard/informations/ContactDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export const ContactDetails = ({
/>
<Autocomplete
sx={{mt: 2, mb: 1, p: 0}}
filterOptions={(options) => options}
freeSolo
value={city}
options={citiesList}
Expand Down
1 change: 1 addition & 0 deletions pwa/components/rendez-vous/PinMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const PinMap = ({
)}
<Autocomplete
fullWidth
filterOptions={(options) => options}
sx={{mt: 2, mb: 1}}
freeSolo
value={cityInput}
Expand Down
18 changes: 12 additions & 6 deletions pwa/interfaces/City.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ export const createCitiesWithGouvAPI = (citiesResponse: Gouv[]): City[] => {
let cities: City[] = [];

citiesResponse.forEach((city: Gouv) => {
const args = [city.name, city.zipCode, city.longitude, city.latitude];
const args = [
city.nom_commune_complet,
city.code_postal,
city.longitude,
city.latitude,
];

if (!args.some((arg) => arg === undefined)) {
cities.push({
id: city.zipCode,
cityCode: city.inseeCode,
name: city.name,
postcode: city.zipCode,
formatted_name: city.name + ', ' + city.zipCode + ', ' + 'France',
id: city.id,
cityCode: city.code_commune_INSEE,
name: city.nom_commune_complet,
postcode: city.code_postal,
formatted_name:
city.nom_commune_complet + ', ' + city.code_postal + ', ' + 'France',
lat: city.latitude,
lon: city.longitude,
});
Expand Down
37 changes: 29 additions & 8 deletions pwa/interfaces/Gouv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,33 @@ export interface Geometry {
}

export interface City {
codeDepartment: string;
inseeCode: string;
codeRegion: string;
departmentName: string;
name: string;
latitude: string;
longitude: string;
zipCode: string;
'@id': string;
id: string;
code_commune_INSEE: string;
nom_commune_postal: string;
code_postal: string;
libelle_acheminement: string;
ligne_5: string;
latitude: number;
longitude: number;
code_commune: string;
article: string;
nom_commune: string;
nom_commune_complet: string;
department: Departement | null;
}

export interface Departement {
'@id': string;
id: string;
code_departement: string;
nom_departement: string;
region: Region | null;
}

export interface Region {
'@id': string;
id: string;
code_region: string;
nom_region: string;
}
1 change: 1 addition & 0 deletions pwa/pages/reparateur/chercher-un-reparateur.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ const SearchRepairer: NextPageWithLayout<SearchRepairerProps> = ({
/>
<Box width={{xs: '100%', md: '50%'}} ref={listContainerRef}>
<Autocomplete
filterOptions={(options) => options}
freeSolo
value={city}
options={citiesList}
Expand Down
2 changes: 1 addition & 1 deletion pwa/utils/apiCity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const gouvCities = async (search: string) => {

try {
const response = await fetch(
`https://boondmanagerapp-20a6481aece0.herokuapp.com/api/cities?name=${search}`
`https://api-address-09a561047853.herokuapp.com/api/cities?nom_commune_postal=${search}`
);

const data = await response.json();
Expand Down

0 comments on commit 59a40b4

Please sign in to comment.