Skip to content

Commit ac7c342

Browse files
committed
Remove janzz occupation suggestions
1 parent 1fe4377 commit ac7c342

File tree

2 files changed

+2
-57
lines changed

2 files changed

+2
-57
lines changed

src/app/(sok)/_components/searchBox/SearchCombobox.jsx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,13 @@ import {
1212
PUBLISHED,
1313
SEARCH_STRING,
1414
} from "@/app/(sok)/_components/searchParamNames";
15-
import { FetchAction, useFetchReducer } from "@/app/_common/hooks/useFetchReducer";
16-
import * as actions from "@/app/_common/actions";
1715
import { findLabelForFilter, getSearchBoxOptions } from "@/app/(sok)/_components/searchBox/buildSearchBoxOptions";
1816
import logAmplitudeEvent, { logFilterChanged } from "@/app/_common/monitoring/amplitude";
1917

20-
let suggestionsCache = [];
21-
const CACHE_MAX_SIZE = 50;
22-
const MINIMUM_LENGTH = 1;
23-
2418
function SearchCombobox({ aggregations, locations }) {
2519
const searchQuery = useSearchQuery();
26-
const [suggestionsResponse, suggestionsDispatch] = useFetchReducer([]);
2720

28-
const options = useMemo(
29-
() => getSearchBoxOptions(aggregations, locations, [...suggestionsResponse.data]),
30-
[aggregations, locations, suggestionsResponse.data],
31-
);
21+
const options = useMemo(() => getSearchBoxOptions(aggregations, locations), [aggregations, locations]);
3222

3323
const selectedOptions = useMemo(
3424
() => buildSelectedOptions(searchQuery.urlSearchParams),
@@ -42,30 +32,6 @@ function SearchCombobox({ aggregations, locations }) {
4232
: { label: o.label, value: o.value };
4333
});
4434

45-
async function fetchSuggestions(value) {
46-
const cached = suggestionsCache.find((c) => c.value === value);
47-
if (cached) {
48-
suggestionsDispatch({ type: FetchAction.RESOLVE, data: cached.data });
49-
return;
50-
}
51-
let data;
52-
try {
53-
data = await actions.getSuggestions(value, MINIMUM_LENGTH);
54-
} catch (err) {
55-
// ignore fetch failed errors
56-
}
57-
if (data) {
58-
suggestionsCache = [{ value, data }, ...suggestionsCache].slice(0, CACHE_MAX_SIZE);
59-
suggestionsDispatch({ type: FetchAction.RESOLVE, data });
60-
}
61-
}
62-
63-
function handleValueChange(value) {
64-
if (value && value.length >= MINIMUM_LENGTH) {
65-
fetchSuggestions(value);
66-
}
67-
}
68-
6935
const handleFreeTextSearchOption = (value, isSelected) => {
7036
if (isSelected) {
7137
searchQuery.append(SEARCH_STRING, value);
@@ -173,7 +139,6 @@ function SearchCombobox({ aggregations, locations }) {
173139
onToggleSelected={onToggleSelected}
174140
selectedOptions={selectedOptions}
175141
options={optionList}
176-
onChange={handleValueChange}
177142
/>
178143
);
179144
}

src/app/(sok)/_components/searchBox/buildSearchBoxOptions.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
INTERNATIONAL,
1818
MUNICIPAL,
1919
NEED_DRIVERS_LICENSE,
20-
OCCUPATION,
2120
OCCUPATION_FIRST_LEVEL,
2221
OCCUPATION_SECOND_LEVEL,
2322
PUBLISHED,
@@ -28,7 +27,6 @@ import {
2827
import { PublishedLabels } from "@/app/(sok)/_utils/publishedLabels";
2928

3029
const promotedOptions: ComboboxOption[] = [
31-
{ label: "Butikkmedarbeider", value: `${OCCUPATION}-Butikkmedarbeider` },
3230
{ label: "Deltid", value: `${EXTENT}-Deltid` },
3331
{ label: labelForEducation("Ingen krav"), value: `${EDUCATION}-Ingen krav` },
3432
{ label: labelForExperience("Ingen"), value: `${EXPERIENCE}-Ingen` },
@@ -199,17 +197,6 @@ function getRemoteOptions(aggregations: Aggregations): ComboboxOption[] {
199197
);
200198
}
201199

202-
function getOccupationSuggestionOptions(allSuggestions: string[]): ComboboxOption[] {
203-
return allSuggestions
204-
.map(
205-
(suggestion): ComboboxOption => ({
206-
label: suggestion,
207-
value: `${OCCUPATION}-${suggestion}`,
208-
}),
209-
)
210-
.filter((option) => !promotedValues.includes(option.value));
211-
}
212-
213200
function getDriversLicenseOptions(aggregations: Aggregations): ComboboxOption[] {
214201
return aggregations.needDriversLicense
215202
.map(
@@ -238,11 +225,7 @@ function getExperienceOptions(aggregations: Aggregations): ComboboxOption[] {
238225
.filter((option) => !promotedValues.includes(option.value));
239226
}
240227

241-
export function getSearchBoxOptions(
242-
aggregations: Aggregations,
243-
locations: LocationList[],
244-
allSuggestions: string[],
245-
): ComboboxOption[] {
228+
export function getSearchBoxOptions(aggregations: Aggregations, locations: LocationList[]): ComboboxOption[] {
246229
const locationList = buildLocations(aggregations, locations);
247230

248231
return [
@@ -261,7 +244,6 @@ export function getSearchBoxOptions(
261244
...getRemoteOptions(aggregations),
262245
...getDriversLicenseOptions(aggregations),
263246
...getExperienceOptions(aggregations),
264-
...getOccupationSuggestionOptions(allSuggestions),
265247
];
266248
}
267249

@@ -277,8 +259,6 @@ export const findLabelForFilter = (value: string): string => {
277259
return "(Kategori)";
278260
case OCCUPATION_SECOND_LEVEL:
279261
return "(Kategori)";
280-
case OCCUPATION:
281-
return "(Yrke)";
282262
case SECTOR:
283263
return "(Sektor)";
284264
case ENGAGEMENT_TYPE:

0 commit comments

Comments
 (0)