From 0b624bd018b98bac9d292ff7dc1ea022b7884b9b Mon Sep 17 00:00:00 2001 From: Simon Seyock Date: Wed, 15 May 2024 10:03:22 +0200 Subject: [PATCH] feat: pass through on fetch success callbacks --- package-lock.json | 8 ++++---- package.json | 2 +- src/Field/NominatimSearch/NominatimSearch.tsx | 1 + src/Field/WfsSearchField/WfsSearchField.tsx | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec3ac52161..f2f4b86a19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@fortawesome/react-fontawesome": "^0.2.0", "@terrestris/base-util": "^1.1.0", "@terrestris/ol-util": "^18.0.0", - "@terrestris/react-util": "^5.0.0", + "@terrestris/react-util": "^5.1.0", "@types/geojson": "^7946.0.14", "@types/lodash": "^4.17.1", "ag-grid-community": "^31.3.1", @@ -5670,9 +5670,9 @@ } }, "node_modules/@terrestris/react-util": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@terrestris/react-util/-/react-util-5.0.0.tgz", - "integrity": "sha512-j2Feq2WdhWuFM+U8KSfj7dz4qkh/slR18lQWTOxWJuybtk+9qLr8AVf3myTLaS362Mr1MPI2mAao+W+O8wz20A==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@terrestris/react-util/-/react-util-5.1.0.tgz", + "integrity": "sha512-i7xhdBRJvcVKUZmMYc6PFoMWzGgX24OkdxcjONaQ8ycjmGnf9tOdXIXHiYAx9DjJQgRDoqu1q1qW1AuR3CCbVA==", "dependencies": { "@camptocamp/inkmap": "^1.4.0", "@terrestris/base-util": "^1.1.0", diff --git a/package.json b/package.json index 85c8c6d474..b9b521dcd0 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@fortawesome/react-fontawesome": "^0.2.0", "@terrestris/base-util": "^1.1.0", "@terrestris/ol-util": "^18.0.0", - "@terrestris/react-util": "^5.0.0", + "@terrestris/react-util": "^5.1.0", "@types/geojson": "^7946.0.14", "@types/lodash": "^4.17.1", "ag-grid-community": "^31.3.1", diff --git a/src/Field/NominatimSearch/NominatimSearch.tsx b/src/Field/NominatimSearch/NominatimSearch.tsx index 55d9b44d6b..879a40bc47 100644 --- a/src/Field/NominatimSearch/NominatimSearch.tsx +++ b/src/Field/NominatimSearch/NominatimSearch.tsx @@ -69,6 +69,7 @@ export const NominatimSearch: FC = ({ onChange = () => undefined, onClear, onFetchError, + onFetchSuccess, onSelect, polygonGeoJSON, renderOption, diff --git a/src/Field/WfsSearchField/WfsSearchField.tsx b/src/Field/WfsSearchField/WfsSearchField.tsx index 103f68b81f..e3f4e4ceb5 100644 --- a/src/Field/WfsSearchField/WfsSearchField.tsx +++ b/src/Field/WfsSearchField/WfsSearchField.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Logger from '@terrestris/base-util/dist/Logger'; import { SearchConfig } from '@terrestris/ol-util/dist/WfsFilterUtil/WfsFilterUtil'; import useMap from '@terrestris/react-util/dist/Hooks/useMap/useMap'; -import { useWfs } from '@terrestris/react-util/dist/Hooks/useWfs/useWfs'; +import { useWfs, WfsQueryArgs } from '@terrestris/react-util/dist/Hooks/useWfs/useWfs'; import { AutoComplete, Input, Spin } from 'antd'; import { DefaultOptionType, OptionProps } from 'antd/lib/select'; import _get from 'lodash/get'; @@ -19,17 +19,14 @@ import { CSS_PREFIX } from '../../constants'; const Option = AutoComplete.Option; export type WfsSearchFieldProps = { - additionalFetchOptions?: Partial; asInput?: boolean; - baseUrl: string; className?: string; displayValue?: string; idProperty?: string; - minChars?: number; onBeforeSearch?: (value: string) => string; onChange?: (val: OlFeature[] | undefined) => undefined; value?: OlFeature[] | undefined; -} & SearchConfig; +} & SearchConfig & Omit; const defaultClassName = `${CSS_PREFIX}wfssearch`; @@ -63,6 +60,8 @@ export const WfsSearchField: FC = ({ srsName = 'EPSG:3857', value, wfsFormatOptions, + onFetchError, + onFetchSuccess, ...passThroughProps }) => { @@ -100,8 +99,10 @@ export const WfsSearchField: FC = ({ * * @param error The error string. */ - const onFetchError = (error: any) => { - Logger.error(`Error while requesting WFS GetFeature: ${error}`); + const onFetchErrorInternal = (error: any) => { + const msg = `Error while requesting WFS GetFeature: ${error}`; + Logger.error(msg); + onFetchError?.(msg); }; const { @@ -110,7 +111,8 @@ export const WfsSearchField: FC = ({ } = useWfs({ baseUrl, minChars, - onFetchError, + onFetchError: onFetchErrorInternal, + onFetchSuccess, searchTerm, searchConfig });