mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
affichage code postal et insee en recherche de ville
This commit is contained in:
parent
205a653bee
commit
5490453764
1 changed files with 7 additions and 6 deletions
|
@ -231,9 +231,10 @@ export function setupCitySearch(inputId, suggestionListId, onSelect) {
|
|||
const data = await response.json();
|
||||
const citySuggestions = data.map(city => ({
|
||||
name: city.nom,
|
||||
postcode: city.codesPostaux[0],
|
||||
insee: city.code,
|
||||
display_name: `${city.nom} (${city.codesPostaux[0]})`
|
||||
postcodes: city.codesPostaux,
|
||||
postcode: city.codesPostaux && city.codesPostaux.length > 0 ? city.codesPostaux[0] : '',
|
||||
display_name: `${city.nom} (${city.codesPostaux && city.codesPostaux.length > 0 ? city.codesPostaux[0] : ''})`
|
||||
}));
|
||||
displaySuggestions(citySuggestions);
|
||||
} catch (error) {
|
||||
|
@ -248,10 +249,10 @@ export function setupCitySearch(inputId, suggestionListId, onSelect) {
|
|||
item.classList.add('suggestion-item');
|
||||
// Nouveau rendu : nom en gras, INSEE et CP en petit/gris
|
||||
item.innerHTML = `
|
||||
<span class="suggestion-name">${suggestion.name}</span>
|
||||
<span class="suggestion-details">
|
||||
<span>INSEE : <b>${suggestion.insee}</b></span>
|
||||
<span style="margin-left:8px;">CP : <b>${Array.isArray(suggestion.postcodes) ? suggestion.postcodes.join(', ') : suggestion.postcode}</b></span>
|
||||
<span class="suggestion-name" style="font-weight:bold;">${suggestion.name}</span><br>
|
||||
<span class="suggestion-details" style="font-size:0.95em;color:#666;">
|
||||
<span>INSEE : <b>${suggestion.insee}</b></span>
|
||||
<span style="margin-left:12px;">CP : <b>${Array.isArray(suggestion.postcodes) ? suggestion.postcodes.join(', ') : suggestion.postcode}</b></span>
|
||||
</span>
|
||||
`;
|
||||
item.addEventListener('click', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue