-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/kontantstøttePerioder' into kont…
…antstøttePerioder
- Loading branch information
Showing
43 changed files
with
825 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { byggHenterRessurs, byggTomRessurs, Ressurs } from '../typer/ressurs'; | ||
import { useApp } from '../context/AppContext'; | ||
import { useCallback, useState } from 'react'; | ||
import { IOppgaveRequest } from '../../Komponenter/Oppgavebenk/typer/oppgaverequest'; | ||
import { IOppgave } from '../../Komponenter/Oppgavebenk/typer/oppgave'; | ||
|
||
export interface IOppgaverResponse { | ||
antallTreffTotalt: number; | ||
oppgaver: IOppgave[]; | ||
} | ||
|
||
export const useHentOppgaver = () => { | ||
const { axiosRequest } = useApp(); | ||
const [oppgaver, settOppgaver] = useState<Ressurs<IOppgaverResponse>>(byggTomRessurs()); | ||
|
||
const hentOppgaver = useCallback( | ||
(data: IOppgaveRequest) => { | ||
settOppgaver(byggHenterRessurs()); | ||
axiosRequest<IOppgaverResponse, IOppgaveRequest>({ | ||
method: 'POST', | ||
url: `/familie-ef-sak/api/oppgave/soek`, | ||
data, | ||
}).then((res: Ressurs<IOppgaverResponse>) => { | ||
settOppgaver(res); | ||
}); | ||
}, | ||
[axiosRequest] | ||
); | ||
|
||
return { hentOppgaver, oppgaver }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,44 @@ | ||
import { RessursFeilet, RessursStatus, RessursSuksess } from '../typer/ressurs'; | ||
import { byggTomRessurs, Ressurs } from '../typer/ressurs'; | ||
import { useApp } from '../context/AppContext'; | ||
import { useCallback, useState, useEffect } from 'react'; | ||
import { useCallback, useState } from 'react'; | ||
import { OppgaveTypeForOpprettelse } from '../../Komponenter/Behandling/Totrinnskontroll/oppgaveForOpprettelseTyper'; | ||
|
||
export interface IOppgaverForOpprettelse { | ||
feilmelding: string | undefined; | ||
hentOppgaverForOpprettelse: (behandlingId: string) => void; | ||
oppgavetyperSomKanOpprettes: OppgaveTypeForOpprettelse[]; | ||
oppgavetyperSomSkalOpprettes: OppgaveTypeForOpprettelse[]; | ||
settOppgavetyperSomSkalOpprettes: React.Dispatch< | ||
React.SetStateAction<OppgaveTypeForOpprettelse[]> | ||
>; | ||
import { AxiosRequestConfig } from 'axios'; | ||
import { useRerunnableEffect } from '../hooks/felles/useRerunnableEffect'; | ||
interface OppgaverForOpprettelseRequest { | ||
hentOppgaverForOpprettelseCallback: { | ||
rerun: () => void; | ||
}; | ||
oppgaverForOpprettelse: Ressurs<OppgaverForOpprettelse>; | ||
} | ||
|
||
interface OppgaverForOpprettelseRequest { | ||
interface OppgaverForOpprettelse { | ||
oppgavetyperSomKanOpprettes: OppgaveTypeForOpprettelse[]; | ||
oppgavetyperSomSkalOpprettes: OppgaveTypeForOpprettelse[]; | ||
} | ||
|
||
export const useHentOppgaverForOpprettelse = (behandlingId: string): IOppgaverForOpprettelse => { | ||
export const useHentOppgaverForOpprettelse = ( | ||
behandlingId: string | ||
): OppgaverForOpprettelseRequest => { | ||
const { axiosRequest } = useApp(); | ||
const [oppgavetyperSomKanOpprettes, settOppgavetyperSomKanOpprettes] = useState< | ||
OppgaveTypeForOpprettelse[] | ||
>([]); | ||
const [oppgavetyperSomSkalOpprettes, settOppgavetyperSomSkalOpprettes] = useState< | ||
OppgaveTypeForOpprettelse[] | ||
>([]); | ||
const [feilmelding, settFeilmelding] = useState<string>(); | ||
|
||
const hentOppgaverForOpprettelse = useCallback( | ||
(behandlingId: string) => { | ||
settFeilmelding(undefined); | ||
axiosRequest<OppgaverForOpprettelseRequest, undefined>({ | ||
const [oppgaverForOpprettelse, settOppgaverForOpprettelse] = | ||
useState<Ressurs<OppgaverForOpprettelse>>(byggTomRessurs()); | ||
|
||
const hentOppgaverForOpprettelseCallback = useRerunnableEffect( | ||
useCallback(() => { | ||
const behandlingConfig: AxiosRequestConfig = { | ||
method: 'GET', | ||
url: `/familie-ef-sak/api/oppgaverforopprettelse/${behandlingId}`, | ||
}).then((res: RessursSuksess<OppgaverForOpprettelseRequest> | RessursFeilet) => { | ||
if (res.status === RessursStatus.SUKSESS) { | ||
settOppgavetyperSomSkalOpprettes(res.data.oppgavetyperSomSkalOpprettes); | ||
settOppgavetyperSomKanOpprettes(res.data.oppgavetyperSomKanOpprettes); | ||
} else { | ||
settFeilmelding( | ||
'Noe gikk galt under henting av oppgaver som kan opprettes. Forsøk å last siden på nytt. ' + | ||
res.frontendFeilmelding | ||
); | ||
} | ||
}); | ||
}, | ||
[axiosRequest] | ||
}; | ||
axiosRequest<OppgaverForOpprettelse, null>(behandlingConfig).then( | ||
(res: Ressurs<OppgaverForOpprettelse>) => settOppgaverForOpprettelse(res) | ||
); | ||
}, [axiosRequest, behandlingId]), | ||
[axiosRequest, behandlingId] | ||
); | ||
|
||
useEffect(() => { | ||
hentOppgaverForOpprettelse(behandlingId); | ||
}, [behandlingId, hentOppgaverForOpprettelse]); | ||
|
||
return { | ||
feilmelding, | ||
hentOppgaverForOpprettelse, | ||
oppgavetyperSomKanOpprettes, | ||
oppgavetyperSomSkalOpprettes, | ||
settOppgavetyperSomSkalOpprettes, | ||
oppgaverForOpprettelse, | ||
hentOppgaverForOpprettelseCallback, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React, { FC } from 'react'; | ||
import styled from 'styled-components'; | ||
import { AGray900 } from '@navikt/ds-tokens/dist/tokens'; | ||
|
||
export const StyledDiv = styled.div<{ $farge: string }>` | ||
border-bottom: 2px solid ${({ $farge }) => $farge}; | ||
`; | ||
|
||
export const Divider: FC<{ farge?: string }> = ({ farge = `${AGray900}` }) => { | ||
return <StyledDiv $farge={farge} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.