|
2 | 2 | import { BodyShort, Box, Heading, Link } from '@navikt/ds-react';
|
3 | 3 | import React from 'react';
|
4 | 4 | import { dateFormatter } from '@navikt/sif-common-utils';
|
| 5 | +import { Msg } from '../../i18n'; |
5 | 6 | import { Venteårsak } from '../../types/Venteårsak';
|
6 | 7 | import { browserEnv } from '../../utils/env';
|
7 |
| -import { Msg, useMessages } from '../../i18n'; |
8 | 8 | import { erSaksbehandlingsfristPassert } from '../../utils/sakUtils';
|
9 | 9 |
|
10 | 10 | interface Props {
|
@@ -38,23 +38,41 @@ const getFristTekst = (frist: Date, venteårsak?: Venteårsak): React.ReactNode
|
38 | 38 | }
|
39 | 39 | };
|
40 | 40 |
|
41 |
| -const Saksbehandlingstid: React.FunctionComponent<Props> = ({ frist, venteårsak, saksbehandlingstidUker = 7 }) => { |
| 41 | +const SaksbehandlingstidMelding = ({ frist, venteårsak, saksbehandlingstidUker }: Props) => { |
42 | 42 | const fristErPassert = frist ? erSaksbehandlingsfristPassert(frist) : false;
|
43 |
| - const { text } = useMessages(); |
| 43 | + if (frist) { |
| 44 | + return fristErPassert ? ( |
| 45 | + <> |
| 46 | + <BodyShort spacing={true}> |
| 47 | + <Msg id="svarfrist.fristPassert.1" /> |
| 48 | + </BodyShort> |
| 49 | + <BodyShort spacing={true}> |
| 50 | + <Msg id="svarfrist.fristPassert.2" /> |
| 51 | + </BodyShort> |
| 52 | + </> |
| 53 | + ) : ( |
| 54 | + getFristTekst(frist, venteårsak) |
| 55 | + ); |
| 56 | + } |
| 57 | + return <Msg id="svarfrist.forventetBehandlingstid" values={{ saksbehandlingstidUker }} />; |
| 58 | +}; |
| 59 | + |
| 60 | +const Saksbehandlingstid: React.FunctionComponent<Props> = ({ frist, venteårsak, saksbehandlingstidUker = 7 }) => { |
44 | 61 | return (
|
45 | 62 | <Box>
|
46 | 63 | <Heading size="medium" level="2" className="text-deepblue-800" spacing={true}>
|
47 |
| - {text('svarfrist.tittel')} |
| 64 | + <Msg id="svarfrist.tittel" /> |
48 | 65 | </Heading>
|
49 | 66 | <BodyShort as="div" className="bg-deepblue-100 pt-4 pl-6 pr-6 pb-6 rounded">
|
50 |
| - {frist && fristErPassert === false ? ( |
51 |
| - <p className="mb-2">{getFristTekst(frist, venteårsak)}</p> |
52 |
| - ) : ( |
53 |
| - <p className="mb-2">{text('svarfrist.forventetBehandlingstid', { saksbehandlingstidUker })}</p> |
54 |
| - )} |
55 |
| - |
| 67 | + <Box className="mb-2"> |
| 68 | + <SaksbehandlingstidMelding |
| 69 | + frist={frist} |
| 70 | + venteårsak={venteårsak} |
| 71 | + saksbehandlingstidUker={saksbehandlingstidUker} |
| 72 | + /> |
| 73 | + </Box> |
56 | 74 | <Link variant="neutral" href={browserEnv.NEXT_PUBLIC_SAKSBEHANDLINGSTID_INFO_URL}>
|
57 |
| - {text('svarfrist.lesMerLenke')} |
| 75 | + <Msg id="svarfrist.lesMerLenke" /> |
58 | 76 | </Link>
|
59 | 77 | </BodyShort>
|
60 | 78 | </Box>
|
|
0 commit comments