[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:
2025-08-15 01:08:56 +02:00
parent 5a284fe6cf
commit 845aa040cc
3 changed files with 66 additions and 2 deletions

View File

@@ -1,6 +1,11 @@
<script setup lang="ts">
import { Address } from "ChillMainAssets/types";
import SearchBar from "ChillMainAssets/vuejs/AddressPicker/Component/SearchBar.vue";
import {
AddressAggregated,
getAddressesAggregated,
} from "ChillMainAssets/vuejs/AddressPicker/driver/local-search";
import { Ref, ref } from "vue";
interface AddressPickerProps {
suggestions?: Address[];
@@ -10,14 +15,43 @@ const props = withDefaults(defineProps<AddressPickerProps>(), {
suggestions: () => [],
});
const onSearch = function (search: string) {
const addresses: Ref<AddressAggregated[]> = ref([]);
let abortController: null | AbortController = null;
const onSearch = async function (search: string): Promise<void> {
if (null !== abortController) {
abortController.abort();
}
if ("" === search) {
addresses.value = [];
abortController = null;
return;
}
abortController = new AbortController();
console.log("onSearch", search);
try {
addresses.value = await getAddressesAggregated(search, abortController);
} catch (e: unknown) {
if (e instanceof DOMException && e.name === "AbortError") {
console.log("search aborted for:", search);
return;
}
throw e;
}
};
</script>
<template>
<search-bar @search="onSearch"></search-bar>
<p>test</p>
<p v-for="a in addresses" :key="a.row_number">
{{ a.street }}, positions: {{ a.positions[0] }}
</p>
</template>
<style scoped lang="scss"></style>