mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
[WIP] Integrate local aggregated address search in AddressPicker
Added a `local-search` driver to support aggregated address fetching. Integrated the `getAddressesAggregated` function with `AddressPicker.vue` for dynamic search suggestions and abortable fetch requests.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
export interface AddressAggregated {
|
||||
row_number: number;
|
||||
street: string;
|
||||
postcode_id: number;
|
||||
code: string;
|
||||
label: string;
|
||||
positions: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws {DOMException} when fetch is aborted, the property name is always equals to 'AbortError'
|
||||
*/
|
||||
export const getAddressesAggregated = async (
|
||||
search: string,
|
||||
abortController: AbortController,
|
||||
): Promise<AddressAggregated[]> => {
|
||||
const params = new URLSearchParams({ q: search });
|
||||
let response = null;
|
||||
|
||||
response = await fetch(
|
||||
`/api/1.0/main/address-reference/aggregated/search?${params}`,
|
||||
{ signal: abortController.signal },
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
throw new Error(response.statusText);
|
||||
};
|
Reference in New Issue
Block a user