From ef721a1725925152d75765751eb376f6ae83f88f Mon Sep 17 00:00:00 2001 From: Erlend Wiklem Date: Fri, 25 Oct 2024 14:01:17 +0200 Subject: [PATCH] Bytte fra location til locationList --- .github/workflows/deploy.yml | 2 +- mock/stilling-api/mockStilling.ts | 25 ++++++++++--------- src/felles/domene/stilling/Stilling.ts | 8 +----- .../useS\303\270kekriterierFraStilling.ts" | 11 ++++++-- src/stilling/stilling/Stilling.tsx | 2 +- .../header/Stillingstittel.tsx" | 22 ++++++++-------- 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index eae72dca..b35b9303 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,7 +45,7 @@ jobs: deploy-til-dev: name: Deploy til dev-gcp needs: bygg-og-push-docker-image - if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/finn-kandidat-for-stilling' + if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/fjern-location-felt' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/mock/stilling-api/mockStilling.ts b/mock/stilling-api/mockStilling.ts index 60ea6374..5fae3b9c 100644 --- a/mock/stilling-api/mockStilling.ts +++ b/mock/stilling-api/mockStilling.ts @@ -283,18 +283,19 @@ export const mockNyRekrutteringsbistandstilling: Rekrutteringsbistandstilling = remarks: [], navIdent: mockVeileder.navIdent, }, - location: { - address: 'Lysaker', - postalCode: '1366', - county: 'Viken', - municipal: 'OSLO', - municipalCode: '0301', - city: 'Bærum', - country: 'NORGE', - latitude: '59.92257120482907', - longitude: '10.752370920709733', - }, - locationList: [], + locationList: [ + { + address: 'Lysaker', + postalCode: '1366', + county: 'Viken', + municipal: 'OSLO', + municipalCode: '0301', + city: 'Bærum', + country: 'NORGE', + latitude: '59.92257120482907', + longitude: '10.752370920709733', + }, + ], properties: {}, firstPublished: false, publishedByAdmin: null, diff --git a/src/felles/domene/stilling/Stilling.ts b/src/felles/domene/stilling/Stilling.ts index 8c9842ff..9c46c25c 100644 --- a/src/felles/domene/stilling/Stilling.ts +++ b/src/felles/domene/stilling/Stilling.ts @@ -16,7 +16,7 @@ export type Stillingbase = { published: string | null; expires: string | null; administration: Administration | null; - location: Geografi | null; + locationList: Geografi[] | null; publishedByAdmin: string | null; businessName: string | null; }; @@ -35,12 +35,6 @@ export type Stilling = Stillingbase & { contactList?: Kontaktinfo[]; mediaList?: object[]; properties: Properties & Record; - location: { - municipalCode: string | null; - municipal: string | null; - postalCode: string | null; - county: string | null; - }; }; // TODO: Fjern nå vi har byttet om diff --git "a/src/kandidatsok/hooks/useS\303\270kekriterierFraStilling.ts" "b/src/kandidatsok/hooks/useS\303\270kekriterierFraStilling.ts" index e2d1fbb0..9c2484d5 100644 --- "a/src/kandidatsok/hooks/useS\303\270kekriterierFraStilling.ts" +++ "b/src/kandidatsok/hooks/useS\303\270kekriterierFraStilling.ts" @@ -4,7 +4,7 @@ import { stedmappingFraGammeltNavn, stedmappingFraGammeltNummer, } from 'felles/MappingSted'; -import { Rekrutteringsbistandstilling } from 'felles/domene/stilling/Stilling'; +import { Geografi, Rekrutteringsbistandstilling } from 'felles/domene/stilling/Stilling'; import { useEffect, useState } from 'react'; import { HentFylkerDTO, useHentFylker } from '../../api/stillings-api/hentFylker'; import useHentStilling from '../../felles/hooks/useStilling'; @@ -64,7 +64,14 @@ const hentØnsketStedFraStilling = ( rekrutteringsbistandstilling: Rekrutteringsbistandstilling, fylker: HentFylkerDTO | undefined ): string | null => { - const { location } = rekrutteringsbistandstilling.stilling; + const { locationList } = rekrutteringsbistandstilling.stilling; + if (!locationList) return null; + return locationList + .map((location) => lagSøkestrengFraLokasjonsListe(location, fylker)) + .join(LISTEPARAMETER_SEPARATOR); +}; + +const lagSøkestrengFraLokasjonsListe = (location: Geografi, fylker: HentFylkerDTO | undefined) => { const { municipal, municipalCode, county } = location; if (municipal && municipalCode) { diff --git a/src/stilling/stilling/Stilling.tsx b/src/stilling/stilling/Stilling.tsx index f01e6b93..c6836636 100644 --- a/src/stilling/stilling/Stilling.tsx +++ b/src/stilling/stilling/Stilling.tsx @@ -237,7 +237,7 @@ const Stilling = () => { )} diff --git "a/src/stilling/stilling/forh\303\245ndsvisning/header/Stillingstittel.tsx" "b/src/stilling/stilling/forh\303\245ndsvisning/header/Stillingstittel.tsx" index 107093bb..a4f8ac09 100644 --- "a/src/stilling/stilling/forh\303\245ndsvisning/header/Stillingstittel.tsx" +++ "b/src/stilling/stilling/forh\303\245ndsvisning/header/Stillingstittel.tsx" @@ -7,19 +7,21 @@ import css from './Stillingstittel.module.css'; type Props = { tittel?: string; employer?: string; - location?: Geografi | null; + locationList?: Geografi[] | null; }; -const Stillingstittel: FunctionComponent = ({ tittel, employer, location }) => { +const Stillingstittel: FunctionComponent = ({ tittel, employer, locationList }) => { let mestSpesifikkeSted = ''; - if (location) { - if (location.city) { - mestSpesifikkeSted = location.city; - } else if (location.municipal) { - mestSpesifikkeSted = location.municipal; - } else if (location.country) { - mestSpesifikkeSted = location.country; - } + if (locationList) { + locationList.forEach((location) => { + if (location.city) { + mestSpesifikkeSted = `${location.city}, ${mestSpesifikkeSted}`.trim(); + } else if (location.municipal) { + mestSpesifikkeSted = `${location.municipal}, ${mestSpesifikkeSted}`.trim(); + } else if (location.country) { + mestSpesifikkeSted = `${location.country}, ${mestSpesifikkeSted}`.trim(); + } + }); } const formatertSted = commaSeparate(employer, capitalizeLocation(mestSpesifikkeSted));