Skip to content

Commit

Permalink
Legg på validering på janzz-feltet
Browse files Browse the repository at this point in the history
  • Loading branch information
frodank committed Oct 30, 2024
1 parent fd14c81 commit 9e97f35
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
15 changes: 15 additions & 0 deletions src/stilling/stilling/adValidationReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
SET_EMPLOYMENT_SECTOR,
SET_EMPLOYMENT_STARTTIME,
SET_EXPIRATION_DATE,
SET_JANZZ,
SET_PRIVACY,
SET_PUBLISHED,
UNCHECK_EMPLOYMENT_WORKDAY,
Expand All @@ -41,6 +42,7 @@ export type ValidertFelt =
| 'location'
| 'postalCode'
| 'locationArea'
| 'yrkestittel'
| 'adText'
| 'expires'
| 'published'
Expand Down Expand Up @@ -139,6 +141,16 @@ function* validateLocationArea(): Generator<unknown, any, any> {
yield removeValidationError({ field: 'locationArea' });
}
}
function* validateYrkestittel(): Generator<unknown, any, any> {
const state = yield select();
const { categoryList } = state.adData;

if (valueIsNotSet(categoryList)) {
yield addValidationError({ field: 'yrkestittel', message: 'Yrkestittel mangler' });
} else {
yield removeValidationError({ field: 'yrkestittel' });
}
}

function* validateAdtext(): Generator<unknown, any, any> {
const adText = yield select((state) => state.adData?.properties.adtext);
Expand Down Expand Up @@ -477,6 +489,7 @@ export function* validateAll(): Generator<unknown, any, any> {
yield validateLocation();
yield validateExpireDate();
yield validatePublishDate();
yield validateYrkestittel();
yield validateAdtext();
yield validateApplicationEmail();
yield validatePostalCode();
Expand All @@ -500,6 +513,7 @@ export function hasValidationErrors(validation: Record<ValidertFelt, string | un
validation.location !== undefined ||
validation.expires !== undefined ||
validation.adText !== undefined ||
validation.yrkestittel !== undefined ||
validation.applicationEmail !== undefined ||
validation.contactPersonEmail !== undefined ||
validation.contactPersonEmailOrPhone !== undefined ||
Expand Down Expand Up @@ -573,6 +587,7 @@ export const validationSaga = function* saga() {
yield takeLatest(VALIDATE_ALL, validateAll);
yield takeLatest(SET_EXPIRATION_DATE, validateExpireDate);
yield takeLatest(SET_PUBLISHED, validatePublishDate);
yield takeLatest(SET_JANZZ, validateYrkestittel);
yield takeLatest(ADD_POSTAL_CODE_BEGIN, validatePostalCode);
yield takeLatest(VALIDATE_LOCATION_AREA, validateLocationArea);
yield takeLatest(
Expand Down
37 changes: 26 additions & 11 deletions src/stilling/stilling/edit/om-stillingen/janzz/Janzz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import capitalizeEmployerName from '../../endre-arbeidsgiver/capitalizeEmployerN
import { SET_EMPLOYMENT_JOBTITLE, SET_JANZZ } from '../../../adDataReducer';
import { StyrkCategory } from 'felles/domene/stilling/Stilling';
import { useDispatch } from 'react-redux';
import { UNSAFE_Combobox } from '@navikt/ds-react';

Check warning on line 10 in src/stilling/stilling/edit/om-stillingen/janzz/Janzz.tsx

View workflow job for this annotation

GitHub Actions / Bygg og push

'UNSAFE_Combobox' is defined but never used

type Props = {
categoryList: StyrkCategory[];
Expand Down Expand Up @@ -82,19 +83,33 @@ const Janzz: FunctionComponent<Props> = ({ categoryList, tittel }) => {
const feilmeldingTilBruker = suggestions.kind === Nettstatus.Feil && suggestions.error.message;

return (
<Typeahead
label="Yrkestittel som vises på stillingen"
value={input === 'Stilling uten valgt jobbtittel' ? '' : input}
onSelect={onForslagValgt}
onChange={onChange}
onBlur={onChange}
suggestions={konverterTilTypeaheadFormat(suggestions)}
error={feilmeldingTilBruker || undefined}
className={css.typeahead}
aria-labelledby="endre-stilling-styrk"
/>
<div>
<Typeahead
label="Yrkestittel som vises på stillingen (må fylles ut)"
value={input === 'Stilling uten valgt jobbtittel' ? '' : input}
onSelect={onForslagValgt}
onChange={onChange}
onBlur={onChange}
suggestions={konverterTilTypeaheadFormat(suggestions)}
error={feilmeldingTilBruker || undefined}
className={css.typeahead}
aria-labelledby="endre-stilling-styrk"
/>
</div>
);
};
/* <UNSAFE_Combobox
label="Yrkestittel som vises på stillingen"
value={input === 'Stilling uten valgt jobbtittel' ? '' : input}
options={}
//onSelect={onForslagValgt}
//onChange={onChange}
//onBlur={onChange}
//suggestions={konverterTilTypeaheadFormat(suggestions)}
error={feilmeldingTilBruker || undefined}
className={css.typeahead}
aria-labelledby="endre-stilling-styrk"
/>*/

const finnJanzzStilling = (suggestions: JanzzStilling[], navn: string) =>
suggestions.find(
Expand Down

0 comments on commit 9e97f35

Please sign in to comment.