Skip to content

Commit

Permalink
GN-4538: Show empty search result when there are no streets
Browse files Browse the repository at this point in the history
  • Loading branch information
dkozickis committed Oct 6, 2023
1 parent e952beb commit 1d28bc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-shoes-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lblod/ember-rdfa-editor-lblod-plugins': patch
---

GN-4538: Display correctly that there are no streets when searching in the address plugin
10 changes: 6 additions & 4 deletions addon/plugins/variable-plugin/utils/address-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type StreetSearchResult = {
gemeente: {
gemeentenaam: { geografischeNaam: { spelling: string } };
};
straatnaam: {
straatnaam?: {
straatnaam: {
geografischeNaam: { spelling: string };
};
Expand Down Expand Up @@ -135,9 +135,11 @@ export async function fetchStreets(term: string, municipality: string) {
});
if (result.ok) {
const jsonResult = (await result.json()) as StreetSearchResult;
const streetnames = jsonResult.adresMatches.map((entry) => {
return entry.straatnaam.straatnaam.geografischeNaam.spelling;
});

const streetnames = jsonResult.adresMatches
.map((entry) => entry.straatnaam?.straatnaam.geografischeNaam.spelling)
.filter(Boolean);

return streetnames;
} else {
throw new AddressError({
Expand Down

0 comments on commit 1d28bc9

Please sign in to comment.