Skip to content

Commit

Permalink
Bytte fra location til locationList
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiklem committed Oct 25, 2024
1 parent 35d66df commit ef721a1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions mock/stilling-api/mockStilling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions src/felles/domene/stilling/Stilling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -35,12 +35,6 @@ export type Stilling = Stillingbase & {
contactList?: Kontaktinfo[];
mediaList?: object[];
properties: Properties & Record<string, any>;
location: {
municipalCode: string | null;
municipal: string | null;
postalCode: string | null;
county: string | null;
};
};

// TODO: Fjern nå vi har byttet om
Expand Down
11 changes: 9 additions & 2 deletions src/kandidatsok/hooks/useSøkekriterierFraStilling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/stilling/stilling/Stilling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const Stilling = () => {
<Stillingstittel
tittel={hentTittelFraStilling(stilling)}
employer={stilling.properties.employer}
location={stilling.location}
locationList={stilling.locationList}
/>
)}
</>
Expand Down
22 changes: 12 additions & 10 deletions src/stilling/stilling/forhåndsvisning/header/Stillingstittel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Props> = ({ tittel, employer, location }) => {
const Stillingstittel: FunctionComponent<Props> = ({ 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));
Expand Down

0 comments on commit ef721a1

Please sign in to comment.