-
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.
Vise kontantstøtteperioder under vedtak og beregning for barnetilsyn (#…
…2988) * Skal vise evt tidligere kontantstøtteperioder i vedtak og beregning for barnetilsyn * viser "nå" hvis perioden er løpende * tomMåned for KsPeriode skal være non-nullable * Skal allikevel ha tomMåned nullable for KsPeriode da infotrygdperioder kan være null her * Skal vise tomt felt hvis tomMåned er null * Fjerner harKontantstøttePerioder og gjør kontantstøtteperioder non-nullable for bedre håndtering * Fjerner harKontantstøttePerioder ifm KontantstøtteAlert siden dette kan utledes av listen av perioder * Update src/frontend/Komponenter/Behandling/VedtakOgBeregning/Barnetilsyn/InnvilgeVedtak/KontantstøtteAlert.tsx * Skal vise når kontantstøtteperioder fra KS er hentet for å kunne lese kontekst bedre --------- Co-authored-by: Viktor Solberg <viktor.grondalen.solberg@nav.no>
- Loading branch information
1 parent
a868bb9
commit b97b131
Showing
6 changed files
with
153 additions
and
18 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
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
119 changes: 106 additions & 13 deletions
119
...omponenter/Behandling/VedtakOgBeregning/Barnetilsyn/InnvilgeVedtak/KontantstøtteAlert.tsx
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,27 +1,120 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { Alert } from '@navikt/ds-react'; | ||
import { Alert, Button } from '@navikt/ds-react'; | ||
import { ChevronDownIcon, ChevronUpIcon } from '@navikt/aksel-icons'; | ||
import { KontantstøttePeriode } from '../../../Inngangsvilkår/vilkår'; | ||
import { BodyShortSmall } from '../../../../../Felles/Visningskomponenter/Tekster'; | ||
import { formaterIsoDato, formaterIsoMånedÅr } from '../../../../../App/utils/formatter'; | ||
|
||
const AlertStripe = styled(Alert)` | ||
margin-top: 1rem; | ||
margin-top: 0.5rem; | ||
margin-bottom: 0.5rem; | ||
padding: 1rem; | ||
`; | ||
|
||
const InnholdContainer = styled.ul` | ||
margin-left: 1rem; | ||
padding-left: 0.5rem; | ||
margin-bottom: 1rem; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
margin-left: 1rem; | ||
padding-left: 0.5rem; | ||
padding-top: 0.2rem; | ||
padding-bottom: 0.2rem; | ||
`; | ||
|
||
interface Props { | ||
harKontantstøttePerioder?: boolean; | ||
kontantstøttePerioderFraGrunnlagsdata: KontantstøttePeriode[]; | ||
registeropplysningerOpprettetTid: string; | ||
} | ||
export const KontantstøtteAlert: React.FC<Props> = ({ harKontantstøttePerioder }) => { | ||
if (harKontantstøttePerioder === null || harKontantstøttePerioder === undefined) { | ||
return null; | ||
|
||
const utledKontantstøtteperioderAlertTekst = ( | ||
kontantstøttePerioderFraGrunnlagsdata: KontantstøttePeriode[], | ||
registeropplysningerOpprettetTid: string, | ||
harKontantstøttePerioder?: boolean | ||
): string => { | ||
if (!harKontantstøttePerioder && kontantstøttePerioderFraGrunnlagsdata.length === 0) { | ||
return `Bruker har verken fått eller får kontantstøtte (oppdatert ${formaterIsoDato( | ||
registeropplysningerOpprettetTid | ||
)})`; | ||
} | ||
if (kontantstøttePerioderFraGrunnlagsdata.length > 0) { | ||
return `Brukers kontantstøtteperioder (hentet ${formaterIsoDato( | ||
registeropplysningerOpprettetTid | ||
)})`; | ||
} | ||
return 'Bruker har eller har fått kontantstøtte'; | ||
}; | ||
|
||
const kontantstøtteKilde = (kilde: string): string => { | ||
return kilde.toLowerCase().includes('ks_sak') ? 'KS sak' : kilde.toLowerCase(); | ||
}; | ||
|
||
export const KontantstøtteAlert: React.FC<Props> = ({ | ||
harKontantstøttePerioder, | ||
kontantstøttePerioderFraGrunnlagsdata, | ||
registeropplysningerOpprettetTid, | ||
}) => { | ||
const [ekspandert, settEkspandert] = useState(false); | ||
const harFlereKontantstøttePerioder = kontantstøttePerioderFraGrunnlagsdata.length > 1; | ||
|
||
return ( | ||
<> | ||
<AlertStripe variant={harKontantstøttePerioder ? 'warning' : 'info'} size={'small'}> | ||
{harKontantstøttePerioder | ||
? 'Bruker har eller har fått kontantstøtte.' | ||
: 'Bruker har verken fått eller får kontantstøtte.'} | ||
</AlertStripe> | ||
</> | ||
<AlertStripe variant="info"> | ||
{utledKontantstøtteperioderAlertTekst( | ||
kontantstøttePerioderFraGrunnlagsdata, | ||
registeropplysningerOpprettetTid, | ||
harKontantstøttePerioder | ||
)} | ||
{kontantstøttePerioderFraGrunnlagsdata.length > 0 && ( | ||
<> | ||
<InnholdContainer> | ||
<li> | ||
<BodyShortSmall> | ||
{formaterIsoMånedÅr( | ||
kontantstøttePerioderFraGrunnlagsdata[0].fomMåned | ||
)}{' '} | ||
-{' '} | ||
{kontantstøttePerioderFraGrunnlagsdata[0].tomMåned | ||
? formaterIsoMånedÅr( | ||
kontantstøttePerioderFraGrunnlagsdata[0].tomMåned | ||
) | ||
: ''}{' '} | ||
{'(kilde: ' + | ||
kontantstøtteKilde( | ||
kontantstøttePerioderFraGrunnlagsdata[0].kilde | ||
) + | ||
')'} | ||
</BodyShortSmall> | ||
</li> | ||
{harFlereKontantstøttePerioder && | ||
ekspandert && | ||
kontantstøttePerioderFraGrunnlagsdata.slice(1).map((periode, index) => ( | ||
<li key={index}> | ||
<BodyShortSmall> | ||
{formaterIsoMånedÅr(periode.fomMåned)} -{' '} | ||
{periode.tomMåned | ||
? formaterIsoMånedÅr(periode.tomMåned) | ||
: ''}{' '} | ||
{'(kilde: ' + kontantstøtteKilde(periode.kilde) + ')'} | ||
</BodyShortSmall> | ||
</li> | ||
))} | ||
</InnholdContainer> | ||
{harFlereKontantstøttePerioder && ( | ||
<StyledButton | ||
variant="tertiary" | ||
icon={ekspandert ? <ChevronUpIcon /> : <ChevronDownIcon />} | ||
iconPosition="right" | ||
onClick={() => settEkspandert((prev) => !prev)} | ||
> | ||
{ekspandert ? 'Skjul perioder' : 'Se flere perioder'} | ||
</StyledButton> | ||
)} | ||
</> | ||
)} | ||
</AlertStripe> | ||
); | ||
}; |
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