-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2218 from Amsterdam/bugfix/89484-multiple-address…
…es-with-bag-id 89484
- Loading branch information
Showing
10 changed files
with
69 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/app/components/addresses/ObjectDetails/hooks/useValues.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/app/components/addresses/utils/getAddressFromBagResults.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const getAddressFromBagResults = (data?: BAGAddressResponse): BAGAddressResponse["results"][number] | undefined => ( | ||
data?.results?.find((result) => result.type_adres === "Hoofdadres") | ||
) | ||
|
||
export default getAddressFromBagResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/app/state/rest/custom/useOtherAddresses/useOtherAddresses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { useBAG, useBAGWithStreet } from "app/state/rest/index" | ||
import getAddressFromBagResults from "app/components/addresses/utils/getAddressFromBagResults" | ||
|
||
/** | ||
* Returns other addresses with the same postcode + huisnummer | ||
* @param bagId | ||
*/ | ||
const useOtherAddressesByBagId = (bagId: Components.Schemas.Address["bag_id"]) => { | ||
const [data] = useBAG(bagId) | ||
const firstResult = data?.results?.[0] | ||
const searchQuery = `${ firstResult?.postcode } ${ firstResult?.huisnummer }` | ||
const foundAddress = getAddressFromBagResults(data) | ||
const searchQuery = `${ foundAddress?.postcode } ${ foundAddress?.huisnummer }` | ||
const [otherAddresses, otherAddressesMethods] = useBAGWithStreet(searchQuery, { lazy: data === undefined }) | ||
return [otherAddresses?.results?.filter(({ huisnummer }) => huisnummer === firstResult?.huisnummer), otherAddressesMethods] as const | ||
return [otherAddresses?.results?.filter(({ huisnummer }) => huisnummer === foundAddress?.huisnummer), otherAddressesMethods] as const | ||
} | ||
export default useOtherAddressesByBagId |
8 changes: 5 additions & 3 deletions
8
src/app/state/rest/custom/usePanoramaByBagId/usePanoramaByBagId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters