From 9e97f354ab0322f7b73fdcdafc865a877f6ae0e2 Mon Sep 17 00:00:00 2001 From: frodank <11638682+frodank@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:51:09 +0100 Subject: [PATCH] =?UTF-8?q?Legg=20p=C3=A5=20validering=20p=C3=A5=20janzz-f?= =?UTF-8?q?eltet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stilling/stilling/adValidationReducer.ts | 15 ++++++++ .../edit/om-stillingen/janzz/Janzz.tsx | 37 +++++++++++++------ 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/stilling/stilling/adValidationReducer.ts b/src/stilling/stilling/adValidationReducer.ts index 6ebaf3a3..371f503f 100644 --- a/src/stilling/stilling/adValidationReducer.ts +++ b/src/stilling/stilling/adValidationReducer.ts @@ -25,6 +25,7 @@ import { SET_EMPLOYMENT_SECTOR, SET_EMPLOYMENT_STARTTIME, SET_EXPIRATION_DATE, + SET_JANZZ, SET_PRIVACY, SET_PUBLISHED, UNCHECK_EMPLOYMENT_WORKDAY, @@ -41,6 +42,7 @@ export type ValidertFelt = | 'location' | 'postalCode' | 'locationArea' + | 'yrkestittel' | 'adText' | 'expires' | 'published' @@ -139,6 +141,16 @@ function* validateLocationArea(): Generator { yield removeValidationError({ field: 'locationArea' }); } } +function* validateYrkestittel(): Generator { + 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 { const adText = yield select((state) => state.adData?.properties.adtext); @@ -477,6 +489,7 @@ export function* validateAll(): Generator { yield validateLocation(); yield validateExpireDate(); yield validatePublishDate(); + yield validateYrkestittel(); yield validateAdtext(); yield validateApplicationEmail(); yield validatePostalCode(); @@ -500,6 +513,7 @@ export function hasValidationErrors(validation: Record = ({ categoryList, tittel }) => { const feilmeldingTilBruker = suggestions.kind === Nettstatus.Feil && suggestions.error.message; return ( - +
+ +
); }; +/* */ const finnJanzzStilling = (suggestions: JanzzStilling[], navn: string) => suggestions.find(