Skip to content

Commit 3b774b1

Browse files
committed
chore: type fixes LINK-1759
1 parent 7a652ae commit 3b774b1

6 files changed

Lines changed: 49 additions & 49 deletions

File tree

src/common/components/eventSelector/EventSelector.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-undef */
22
import { ApolloError } from '@apollo/client';
3-
import { SearchFunction, SearchResult } from 'hds-react';
3+
import { Option, SearchFunction, SearchResult, SelectData } from 'hds-react';
44
import React, { useCallback, useEffect } from 'react';
55
import { useTranslation } from 'react-i18next';
66

@@ -48,6 +48,7 @@ const EventSelector: React.FC<EventSelectorProps> = ({
4848
variables: {
4949
...variables,
5050
createPath: getPathBuilder(eventsPathBuilder),
51+
text: '',
5152
},
5253
});
5354

@@ -91,14 +92,14 @@ const EventSelector: React.FC<EventSelectorProps> = ({
9192
throw error;
9293
}
9394

94-
const newOptions = getValue(
95-
newEventsData?.events.data.map((event) =>
96-
getOption(event as EventFieldsFragment, locale)
95+
return {
96+
options: getValue(
97+
newEventsData?.events.data.map((event) =>
98+
getOption(event as EventFieldsFragment, locale)
99+
),
100+
[]
97101
),
98-
[]
99-
);
100-
101-
return { options: newOptions };
102+
};
102103
} catch (error) {
103104
return Promise.reject(error as ApolloError);
104105
}
@@ -107,12 +108,11 @@ const EventSelector: React.FC<EventSelectorProps> = ({
107108
);
108109

109110
const handleChange = React.useCallback(
110-
(...args: unknown[]) => {
111+
(selectedOptions: Option[], clickedOption: Option, data: SelectData) => {
111112
setOptions(initialOptions.current);
112113

113114
if (onChange) {
114-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
115-
(onChange as any)(...args);
115+
onChange(selectedOptions, clickedOption, data);
116116
}
117117
},
118118
[onChange]

src/common/components/eventSelector/__mocks__/eventSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const eventsVariables = {
1818
createPath: undefined,
1919
sort: EVENT_SORT_OPTIONS.NAME,
2020
superEventType: ['umbrella'],
21+
text: '',
2122
};
2223
const events = fakeEvents(1, [event]);
2324
const eventsResponse = { data: { events: events } };

src/common/components/keywordSelector/KeywordSelector.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ const KeywordSelector: React.FC<KeywordSelectorProps> = ({
105105
throw error;
106106
}
107107

108-
const newOptions = getValue(
109-
newKeywordsData?.keywords.data.map((keyword) =>
110-
getOption({ keyword: keyword as KeywordFieldsFragment, locale })
108+
return Promise.resolve({
109+
options: getValue(
110+
newKeywordsData?.keywords.data.map((keyword) =>
111+
getOption({ keyword: keyword as KeywordFieldsFragment, locale })
112+
),
113+
[]
111114
),
112-
[]
113-
);
114-
115-
return Promise.resolve({ options: newOptions });
115+
});
116116
} catch (error) {
117117
return Promise.reject(error as ApolloError);
118118
}

src/common/components/placeSelector/PlaceSelector.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-undef */
22
import { ApolloError } from '@apollo/client';
3-
import { SearchFunction, SearchResult } from 'hds-react';
3+
import { Option, SearchFunction, SearchResult, SelectData } from 'hds-react';
44
import { TFunction } from 'i18next';
55
import React, { useCallback, useEffect } from 'react';
66
import { useTranslation } from 'react-i18next';
@@ -125,14 +125,14 @@ const PlaceSelector: React.FC<PlaceSelectorProps> = ({
125125
throw error;
126126
}
127127

128-
const newOptions = getValue(
129-
newPlacesData?.places.data.map((place) =>
130-
getOption({ place: place as PlaceFieldsFragment, locale, t })
128+
return {
129+
options: getValue(
130+
newPlacesData?.places.data.map((place) =>
131+
getOption({ place: place as PlaceFieldsFragment, locale, t })
132+
),
133+
[]
131134
),
132-
[]
133-
);
134-
135-
return { options: newOptions };
135+
};
136136
} catch (error) {
137137
return Promise.reject(error as ApolloError);
138138
}
@@ -141,12 +141,11 @@ const PlaceSelector: React.FC<PlaceSelectorProps> = ({
141141
);
142142

143143
const handleChange = React.useCallback(
144-
(...args: unknown[]) => {
144+
(selectedOptions: Option[], clickedOption: Option, data: SelectData) => {
145145
setOptions(initialOptions.current);
146146

147147
if (onChange) {
148-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
149-
(onChange as any)(...args);
148+
onChange(selectedOptions, clickedOption, data);
150149
}
151150
},
152151
[onChange]

src/common/components/singleKeywordSelector/SingleKeywordSelector.tsx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-undef */
22
import { ApolloError } from '@apollo/client';
3-
import { SearchFunction, SearchResult } from 'hds-react';
3+
import { Option, SearchFunction, SearchResult, SelectData } from 'hds-react';
44
import React, { useCallback } from 'react';
55
import { useTranslation } from 'react-i18next';
66

@@ -93,18 +93,6 @@ const SingleKeywordSelector: React.FC<SingleKeywordSelectorProps> = ({
9393
}
9494
}, [keywordsOptions, keywordsData]);
9595

96-
const handleChange = React.useCallback(
97-
(...args: unknown[]) => {
98-
setOptions(initialOptions.current);
99-
100-
if (onChange) {
101-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
102-
(onChange as any)(...args);
103-
}
104-
},
105-
[onChange]
106-
);
107-
10896
const handleSearch: SearchFunction = React.useCallback(
10997
async (searchValue: string): Promise<SearchResult> => {
11098
try {
@@ -116,21 +104,32 @@ const SingleKeywordSelector: React.FC<SingleKeywordSelectorProps> = ({
116104
throw error;
117105
}
118106

119-
const newOptions = getValue(
120-
newkeywordsData?.keywords.data.map((keyword) =>
121-
getOption({ keyword: keyword as KeywordFieldsFragment, locale })
107+
return {
108+
options: getValue(
109+
newkeywordsData?.keywords.data.map((keyword) =>
110+
getOption({ keyword: keyword as KeywordFieldsFragment, locale })
111+
),
112+
[]
122113
),
123-
[]
124-
);
125-
126-
return { options: newOptions };
114+
};
127115
} catch (error) {
128116
return Promise.reject(error as ApolloError);
129117
}
130118
},
131119
[refetch, locale]
132120
);
133121

122+
const handleChange = React.useCallback(
123+
(selectedOptions: Option[], clickedOption: Option, data: SelectData) => {
124+
setOptions(initialOptions.current);
125+
126+
if (onChange) {
127+
onChange(selectedOptions, clickedOption, data);
128+
}
129+
},
130+
[onChange]
131+
);
132+
134133
const selectedKeyword = React.useMemo(
135134
() =>
136135
keywordData?.keyword

src/domain/registration/formSections/eventSection/__mocks__/eventSection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const eventsVariables = {
4040
start: 'now',
4141
sort: EVENT_SORT_OPTIONS.NAME,
4242
superEventType: ['none'],
43+
text: '',
4344
};
4445

4546
const events = fakeEvents(1, [event]);

0 commit comments

Comments
 (0)