Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a57e9cb

Browse files
committedNov 6, 2024·
Tilbakestill til master
1 parent dc3a82c commit a57e9cb

File tree

1 file changed

+12
-21
lines changed
  • src/stilling/stilling/edit/om-stillingen/janzz

1 file changed

+12
-21
lines changed
 

‎src/stilling/stilling/edit/om-stillingen/janzz/Janzz.tsx

+12-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React, { FunctionComponent, useState, useEffect } from 'react';
1+
// components/Janzz.tsx
2+
3+
import React, { FunctionComponent, useState } from 'react';
24
import css from './Janzz.module.css';
35
import { SET_EMPLOYMENT_JOBTITLE, SET_JANZZ } from '../../../adDataReducer';
46
import { useDispatch, useSelector } from 'react-redux';
@@ -20,15 +22,17 @@ const Janzz: FunctionComponent<Props> = ({ tittel }) => {
2022

2123
const { data: suggestions, isLoading, error } = useHentJanzzYrker(input);
2224

23-
useEffect(() => {
24-
if (suggestions && suggestions.length > 0) {
25+
const onChange = (event: React.ChangeEvent<HTMLInputElement> | null, value?: string) => {
26+
setInput(event?.target?.value || value || '');
27+
};
28+
29+
const onToggleSelected = (option: string, isSelected: boolean) => {
30+
if (isSelected && suggestions) {
2531
const found = suggestions.find(
26-
({ label }) => label.toLowerCase() === input.toLowerCase()
32+
(forslag) => forslag.label.toLowerCase() === option.toLowerCase()
2733
);
28-
2934
if (found) {
3035
dispatch({ type: SET_EMPLOYMENT_JOBTITLE, jobtitle: found.label });
31-
3236
const kategori = [
3337
{
3438
id: found.konseptId,
@@ -39,28 +43,15 @@ const Janzz: FunctionComponent<Props> = ({ tittel }) => {
3943
parentId: null,
4044
},
4145
];
42-
4346
dispatch({ type: SET_JANZZ, kategori });
44-
} else {
45-
dispatch({ type: SET_JANZZ, undefined });
47+
setInput(capitalizeEmployerName(found.label) || '');
4648
}
47-
} else {
48-
dispatch({ type: SET_JANZZ, undefined });
49-
}
50-
}, [input, suggestions]);
51-
52-
const onChange = (event: React.ChangeEvent<HTMLInputElement> | null, value?: string) => {
53-
setInput(event?.target?.value || value || '');
54-
};
55-
56-
const onToggleSelected = (option: string, isSelected: boolean) => {
57-
if (isSelected) {
58-
setInput(capitalizeEmployerName(option) || '');
5949
}
6050
};
6151

6252
const feilmeldingTilBruker = error ? error.message : undefined;
6353

54+
// TODO: Fjern default tekster fra backend, slik at vi slipper å filterere de bort her
6455
return (
6556
<div>
6657
<UnsafeCombobox

0 commit comments

Comments
 (0)
Please sign in to comment.