Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finn kandidater stilling #247

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading