diff --git a/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.stories.tsx b/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.stories.tsx index 8d4e617f78..3347511a20 100644 --- a/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.stories.tsx +++ b/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.stories.tsx @@ -3,11 +3,16 @@ import { action } from '@storybook/addon-actions'; import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes'; import aksjonspunktStatus from '@fpsak-frontend/kodeverk/src/aksjonspunktStatus'; import { behandlingType } from '@k9-sak-web/backend/k9sak/kodeverk/behandling/BehandlingType.js'; +import { fagsakYtelsesType } from '@k9-sak-web/backend/k9sak/kodeverk/FagsakYtelsesType.js'; import { KodeverkProvider } from '@k9-sak-web/gui/kodeverk/index.js'; import alleKodeverk from '@k9-sak-web/gui/storybook/mocks/alleKodeverk.json'; import { AksjonspunktDto, BehandlingDto } from '@navikt/k9-sak-typescript-client'; import TilkjentYtelseProsessIndex from './TilkjentYtelseProsessIndex'; +const fagsak = { + sakstype: { kode: fagsakYtelsesType.PSB, kodeverk: 'FAGSAK_YTELSE' }, +}; + const behandling = { id: 1, versjon: 1, @@ -160,6 +165,7 @@ export const visUtenAksjonspunkt = args => ( alleKodeverk={alleKodeverk as any} submitCallback={action('button-click')} arbeidsgiverOpplysningerPerId={arbeidsgiverOpplysningerPerId} + fagsak={fagsak} {...args} /> ); @@ -184,6 +190,7 @@ export const visÅpentAksjonspunktTilbaketrekk = args => ( alleKodeverk={alleKodeverk as any} submitCallback={action('button-click')} arbeidsgiverOpplysningerPerId={arbeidsgiverOpplysningerPerId} + fagsak={fagsak} {...args} /> ); @@ -213,6 +220,7 @@ export const visÅpentAksjonspunktManuellTilkjentYtelse = args => ( } submitCallback={action('button-click')} arbeidsgiverOpplysningerPerId={arbeidsgiverOpplysningerPerId} + fagsak={fagsak} {...args} /> diff --git a/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.tsx b/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.tsx index f2cd8bc631..6d5cc9d67b 100644 --- a/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.tsx +++ b/packages/prosess-tilkjent-ytelse/src/TilkjentYtelseProsessIndex.tsx @@ -1,3 +1,4 @@ +import { fagsakYtelsesType } from '@k9-sak-web/backend/k9sak/kodeverk/FagsakYtelsesType.js'; import { ArbeidsgiverOpplysningerPerId } from '@k9-sak-web/types'; import { AksjonspunktDto, @@ -35,6 +36,7 @@ const TilkjentYtelseProsessIndex = ({ submitCallback, readOnlySubmitButton, arbeidsgiverOpplysningerPerId, + fagsak, }: OwnProps) => ( ); diff --git a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.spec.tsx b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.spec.tsx index 06dc372972..5d8bf9bf27 100644 --- a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.spec.tsx +++ b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.spec.tsx @@ -51,6 +51,7 @@ describe('', () => { groups={[]} kodeverkNavnFraKode={kodeverkNavnFraKode} arbeidsgiverOpplysningerPerId={{}} + isUngdomsytelseFagsak={false} />, ); diff --git a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.tsx b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.tsx index b683b33072..d9dd05f886 100644 --- a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.tsx +++ b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelse.tsx @@ -112,6 +112,7 @@ interface OwnProps { }[]; kodeverkNavnFraKode: (kode: string, kodeverkType: KodeverkType) => string; arbeidsgiverOpplysningerPerId: ArbeidsgiverOpplysningerPerId; + isUngdomsytelseFagsak: boolean; } interface OwnState { @@ -237,7 +238,7 @@ export class TilkjentYtelse extends Component { goBackward, goForward, openPeriodInfo, - props: { groups, items, kodeverkNavnFraKode, arbeidsgiverOpplysningerPerId }, + props: { groups, items, kodeverkNavnFraKode, arbeidsgiverOpplysningerPerId, isUngdomsytelseFagsak }, selectHandler, state: { selectedItem }, zoomIn, @@ -277,6 +278,7 @@ export class TilkjentYtelse extends Component { callbackForward={nextPeriod} callbackBackward={prevPeriod} arbeidsgiverOpplysningerPerId={arbeidsgiverOpplysningerPerId} + isUngdomsytelseFagsak={isUngdomsytelseFagsak} /> )} diff --git a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelsePanel.tsx b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelsePanel.tsx index 87f4d883c0..88e84565f9 100644 --- a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelsePanel.tsx +++ b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelsePanel.tsx @@ -47,6 +47,7 @@ interface PureOwnProps { submitCallback: (data: any) => Promise; readOnlySubmitButton: boolean; arbeidsgiverOpplysningerPerId: ArbeidsgiverOpplysningerPerId; + isUngdomsytelseFagsak: boolean; } const TilkjentYtelsePanelImpl = ({ @@ -56,6 +57,7 @@ const TilkjentYtelsePanelImpl = ({ aksjonspunkter, readOnly, arbeidsgiverOpplysningerPerId, + isUngdomsytelseFagsak, }: Partial) => { const { getKodeverkNavnFraKodeFn } = useKodeverkContext(); const kodeverkNavnFraKode = getKodeverkNavnFraKodeFn(); @@ -73,6 +75,7 @@ const TilkjentYtelsePanelImpl = ({ groups={groups} arbeidsgiverOpplysningerPerId={arbeidsgiverOpplysningerPerId} kodeverkNavnFraKode={kodeverkNavnFraKode} + isUngdomsytelseFagsak={isUngdomsytelseFagsak} /> )} diff --git a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimeLineData.spec.tsx b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimeLineData.spec.tsx index 923cdde490..05c7872c87 100644 --- a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimeLineData.spec.tsx +++ b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimeLineData.spec.tsx @@ -66,6 +66,7 @@ describe('', () => { selectedItemStartDate={selectedItemStartDate} selectedItemEndDate={selectedItemEndDate} arbeidsgiverOpplysningerPerId={{}} + isUngdomsytelseFagsak={false} />, ); diff --git a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimelineData.tsx b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimelineData.tsx index 3be1f03cb4..fabe45b006 100644 --- a/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimelineData.tsx +++ b/packages/prosess-tilkjent-ytelse/src/components/TilkjentYtelseTimelineData.tsx @@ -18,6 +18,7 @@ interface OwnProps { callbackForward: (...args: any[]) => any; callbackBackward: (...args: any[]) => any; arbeidsgiverOpplysningerPerId: ArbeidsgiverOpplysningerPerId; + isUngdomsytelseFagsak: boolean; } /** @@ -38,6 +39,7 @@ const TilkjentYtelseTimeLineData = ({ callbackForward, callbackBackward, arbeidsgiverOpplysningerPerId, + isUngdomsytelseFagsak, }: OwnProps) => { const { kodeverkNavnFraKode } = useKodeverkContext(); const { andeler } = selectedItemData; @@ -145,45 +147,47 @@ const TilkjentYtelseTimeLineData = ({ ))} - - - {andeler.map((andel, index) => { - const label = createArbeidsgiverVisningsnavnForAndel( - andel, - kodeverkNavnFraKode, - arbeidsgiverOpplysningerPerId, - ); - return ; - })} - - {andeler.map((andel, index) => ( - -
- - {`Utbetalt refusjon: `} - {andel?.refusjon} kr - - - {`Utbetalt til søker: `} - {andel?.tilSoker} kr - - - {`Utbetalingsgrad: `} - {andel?.utbetalingsgrad} % - - - {`Aktivitetsstatus: `} - - {getAktivitet(andel?.aktivitetStatus, kodeverkNavnFraKode)} - - -
-
- ))} -
+ {!isUngdomsytelseFagsak && ( + + + {andeler.map((andel, index) => { + const label = createArbeidsgiverVisningsnavnForAndel( + andel, + kodeverkNavnFraKode, + arbeidsgiverOpplysningerPerId, + ); + return ; + })} + + {andeler.map((andel, index) => ( + +
+ + {`Utbetalt refusjon: `} + {andel?.refusjon} kr + + + {`Utbetalt til søker: `} + {andel?.tilSoker} kr + + + {`Utbetalingsgrad: `} + {andel?.utbetalingsgrad} % + + + {`Aktivitetsstatus: `} + + {getAktivitet(andel?.aktivitetStatus, kodeverkNavnFraKode)} + + +
+
+ ))} +
+ )} ); }; diff --git a/packages/v2/backend/package.json b/packages/v2/backend/package.json index 77a7f9907d..9b474aee84 100644 --- a/packages/v2/backend/package.json +++ b/packages/v2/backend/package.json @@ -16,6 +16,6 @@ }, "dependencies": { "@navikt/k9-klage-typescript-client": "1.0.20240513162434-997f3da", - "@navikt/k9-sak-typescript-client": "1.0.20240916120432" + "@navikt/k9-sak-typescript-client": "1.0.20241022074528" } } diff --git a/packages/v2/gui/src/prosess/ung-beregning/UngBeregning.stories.tsx b/packages/v2/gui/src/prosess/ung-beregning/UngBeregning.stories.tsx new file mode 100644 index 0000000000..b73a62eeb6 --- /dev/null +++ b/packages/v2/gui/src/prosess/ung-beregning/UngBeregning.stories.tsx @@ -0,0 +1,14 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { FakeUngBeregningBackendApi } from '../../storybook/mocks/FakeUngBeregningBackendApi'; +import UngBeregning from './UngBeregning'; + +const api = new FakeUngBeregningBackendApi(); +const meta = { + title: 'gui/prosess/ung-beregning/UngBeregning.tsx', + component: UngBeregning, +} satisfies Meta; +export default meta; + +type Story = StoryObj; + +export const DefaultStory: Story = { args: { behandling: { uuid: '123' }, api } }; diff --git a/packages/v2/gui/src/prosess/ung-beregning/UngBeregning.tsx b/packages/v2/gui/src/prosess/ung-beregning/UngBeregning.tsx new file mode 100644 index 0000000000..02e3c0f3fa --- /dev/null +++ b/packages/v2/gui/src/prosess/ung-beregning/UngBeregning.tsx @@ -0,0 +1,85 @@ +import type { UngdomsytelseSatsPeriodeDto } from '@k9-sak-web/backend/k9sak/generated'; +import { formatPeriod } from '@k9-sak-web/lib/dateUtils/dateUtils.js'; +import { Alert, Heading, Loader, Table } from '@navikt/ds-react'; +import { useQuery } from '@tanstack/react-query'; +import type { UngBeregningBackendApiType } from './UngBeregningBackendApiType'; + +const formatCurrencyWithKr = (value: number) => { + const formattedValue = Number(value).toLocaleString('nb-NO').replace(/,|\s/g, ' '); + return `${formattedValue} kr`; +}; + +const formatCurrencyNoKr = (value: number) => { + if (value === null || value === undefined) { + return undefined; + } + // Fjerner mellomrom i tilfelle vi får inn tall med det + const newVal = value.toString().replace(/\s/g, ''); + if (Number.isNaN(newVal)) { + return undefined; + } + return Number(Math.round(+newVal)).toLocaleString('nb-NO').replace(/,|\s/g, ' '); +}; + +interface Props { + behandling: { uuid: string }; + api: UngBeregningBackendApiType; +} + +const UngBeregning = ({ api, behandling }: Props) => { + const { + data: satser, + isLoading: satserIsLoading, + isSuccess: satserSuccess, + isError: satserIsError, + } = useQuery({ + queryKey: ['satser'], + queryFn: () => api.getSatser(behandling.uuid), + }); + + if (satserIsLoading) { + return ; + } + + if (satserIsError) { + return Noe gikk galt, vennligst prøv igjen senere; + } + + return ( +
+ {satserSuccess && ( +
+ + Satser + + + + + Periode + Sats + + Grunnbeløp + + + Dagsats + + + + + {satser.map(({ fom, tom, satsType, dagsats, grunnbeløp }) => ( + + {fom && tom && formatPeriod(fom, tom)} + {satsType} + {grunnbeløp && formatCurrencyWithKr(grunnbeløp)} + {dagsats && formatCurrencyNoKr(dagsats)} kr + + ))} + +
+
+ )} +
+ ); +}; + +export default UngBeregning; diff --git a/packages/v2/gui/src/prosess/ung-beregning/UngBeregningBackendApiType.ts b/packages/v2/gui/src/prosess/ung-beregning/UngBeregningBackendApiType.ts new file mode 100644 index 0000000000..391d4157be --- /dev/null +++ b/packages/v2/gui/src/prosess/ung-beregning/UngBeregningBackendApiType.ts @@ -0,0 +1,5 @@ +import type { UngdomsytelseSatsPeriodeDto } from '@k9-sak-web/backend/k9sak/generated'; + +export type UngBeregningBackendApiType = { + getSatser(behandlingUuid: string): Promise; +}; diff --git a/packages/v2/gui/src/prosess/ung-beregning/UngBeregningBackendClient.ts b/packages/v2/gui/src/prosess/ung-beregning/UngBeregningBackendClient.ts new file mode 100644 index 0000000000..2f509884b5 --- /dev/null +++ b/packages/v2/gui/src/prosess/ung-beregning/UngBeregningBackendClient.ts @@ -0,0 +1,13 @@ +import type { K9SakClient, UngdomsytelseSatsPeriodeDto } from '@k9-sak-web/backend/k9sak/generated'; + +export default class UngBeregningBackendClient { + #k9sak: K9SakClient; + + constructor(k9sakClient: K9SakClient) { + this.#k9sak = k9sakClient; + } + + async getSatser(behandlingUuid: string): Promise { + return this.#k9sak.ung.getUngdomsytelseInnvilgetSats(behandlingUuid); + } +} diff --git a/packages/v2/gui/src/prosess/ung-beregning/UngBeregningIndex.tsx b/packages/v2/gui/src/prosess/ung-beregning/UngBeregningIndex.tsx index 41540c427c..e87382c9cb 100644 --- a/packages/v2/gui/src/prosess/ung-beregning/UngBeregningIndex.tsx +++ b/packages/v2/gui/src/prosess/ung-beregning/UngBeregningIndex.tsx @@ -1,131 +1,17 @@ import type { BehandlingDto } from '@k9-sak-web/backend/k9sak/generated'; -import { formatPeriod } from '@k9-sak-web/lib/dateUtils/dateUtils.js'; -import { Alert, Heading, Loader, Table, VStack } from '@navikt/ds-react'; -import { useQuery } from '@tanstack/react-query'; -import axios, { type AxiosResponse } from 'axios'; - -const formatCurrencyWithKr = (value: number) => { - const formattedValue = Number(value).toLocaleString('nb-NO').replace(/,|\s/g, ' '); - return `${formattedValue} kr`; -}; - -const fetchSatser = (signal: AbortSignal, behandlingUuid: string) => - axios - .get('/k9/sak/api/ungdomsytelse/satser', { signal, params: { behandlingUuid } }) - .then(({ data }: AxiosResponse) => data ?? []); - -const fetchUttak = (signal: AbortSignal, behandlingUuid: string) => - axios - .get('/k9/sak/api/ungdomsytelse/uttak', { signal, params: { behandlingUuid } }) - .then(({ data }: AxiosResponse) => data ?? []); - -interface SatserData { - fom: string; - tom: string; - dagsats: number; - grunnbeløpFaktor: number; - grunnbeløp: number; -} - -interface UttakData { - fom: string; - tom: string; - utbetalingsgrad: number; - avslagsårsak: string | null; -} +import { useContext } from 'react'; +import { K9SakClientContext } from '../../app/K9SakClientContext'; +import UngBeregning from './UngBeregning'; +import UngBeregningBackendClient from './UngBeregningBackendClient'; interface Props { behandling: BehandlingDto; } const UngBeregningIndex = ({ behandling }: Props) => { - const { - data: satser, - isLoading: satserIsLoading, - isSuccess: satserSuccess, - isError: satserIsError, - } = useQuery({ - queryKey: ['satser'], - queryFn: ({ signal }) => fetchSatser(signal, behandling.uuid), - }); - - const { - data: uttak, - isLoading: uttakIsLoading, - isSuccess: uttakSuccess, - isError: uttakIsError, - } = useQuery({ - queryKey: ['uttak'], - queryFn: ({ signal }) => fetchUttak(signal, behandling.uuid), - }); - - if (satserIsLoading || uttakIsLoading) { - return ; - } - - if (satserIsError && uttakIsError) { - return Noe gikk galt, vennligst prøv igjen senere; - } - - return ( -
- - {satserSuccess && ( -
- - Satser - - - - - Periode - Dagsats - Grunnbeløpfaktor - Grunnbeløp - - - - {satser.map(({ fom, tom, dagsats, grunnbeløpFaktor, grunnbeløp }) => ( - - {formatPeriod(fom, tom)} - {dagsats} kr - {grunnbeløpFaktor} - {formatCurrencyWithKr(grunnbeløp)} - - ))} - -
-
- )} - - {uttakSuccess && ( -
- - Uttak - - - - - Periode - Utbetalingsgrad - Avslagsårsak - - - - {uttak.map(({ fom, tom, utbetalingsgrad, avslagsårsak }) => ( - - {formatPeriod(fom, tom)} - {utbetalingsgrad} - {avslagsårsak} - - ))} - -
-
- )} -
-
- ); + const k9SakClient = useContext(K9SakClientContext); + const ungBeregningBackendClient = new UngBeregningBackendClient(k9SakClient); + return ; }; export default UngBeregningIndex; diff --git a/packages/v2/gui/src/storybook/mocks/FakeUngBeregningBackendApi.ts b/packages/v2/gui/src/storybook/mocks/FakeUngBeregningBackendApi.ts new file mode 100644 index 0000000000..32a8aaff4f --- /dev/null +++ b/packages/v2/gui/src/storybook/mocks/FakeUngBeregningBackendApi.ts @@ -0,0 +1,16 @@ +import type { UngdomsytelseSatsPeriodeDto } from '@k9-sak-web/backend/k9sak/generated'; + +export class FakeUngBeregningBackendApi { + async getSatser(): Promise { + return [ + { + fom: '2024-01-01', + tom: '2024-02-01', + dagsats: 608.31, + grunnbeløpFaktor: 1.3333, + grunnbeløp: 118620, + satsType: 'LAV', + }, + ]; + } +} diff --git a/yarn.lock b/yarn.lock index 9d5ea7fe0c..6cb4f4b458 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3958,7 +3958,7 @@ __metadata: resolution: "@k9-sak-web/backend@workspace:packages/v2/backend" dependencies: "@navikt/k9-klage-typescript-client": 1.0.20240513162434-997f3da - "@navikt/k9-sak-typescript-client": 1.0.20240916120432 + "@navikt/k9-sak-typescript-client": 1.0.20241022074528 languageName: unknown linkType: soft @@ -5410,10 +5410,10 @@ __metadata: languageName: node linkType: hard -"@navikt/k9-sak-typescript-client@npm:1.0.20240916120432": - version: 1.0.20240916120432 - resolution: "@navikt/k9-sak-typescript-client@npm:1.0.20240916120432::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40navikt%2Fk9-sak-typescript-client%2F1.0.20240916120432%2F7d012f7d2afeb583907a37501aa04f5ba7aa07ce" - checksum: a528842575e26710e74095be1e44ed42da2758e84aa09f5d4a3af26b786ff4206cecd7697121aea023e1d7b30a3f6efe5c03f5db962d495fe648906882fb4c2b +"@navikt/k9-sak-typescript-client@npm:1.0.20241022074528": + version: 1.0.20241022074528 + resolution: "@navikt/k9-sak-typescript-client@npm:1.0.20241022074528::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40navikt%2Fk9-sak-typescript-client%2F1.0.20241022074528%2Fc8a6937a3b146e15135f2cc175db339d19a74211" + checksum: a3b74841acd868e0f15425c0d6389903ef26dd2c7ff8c393e334e0657bac4d721107a04812b57ac170583866a83d65ada12e96448cde4de80befcd8d59f29bbc languageName: node linkType: hard