Skip to content

Commit

Permalink
feat: pass through on fetch success callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed May 15, 2024
1 parent d5319fd commit 0b624bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/Field/NominatimSearch/NominatimSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const NominatimSearch: FC<NominatimSearchProps> = ({
onChange = () => undefined,
onClear,
onFetchError,
onFetchSuccess,
onSelect,
polygonGeoJSON,
renderOption,
Expand Down
18 changes: 10 additions & 8 deletions src/Field/WfsSearchField/WfsSearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -19,17 +19,14 @@ import { CSS_PREFIX } from '../../constants';
const Option = AutoComplete.Option;

export type WfsSearchFieldProps = {
additionalFetchOptions?: Partial<RequestInit>;
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<WfsQueryArgs, 'searchConfig'|'searchTerm'>;

const defaultClassName = `${CSS_PREFIX}wfssearch`;

Expand Down Expand Up @@ -63,6 +60,8 @@ export const WfsSearchField: FC<WfsSearchFieldProps> = ({
srsName = 'EPSG:3857',
value,
wfsFormatOptions,
onFetchError,
onFetchSuccess,
...passThroughProps
}) => {

Expand Down Expand Up @@ -100,8 +99,10 @@ export const WfsSearchField: FC<WfsSearchFieldProps> = ({
*
* @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 {
Expand All @@ -110,7 +111,8 @@ export const WfsSearchField: FC<WfsSearchFieldProps> = ({
} = useWfs({
baseUrl,
minChars,
onFetchError,
onFetchError: onFetchErrorInternal,
onFetchSuccess,
searchTerm,
searchConfig
});
Expand Down

0 comments on commit 0b624bd

Please sign in to comment.