Skip to content

Commit

Permalink
Fjerne unødvendig sjekk som hindrer søk på kriterier
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiklem committed Oct 11, 2024
1 parent 346d730 commit 6c19e02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 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/fjerne-filterOrd'
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/fjerne-sjekk'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
28 changes: 13 additions & 15 deletions src/kandidatsok/hooks/useSøkekriterierFraStilling.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { FilterParam } from './useQuery';
import useSøkekriterier, { LISTEPARAMETER_SEPARATOR } from './useSøkekriterier';
import { KandidatsokQueryParam } from 'felles/lenker';
import { HentFylkerDTO, useHentFylker } from '../../api/stillings-api/hentFylker';
import {
formaterStedsnavn,
lagKandidatsøkstreng,
stedmappingFraGammeltNavn,
stedmappingFraGammeltNummer,
} from 'felles/MappingSted';
import { Rekrutteringsbistandstilling } from 'felles/domene/stilling/Stilling';
import { useEffect, useState } from 'react';
import { HentFylkerDTO, useHentFylker } from '../../api/stillings-api/hentFylker';
import { FilterParam } from './useQuery';
import useSøkekriterier, { LISTEPARAMETER_SEPARATOR } from './useSøkekriterier';

const useSøkekriterierFraStilling = (
rekrutteringsbistandstilling: Rekrutteringsbistandstilling | undefined,
brukKriterierFraStillingen: boolean
) => {
const { setSearchParam } = useSøkekriterier();
const [searchParams] = useSearchParams();
// const [searchParams] = useSearchParams();
const [harLagtTilKriterier, setHarLagtTilKriterier] = useState(false);

const { data: fylker, isLoading: fylkerIsLoading } = useHentFylker();
Expand All @@ -40,14 +38,19 @@ const useSøkekriterierFraStilling = (
if (
rekrutteringsbistandstilling &&
brukKriterierFraStillingen &&
søkeKriterierIkkeLagtTil(searchParams) &&
!fylkerIsLoading &&
!harLagtTilKriterier
) {
anvendSøkekriterier(rekrutteringsbistandstilling);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [rekrutteringsbistandstilling, brukKriterierFraStillingen, JSON.stringify(fylker)]);
}, [
rekrutteringsbistandstilling,
brukKriterierFraStillingen,
fylkerIsLoading,
harLagtTilKriterier,
fylker,
setSearchParam,
]);
};

const hentØnsketYrkeFraStilling = (rekrutteringsbistandstilling: Rekrutteringsbistandstilling) => {
Expand Down Expand Up @@ -92,9 +95,4 @@ const hentØnsketStedFraStilling = (
}
};

const søkeKriterierIkkeLagtTil = (searchParams: URLSearchParams) =>
Array.from(searchParams.keys()).every(
(param) => param === KandidatsokQueryParam.Kandidatliste
) || Array.from(searchParams.keys()).every((param) => param === KandidatsokQueryParam.Stilling);

export default useSøkekriterierFraStilling;

0 comments on commit 6c19e02

Please sign in to comment.