Skip to content

Commit

Permalink
Finn kandidater stilling (#247)
Browse files Browse the repository at this point in the history
* Finn kandidater for stilling

* wip
  • Loading branch information
Wiklem authored Oct 18, 2024
1 parent ec60804 commit 283dafa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 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/openai-evaluering'
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/finn-kandidater-stilling'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
17 changes: 4 additions & 13 deletions src/kandidatsok/hooks/useSøkekriterierFraStilling.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
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 [harLagtTilKriterier, setHarLagtTilKriterier] = useState(false);

const { data: fylker, isLoading: fylkerIsLoading } = useHentFylker();
Expand All @@ -40,7 +37,6 @@ const useSøkekriterierFraStilling = (
if (
rekrutteringsbistandstilling &&
brukKriterierFraStillingen &&
søkeKriterierIkkeLagtTil(searchParams) &&
!fylkerIsLoading &&
!harLagtTilKriterier
) {
Expand Down Expand Up @@ -92,9 +88,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;
20 changes: 19 additions & 1 deletion src/kandidatsok/kandidatlistebanner/Kandidatlistebanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,33 @@ import { FunctionComponent } from 'react';
import { Link } from 'react-router-dom';
import useHentStilling, { useHentStillingTittel } from '../../felles/hooks/useStilling';
import { lenkeTilStilling } from '../../felles/lenker';
import useNavigeringsstate from '../hooks/useNavigeringsstate';
import useSøkekriterierFraStilling from '../hooks/useSøkekriterierFraStilling';
import css from './Kandidatlistebanner.module.css';
import useNavigeringsstate from '../hooks/useNavigeringsstate';

type Props = {
stillingId?: string;
};

const Kandidatlistebanner: FunctionComponent<Props> = ({ stillingId }) => {
if (stillingId) {
return <KandidatlistebannerVisningStilling stillingId={stillingId} />;
}

return <KandidatlistebannerVisning />;
};

const KandidatlistebannerVisningStilling = ({ stillingId }: { stillingId: string }) => {
const { stilling, isLoading } = useHentStilling(stillingId);
useSøkekriterierFraStilling(stilling, true);
if (isLoading) {
return <Loader size="medium" />;
}

return <KandidatlistebannerVisning stillingId={stillingId} />;
};

const KandidatlistebannerVisning: FunctionComponent<Props> = ({ stillingId }) => {
const navigeringsstate = useNavigeringsstate();
const {
stilling: rekrutteringsbistandstilling,
Expand Down

0 comments on commit 283dafa

Please sign in to comment.