From 28d75acc5d647dec2e978387cda9be6a261ed00d Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 13 Sep 2023 08:44:25 +0200 Subject: [PATCH 01/25] =?UTF-8?q?Sl=C3=A5r=20av=20skrivetilgang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5bc2fc2e..42c48148 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,7 +59,11 @@ COPY --from=builder /app/public ./public # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +RUN chmod -w ./standalone + COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +RUN chmod -w ./.next/static + USER nextjs From e40d77ef937e55a874e8aeb1af5074bc52db09b0 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 20 Sep 2023 08:44:58 +0200 Subject: [PATCH 02/25] =?UTF-8?q?Setter=20rettigheter=20p=C3=A5=20en=20ann?= =?UTF-8?q?en=20m=C3=A5te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 42c48148..3d5016ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,11 +58,9 @@ COPY --from=builder /app/public ./public # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -RUN chmod -w ./standalone +COPY --from=builder --chown=nextjs:nodejs --chmod=644 /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static -RUN chmod -w ./.next/static +COPY --from=builder --chown=nextjs:nodejs --chmod=644 /app/.next/static ./.next/static USER nextjs From 963fd2062f996322047891f9c252a5f5d5849ea1 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 13 Sep 2023 12:06:25 +0200 Subject: [PATCH 03/25] Sonar fikser (#261) --- .../EndringAarsakVisning.tsx | 16 ++++++++-------- .../RefusjonUtbetalingEndring.tsx | 5 ++++- state/useKvitteringInit.ts | 2 -- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/EndringAarsakVisning/EndringAarsakVisning.tsx b/components/EndringAarsakVisning/EndringAarsakVisning.tsx index 221fcb73..c3aba7c4 100644 --- a/components/EndringAarsakVisning/EndringAarsakVisning.tsx +++ b/components/EndringAarsakVisning/EndringAarsakVisning.tsx @@ -32,8 +32,8 @@ export default function EndringAarsakVisning(props: EndringAarsakVisningProps) {
{props.ferie.map((periode, index) => ( ))}{' '} @@ -53,8 +53,8 @@ export default function EndringAarsakVisning(props: EndringAarsakVisningProps) {
{props.permisjon.map((periode, index) => ( ))}{' '} @@ -66,8 +66,8 @@ export default function EndringAarsakVisning(props: EndringAarsakVisningProps) {
{props.permittering.map((periode, index) => ( ))}{' '} @@ -95,8 +95,8 @@ export default function EndringAarsakVisning(props: EndringAarsakVisningProps) {
{props.sykefravaer.map((periode, index) => ( ))}{' '} diff --git a/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx b/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx index d95f15ac..c1ed8d27 100644 --- a/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx +++ b/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx @@ -101,7 +101,10 @@ export default function RefusjonUtbetalingEndring({ {harRefusjonEndring === 'Ja' && endringer.map((endring, key) => ( -
+
changeBelopHandler(event, key)} diff --git a/state/useKvitteringInit.ts b/state/useKvitteringInit.ts index 31e9cf15..cf246877 100644 --- a/state/useKvitteringInit.ts +++ b/state/useKvitteringInit.ts @@ -87,8 +87,6 @@ export default function useKvitteringInit() { const bestemmendeFravaersdag = jsonData.bestemmendeFraværsdag; if (bestemmendeFravaersdag) setBestemmendeFravaersdag(parseIsoDate(bestemmendeFravaersdag)); - const arbeidsgiverperioder = jsonData.arbeidsgiverperioder; - const beregnetInntekt = jsonData.inntekt && jsonData.inntekt.beregnetInntekt ? jsonData.inntekt.beregnetInntekt From 27e7f07e2d8cba960986e9a6a233a41df0f677f7 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 13 Sep 2023 12:54:25 +0200 Subject: [PATCH 04/25] Fix refusjon arbeidsgiverperiode (#262) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix for NaN i arbeidsgiver betaler i arbeidsgiverperioden * Lønn ut i agp * Formattering av visning * Litt testing * Kommentert kode * Tekster endret --- .../utils/ugyldigEllerNegativtTall.test.ts | 33 ++++++++ components/Bruttoinntekt/Bruttoinntekt.tsx | 79 ------------------- .../FullLonnIArbeidsgiverperioden.tsx | 2 +- .../FullLonnIArbeidsgiverperioden.test.tsx | 32 ++++++++ .../RefusjonArbeidsgiver.tsx | 6 +- cypress/e2e/endremaanedsinntekt.cy.js | 5 +- state/useBruttoinntektStore.ts | 7 +- state/useFyllInnsending.ts | 8 +- state/useRefusjonArbeidsgiverStore.ts | 14 ++-- utils/feiltekster.ts | 4 +- utils/ugyldigEllerNegativtTall.ts | 3 + utils/useValiderInntektsmelding.ts | 2 +- .../validerLonnIArbeidsgiverperioden.ts | 3 +- 13 files changed, 94 insertions(+), 104 deletions(-) create mode 100644 __tests__/utils/ugyldigEllerNegativtTall.test.ts create mode 100644 components/FullLonnIArbeidsgiverperioden/__tests__/FullLonnIArbeidsgiverperioden.test.tsx create mode 100644 utils/ugyldigEllerNegativtTall.ts diff --git a/__tests__/utils/ugyldigEllerNegativtTall.test.ts b/__tests__/utils/ugyldigEllerNegativtTall.test.ts new file mode 100644 index 00000000..c2b39389 --- /dev/null +++ b/__tests__/utils/ugyldigEllerNegativtTall.test.ts @@ -0,0 +1,33 @@ +import ugyldigEllerNegativtTall from '../../utils/ugyldigEllerNegativtTall'; + +describe('ugyldigEllerNegativtTall', () => { + it('ugyldigEllerNegativtTall returns true for negative numbers', () => { + const result = ugyldigEllerNegativtTall(-1); + expect(result).toBe(true); + }); + + it('ugyldigEllerNegativtTall returns true for NaN', () => { + const result = ugyldigEllerNegativtTall(NaN); + expect(result).toBe(true); + }); + + it('ugyldigEllerNegativtTall returns true for null', () => { + const result = ugyldigEllerNegativtTall(null); + expect(result).toBe(true); + }); + + it('ugyldigEllerNegativtTall returns true for undefined', () => { + const result = ugyldigEllerNegativtTall(undefined); + expect(result).toBe(true); + }); + + it('ugyldigEllerNegativtTall returns false for positive numbers', () => { + const result = ugyldigEllerNegativtTall(1); + expect(result).toBe(false); + }); + + it('ugyldigEllerNegativtTall returns false for zero', () => { + const result = ugyldigEllerNegativtTall(0); + expect(result).toBe(false); + }); +}); diff --git a/components/Bruttoinntekt/Bruttoinntekt.tsx b/components/Bruttoinntekt/Bruttoinntekt.tsx index a7da0c25..3bc5a747 100644 --- a/components/Bruttoinntekt/Bruttoinntekt.tsx +++ b/components/Bruttoinntekt/Bruttoinntekt.tsx @@ -199,85 +199,6 @@ export default function Bruttoinntekt({ bestemmendeFravaersdag }: BruttoinntektP ); - // } else { - // return ( - // <> - // Beregnet månedslønn - // - // Beregnet månedslønn skal som hovedregel fastsettes ut fra et gjennomsnitt av den inntekten som er rapportert - // til a-ordningen i de 3 siste kalendermånedene før sykefraværet startet.{' '} - // - // Les mer om beregning av månedslønn. - // - // - // {feilHentingAvInntektsdata && feilHentingAvInntektsdata.length > 0 && ( - // - // Vi har problemer med å hente inntektsopplysninger akkurat nå. Du kan legge inn beregnet månedsinntekt selv - // eller forsøke igjen senere. - // - // )} - // - // Angi bruttoinntekt som snitt av siste tre måneders lønn. Dersom inntekten har gått opp pga. varig - - // lønnsforhøyelse, og ikke for eksempel representerer uforutsett overtid kan dette gjøre at inntekten settes som - // - høyere enn snitt av siste tre måneder. - // - //
- // {!endringAvBelop && ( - // <> - // - // {formatCurrency(bruttoinntekt && bruttoinntekt.bruttoInntekt ? bruttoinntekt.bruttoInntekt : 0)}{' '} - // kr/måned - // - // - // - // )} - // {endringAvBelop && ( - // - // )} - //
- // Stemmer dette? - // - // Sjekk nøye at beregnet månedslønn er korrekt. Hvis den ansatte nylig har fått lønnsøkning, endring i - // arbeidstid, hatt ubetalt fri eller har andre endringer i lønn må dette korrigeres. Overtid skal ikke - // inkluderes i beregnet månedslønn. Beregningen er gjort etter{' '} - // folketrygdloven $8-28. - // - // - // ); - // } } function sjekkOmFerieMaaneder(tidligereinntekt: Array | undefined): boolean { diff --git a/components/FullLonnIArbeidsgiverperioden/FullLonnIArbeidsgiverperioden.tsx b/components/FullLonnIArbeidsgiverperioden/FullLonnIArbeidsgiverperioden.tsx index ed462ac5..77e863b9 100644 --- a/components/FullLonnIArbeidsgiverperioden/FullLonnIArbeidsgiverperioden.tsx +++ b/components/FullLonnIArbeidsgiverperioden/FullLonnIArbeidsgiverperioden.tsx @@ -21,7 +21,7 @@ export default function FullLonnIArbeidsgiverperioden({ lonnIPerioden }: FullLon
Nei
Utbetalt under arbeidsgiverperiode
-
{formatCurrency(lonnIPerioden.utbetalt)} kr
+
{lonnIPerioden.utbetalt ? formatCurrency(lonnIPerioden.utbetalt) : 0} kr
Begrunnelse for ingen eller redusert utbetaling
{formaterBegrunnelse(lonnIPerioden.begrunnelse)}
diff --git a/components/FullLonnIArbeidsgiverperioden/__tests__/FullLonnIArbeidsgiverperioden.test.tsx b/components/FullLonnIArbeidsgiverperioden/__tests__/FullLonnIArbeidsgiverperioden.test.tsx new file mode 100644 index 00000000..924dcd8c --- /dev/null +++ b/components/FullLonnIArbeidsgiverperioden/__tests__/FullLonnIArbeidsgiverperioden.test.tsx @@ -0,0 +1,32 @@ +import { render, screen } from '@testing-library/react'; +import FullLonnIArbeidsgiverperioden from '../FullLonnIArbeidsgiverperioden'; + +describe('FullLonnIArbeidsgiverperioden', () => { + it('should render nothing if lonnIPerioden is falsy', () => { + render(); + expect(screen.queryByText(/Ja|Nei/)).not.toBeInTheDocument(); + }); + + it('should render "Ja" if lonnIPerioden.status is "Ja"', () => { + render(); + expect(screen.getByText('Ja')).toBeInTheDocument(); + }); + + it('should render "Nei" and other details if lonnIPerioden.status is "Nei"', () => { + const lonnIPerioden = { + status: 'Nei', + utbetalt: 1000, + begrunnelse: 'TidligereVirksomhet' + }; + render(); + expect(screen.getByText('Nei')).toBeInTheDocument(); + expect(screen.getByText('Utbetalt under arbeidsgiverperiode')).toBeInTheDocument(); + expect(screen.getByText('Begrunnelse for ingen eller redusert utbetaling')).toBeInTheDocument(); + expect(screen.getByText(/Arbeidsgiverperioden er helt eller delvis/)).toBeInTheDocument(); + }); + + it('should render nothing if lonnIPerioden is undefined', () => { + render(); + expect(screen.queryByText(/Ja|Nei/)).not.toBeInTheDocument(); + }); +}); diff --git a/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.tsx b/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.tsx index 27da466b..771c4d0b 100644 --- a/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.tsx +++ b/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.tsx @@ -106,7 +106,11 @@ export default function RefusjonArbeidsgiver() { onChange={(event) => beloepUtbetaltUnderArbeidsgiverperioden(event.target.value)} id={'lus-uua-input'} error={visFeilmeldingsTekst('lus-uua-input')} - defaultValue={formatCurrency(fullLonnIArbeidsgiverPerioden.utbetalt)} + defaultValue={ + Number.isNaN(fullLonnIArbeidsgiverPerioden.utbetalt) + ? '' + : formatCurrency(fullLonnIArbeidsgiverPerioden.utbetalt) + } /> { cy.contains('Send').click(); - cy.findAllByText('Vennligst angi bruttoinntekt på formatet 1234,50.').should('exist'); + cy.findAllByText('Vennligst angi bruttoinntekt på formatet 1234,50').should('exist'); cy.findAllByText('Vennligst angi årsak for endringen.').should('exist'); cy.get('[data-cy="inntekt-belop-input"]').clear(); cy.get('[data-cy="inntekt-belop-input"]').type('70000'); - cy.findAllByText('Vennligst angi bruttoinntekt på formatet 1234,50.').should('have.length', 0); + cy.findAllByText('Vennligst angi bruttoinntekt på formatet 1234,50').should('have.length', 0); cy.get('[data-cy="refusjon-arbeidsgiver-belop"]') .invoke('text') @@ -60,7 +60,6 @@ describe('Utfylling og innsending av skjema', () => { cy.get('[data-cy="refusjon-arbeidsgiver-belop-input"]').should('have.value', '75000'); - // cy.get('h2').first().should('have.text', 'Kvittering - innsendt inntektsmelding'); }); }); diff --git a/state/useBruttoinntektStore.ts b/state/useBruttoinntektStore.ts index 146d41a2..af456cfc 100644 --- a/state/useBruttoinntektStore.ts +++ b/state/useBruttoinntektStore.ts @@ -10,6 +10,7 @@ import fetchInntektsdata from '../utils/fetchInntektsdata'; import environment from '../config/environment'; import roundTwoDecimals from '../utils/roundTwoDecimals'; import { FeilReportElement } from './useStateInit'; +import ugyldigEllerNegativtTall from '../utils/ugyldigEllerNegativtTall'; export const sorterInntekter = (a: HistoriskInntekt, b: HistoriskInntekt) => { if (a.maaned < b.maaned) { @@ -85,11 +86,7 @@ const useBruttoinntektStore: StateCreator= 0) { - state = slettFeilmeldingFraState(state, 'lus-input'); - } else { + state = slettFeilmeldingFraState(state, 'lus-input'); + const nBelop = stringishToNumber(beloep); + if (ugyldigEllerNegativtTall(nBelop)) { state = leggTilFeilmelding(state, 'lus-input', feiltekster.LONN_UNDER_SYKEFRAVAERET_BELOP); } return state; @@ -122,9 +123,8 @@ const useRefusjonArbeidsgiverStore: StateCreator= 0) { - state = slettFeilmeldingFraState(state, 'lus-uua-input'); - } else { + state = slettFeilmeldingFraState(state, 'lus-uua-input'); + if (ugyldigEllerNegativtTall(nBelop)) { state = leggTilFeilmelding(state, 'lus-uua-input', feiltekster.LONN_UNDER_SYKEFRAVAERET_BELOP); } return state; @@ -196,7 +196,7 @@ const useRefusjonArbeidsgiverStore: StateCreator + setHarRefusjonEndringer: (harEndringer) => set( produce((state) => { state.harRefusjonEndringer = harEndringer; diff --git a/utils/feiltekster.ts b/utils/feiltekster.ts index 6364e1d4..87f3d53c 100644 --- a/utils/feiltekster.ts +++ b/utils/feiltekster.ts @@ -6,7 +6,7 @@ const feiltekster = { MANGLER_FRA: 'Vennligst angi fra dato.', MANGLER_TIL: 'Vennligst angi til dato.', IKKE_BEKREFTET: 'Bruttoinntekt er ikke bekreftet.', - BRUTTOINNTEKT_MANGLER: 'Vennligst angi bruttoinntekt på formatet 1234,50.', + BRUTTOINNTEKT_MANGLER: 'Vennligst angi bruttoinntekt på formatet 1234,50', LONN_I_ARBEIDSGIVERPERIODEN_MANGLER: 'Angi om arbeidsgiver betaler ut full lønn til arbeidstaker i arbeidsgiverperioden.', LONN_I_ARBEIDSGIVERPERIODEN_BEGRUNNELSE: @@ -28,7 +28,7 @@ const feiltekster = { MANGLER_TYPE: 'Angi naturalytelse.', MANGLER_BORTFALLSDATO: 'Angi dato naturalytelsen bortfaller.', MANGLER_VERDI: 'Angi verdien på naturalytelsen.', - LONN_I_ARBEIDSGIVERPERIODEN_BELOP: 'Angi beløp. Må være høyere enn eller lik 0.', + LONN_I_ARBEIDSGIVERPERIODEN_BELOP: 'Angi beløp. Må være høyere enn eller lik 0 og på formatet 1234,50', MANGLER_VALG_ENDRING_MAANEDSLONN_I_PERIODEN: 'Angi om det har vært endring i månedslønn i perioden', MANGLER_BELOP: 'Angi ny lønn', MANGLER_DATO: 'Angi dato for lønnsendring', diff --git a/utils/ugyldigEllerNegativtTall.ts b/utils/ugyldigEllerNegativtTall.ts new file mode 100644 index 00000000..6f132c88 --- /dev/null +++ b/utils/ugyldigEllerNegativtTall.ts @@ -0,0 +1,3 @@ +export default function ugyldigEllerNegativtTall(tall?: number | null) { + return tall === undefined || tall === null || tall < 0 || Number.isNaN(tall); +} diff --git a/utils/useValiderInntektsmelding.ts b/utils/useValiderInntektsmelding.ts index b5f89d2e..d4c95c0e 100644 --- a/utils/useValiderInntektsmelding.ts +++ b/utils/useValiderInntektsmelding.ts @@ -14,7 +14,7 @@ import validerPeriodeEgenmelding, { PeriodeEgenmeldingFeilkode } from '../valida import validerBekreftOpplysninger, { BekreftOpplysningerFeilkoder } from '../validators/validerBekreftOpplysninger'; import useBoundStore from '../state/useBoundStore'; import valdiderEndringAvMaanedslonn, { EndringAvMaanedslonnFeilkode } from '../validators/validerEndringAvMaanedslonn'; -import validerTelefon, { TelefonFeilkode } from 'validators/validerTelefon'; +import validerTelefon, { TelefonFeilkode } from '../validators/validerTelefon'; export interface SubmitInntektsmeldingReturnvalues { valideringOK: boolean; diff --git a/validators/validerLonnIArbeidsgiverperioden.ts b/validators/validerLonnIArbeidsgiverperioden.ts index 96955970..92fd5384 100644 --- a/validators/validerLonnIArbeidsgiverperioden.ts +++ b/validators/validerLonnIArbeidsgiverperioden.ts @@ -1,4 +1,5 @@ import { LonnIArbeidsgiverperioden } from '../state/state'; +import ugyldigEllerNegativtTall from '../utils/ugyldigEllerNegativtTall'; import { ValiderResultat } from '../utils/useValiderInntektsmelding'; export enum LonnIArbeidsgiverperiodenFeilkode { @@ -22,7 +23,7 @@ export default function validerLonnIArbeidsgiverperioden(lonnIAP?: LonnIArbeidsg felt: 'lia-select' }); } - if (lonnIAP.status === 'Nei' && (typeof lonnIAP.utbetalt === 'undefined' || lonnIAP.utbetalt < 0)) { + if (lonnIAP.status === 'Nei' && ugyldigEllerNegativtTall(lonnIAP.utbetalt)) { errorStatus.push({ code: LonnIArbeidsgiverperiodenFeilkode.LONN_I_ARBEIDSGIVERPERIODEN_BELOP, felt: 'lus-uua-input' From 049231728bef7819ef74f49a9abe03dd581b63ed Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 13 Sep 2023 14:32:08 +0200 Subject: [PATCH 05/25] Tillater ikke negative tall (#263) --- .../RefusjonArbeidsgiver/RefusjonArbeidsgiver.module.css | 4 ++++ components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx | 1 + utils/feiltekster.ts | 2 +- validators/validerEndringAvMaanedslonn.ts | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.module.css b/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.module.css index 45baa369..13b54612 100644 --- a/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.module.css +++ b/components/RefusjonArbeidsgiver/RefusjonArbeidsgiver.module.css @@ -44,6 +44,10 @@ margin-top: 1.5rem; } +.endringsboks { + max-width: 12rem; +} + @media screen and (max-width: 500px) { .belopswrapper, .belopperiode, diff --git a/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx b/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx index c1ed8d27..923e9d11 100644 --- a/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx +++ b/components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring.tsx @@ -111,6 +111,7 @@ export default function RefusjonUtbetalingEndring({ defaultValue={endring.belop} id={`lus-utbetaling-endring-belop-${key}`} error={visFeilmeldingsTekst(`lus-utbetaling-endring-belop-${key}`)} + className={lokalStyles.endringsboks} /> { - if (!endring.belop) { + if (!endring.belop || ugyldigEllerNegativtTall(endring.belop)) { feilmeldinger.push({ felt: `lus-utbetaling-endring-belop-${index}`, code: EndringAvMaanedslonnFeilkode.MANGLER_BELOP From 1aede0d9962974d24d4e2f070a80675c2aaf5b3e Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 13 Sep 2023 14:31:35 +0200 Subject: [PATCH 06/25] Riktige mockdata --- mockdata/trenger-delvis.json | 48 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/mockdata/trenger-delvis.json b/mockdata/trenger-delvis.json index b4ea7c4e..55e85906 100644 --- a/mockdata/trenger-delvis.json +++ b/mockdata/trenger-delvis.json @@ -1,60 +1,38 @@ { - "navn": "LEKKER SKOGFIOL", + "navn": "ULTRAFIOLETT DAMESYKKEL", "orgNavn": "ANSTENDIG PIGGSVIN BARNEHAGE", - "identitetsnummer": "16507927681", + "innsenderNavn": "Muskuløs Vals", + "identitetsnummer": "10486535275", "orgnrUnderenhet": "810007842", "fravaersperioder": [ - { - "fom": "2023-01-02", - "tom": "2023-01-20" - }, - { - "fom": "2023-01-24", - "tom": "2023-01-29" - } + { "fom": "2023-01-02", "tom": "2023-01-20" }, + { "fom": "2023-01-24", "tom": "2023-01-29" } ], "egenmeldingsperioder": [], - "bruttoinntekt": 45000, + "bruttoinntekt": 45000.0, "tidligereinntekter": [ - { - "maaned": "2022-11", - "inntekt": 45000 - }, - { - "maaned": "2022-10", - "inntekt": 45000 - }, - { - "maaned": "2022-12", - "inntekt": 45000 - } + { "maaned": "2022-11", "inntekt": 45000.0 }, + { "maaned": "2022-10", "inntekt": 45000.0 }, + { "maaned": "2022-12", "inntekt": 45000.0 } ], "behandlingsperiode": null, "behandlingsdager": [], "forespurtData": { - "arbeidsgiverperiode": { - "paakrevd": false - }, + "arbeidsgiverperiode": { "paakrevd": false }, "inntekt": { "paakrevd": true, "forslag": { "type": "ForslagInntektGrunnlag", "beregningsmaaneder": ["2022-10", "2022-11", "2022-12"], - "forrigeInntekt": { - "skjæringstidspunkt": "2023-01-02", - "kilde": "INNTEKTSMELDING", - "beløp": 46000 - } + "forrigeInntekt": { "skjæringstidspunkt": "2023-01-02", "kilde": "INNTEKTSMELDING", "beløp": 46000.0 } } }, "refusjon": { "paakrevd": true, "forslag": { "perioder": [ - { - "fom": "2023-01-02", - "beloep": 0 - } + { "fom": "2023-01-02", "beloep": 46000.0 }, + { "fom": "2023-09-30", "beloep": 0.0 } ], "opphoersdato": null } From b908e625a9229265880b22110adac425dad8af9c Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 13 Sep 2023 14:59:05 +0200 Subject: [PATCH 07/25] Bruker ny parserIso --- utils/parseIsoDate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/parseIsoDate.ts b/utils/parseIsoDate.ts index 251a36d0..41b5c659 100644 --- a/utils/parseIsoDate.ts +++ b/utils/parseIsoDate.ts @@ -1,5 +1,5 @@ -import { parse } from 'date-fns'; +import { parseISO } from 'date-fns'; export default function parseIsoDate(isoDateString: string): Date { - return parse(isoDateString, 'yyyy-MM-dd', new Date()); + return parseISO(isoDateString); } From 701859e0212491cdc7c6e60b7a9790461050b5b6 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Thu, 14 Sep 2023 08:14:43 +0200 Subject: [PATCH 08/25] v0.2.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 982ba81f..6e8a076f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spinntektsmelding-frontend", - "version": "0.2.7", + "version": "0.2.8", "private": true, "scripts": { "dev": "next dev | pino-pretty", From 10cb7fb77ebb8651769d18634e67640fb402fab8 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Fri, 15 Sep 2023 11:00:22 +0200 Subject: [PATCH 09/25] Sonar (#264) * Sonar klager * Tester og utils * Test som feiler --- __tests__/components/Aarsaksvelger.test.tsx | 259 ++++++++++++++++++ __tests__/utils/formatTime.test.ts | 16 ++ __tests__/utils/logEvent.test.ts | 79 ++++++ __tests__/utils/numberOfDaysInRanges.test.ts | 8 + .../valdiderEndringAvMaanedslonn.test.ts | 18 ++ .../Arbeidsgiverperiode.tsx | 3 +- components/Bruttoinntekt/Bruttoinntekt.tsx | 3 +- components/Egenmelding/Egenmelding.tsx | 3 +- pages/endring/[slug].tsx | 6 +- utils/logEvent.ts | 37 +++ utils/ugyldigEllerNegativtTall.ts | 2 +- utils/useAmplitude.ts | 44 --- utils/useSendInnSkjema.ts | 7 +- validators/validerBehandlingsdager.ts | 2 +- validators/validerEndringAvMaanedslonn.ts | 2 + 15 files changed, 430 insertions(+), 59 deletions(-) create mode 100644 __tests__/components/Aarsaksvelger.test.tsx create mode 100644 __tests__/utils/formatTime.test.ts create mode 100644 __tests__/utils/logEvent.test.ts create mode 100644 utils/logEvent.ts delete mode 100644 utils/useAmplitude.ts diff --git a/__tests__/components/Aarsaksvelger.test.tsx b/__tests__/components/Aarsaksvelger.test.tsx new file mode 100644 index 00000000..4d8aee3d --- /dev/null +++ b/__tests__/components/Aarsaksvelger.test.tsx @@ -0,0 +1,259 @@ +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import Aarsaksvelger from '../../components/Bruttoinntekt/Aarsaksvelger'; +import { vi } from 'vitest'; +import parseIsoDate from '../../utils/parseIsoDate'; + +// Mock the ResizeObserver +const ResizeObserverMock = vi.fn(() => ({ + observe: vi.fn(), + unobserve: vi.fn(), + disconnect: vi.fn() +})); + +// Stub the global ResizeObserver +vi.stubGlobal('ResizeObserver', ResizeObserverMock); + +const IntersectionObserverMock = vi.fn(() => ({ + disconnect: vi.fn(), + observe: vi.fn(), + takeRecords: vi.fn(), + unobserve: vi.fn() +})); + +vi.stubGlobal('IntersectionObserver', IntersectionObserverMock); +vi.stubGlobal('ResizeObserver', IntersectionObserverMock); + +describe('Aarsaksvelger', () => { + const changeMaanedsintektHandler = vi.fn(); + const changeBegrunnelseHandler = vi.fn(); + const clickTilbakestillMaanedsinntekt = vi.fn(); + const setTariffEndringsdato = vi.fn(); + const setTariffKjentdato = vi.fn(); + const visFeilmeldingsTekst = vi.fn(); + + it('renders the component', () => { + render( + + ); + expect(screen.getByLabelText('Månedsinntekt')).toBeInTheDocument(); + expect( + screen.getByRole('button', { + name: /Tilbakestill/i + }) + ).toBeInTheDocument(); + }); + + it('calls the changeMaanedsintektHandler function when the input value changes', async () => { + render( + + ); + const user = userEvent.setup(); + const input = screen.getByLabelText(/edsinntekt/); + await user.type(input, '20000'); + expect(changeMaanedsintektHandler).toHaveBeenCalledTimes(5); + }); + + it('calls the changeBegrunnelseHandler function when the select value changes', async () => { + render( + + ); + const user = userEvent.setup(); + + const select = screen.getByLabelText('Velg endringsårsak'); + await user.selectOptions(select, 'Bonus'); + expect(changeBegrunnelseHandler).toHaveBeenCalledTimes(1); + expect(changeBegrunnelseHandler).toHaveBeenCalledWith('Bonus'); + }); + + it('calls the clickTilbakestillMaanedsinntekt function when the button is clicked', () => { + render( + + ); + const button = screen.getByRole('button', { + name: /Tilbakestill/i + }); + button.click(); + expect(clickTilbakestillMaanedsinntekt).toHaveBeenCalledTimes(1); + }); + + it('calls the changeBegrunnelseHandler function when the Varig lønnsendring is selected', async () => { + render( + + ); + + const user = userEvent.setup(); + const select = screen.getByLabelText('Velg endringsårsak'); + + await user.selectOptions(select, 'Varig lønnsendring'); + + expect(changeBegrunnelseHandler).toHaveBeenCalledWith('VarigLonnsendring'); + }); + + it('calls the setTariffKjentdato function when the TariffendringDato component is used', async () => { + render( + + ); + + const user = userEvent.setup(); + + await waitFor(() => screen.getByLabelText('Dato tariffendring ble kjent')); + const input = screen.getByLabelText('Dato tariffendring ble kjent'); + userEvent.clear(input); + userEvent.type(input, '2022-01-01'); + expect(setTariffKjentdato).toHaveBeenCalledTimes(1); + + const inputGjelderFra = screen.getByLabelText('Tariffendring gjelder fra'); + userEvent.clear(inputGjelderFra); + userEvent.type(inputGjelderFra, '2022-01-01'); + expect(setTariffEndringsdato).toHaveBeenCalledTimes(1); + }); + + it.skip('calls the setFeriePeriode function when the endringsaarsak is ferie', async () => { + const setFeriePeriode = vi.fn(); + + render( + + ); + + const user = userEvent.setup(); + + const input = screen.getByLabelText('Fra'); + await user.clear(input); + await user.type(input, '02.02.2022'); + expect(setFeriePeriode).toHaveBeenCalledWith([ + { + fom: parseIsoDate('2022-02-02'), + id: '1', + tom: undefined + } + ]); + }); +}); diff --git a/__tests__/utils/formatTime.test.ts b/__tests__/utils/formatTime.test.ts new file mode 100644 index 00000000..b3567e7c --- /dev/null +++ b/__tests__/utils/formatTime.test.ts @@ -0,0 +1,16 @@ +import formatTime from '../../utils/formatTime'; +import timezone_mock from 'timezone-mock'; + +timezone_mock.register('UTC'); + +describe('formatTime', () => { + it('formats a date correctly', () => { + const date = new Date('2022-01-01T12:34:56Z'); + expect(formatTime(date)).toEqual('12:34'); + }); + + it('formats a date with leading zeros correctly', () => { + const date = new Date('2022-01-01T09:08:07Z'); + expect(formatTime(date)).toEqual('09:08'); + }); +}); diff --git a/__tests__/utils/logEvent.test.ts b/__tests__/utils/logEvent.test.ts new file mode 100644 index 00000000..bbd79af1 --- /dev/null +++ b/__tests__/utils/logEvent.test.ts @@ -0,0 +1,79 @@ +import { vi } from 'vitest'; +import logEvent from '../../utils/logEvent'; +import env from '../../config/environment'; + +const mockLogAmplitudeEvent = vi.hoisted(() => { + return vi.fn(); +}); + +const mockLoggerWarn = vi.hoisted(() => { + return vi.fn(); +}); + +const mockWindow = { + location: { + href: 'http://localhost:3000' + } +}; + +const mockEventName = 'knapp klikket'; +const mockEventData = { + buttonName: 'Lagre', + formName: 'Opprett bruker' +}; + +vi.mock('@navikt/nav-dekoratoren-moduler', () => ({ + logAmplitudeEvent: mockLogAmplitudeEvent, + default: vi.fn() +})); +vi.mock('@navikt/next-logger', () => ({ + logger: { + warn: mockLoggerWarn + } +})); +vi.spyOn(global, 'window', 'get').mockImplementation(() => mockWindow); + +const envSpy = vi.spyOn(env, 'amplitudeEnabled', 'get').mockImplementation(() => true); + +const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); + +describe.skip('logEvent', () => { + beforeEach(() => { + consoleSpy.mockClear(); + mockLogAmplitudeEvent.mockClear(); + mockLoggerWarn.mockClear(); + envSpy.mockClear(); + }); + + it('should log event data to Amplitude if amplitudeEnabled is true', () => { + logEvent(mockEventName, mockEventData); + expect(consoleSpy).not.toHaveBeenCalled(); + expect(mockLoggerWarn).not.toHaveBeenCalled(); + expect(mockLogAmplitudeEvent).toHaveBeenCalledWith({ + origin: 'spinntektsmelding-frontend', + eventName: mockEventName, + eventData: mockEventData + }); + }); + + it('should log event data to console if amplitudeEnabled is false', () => { + // const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); + + logEvent(mockEventName, mockEventData); + + expect(mockLogAmplitudeEvent).not.toHaveBeenCalled(); + expect(mockLoggerWarn).not.toHaveBeenCalled(); + expect(consoleSpy).toHaveBeenCalledWith( + `Logger ${mockEventName} - Event properties: ${JSON.stringify(mockEventData)}!` + ); + + consoleSpy.mockRestore(); + }); + + it('should not log event data if window is undefined', () => { + logEvent(mockEventName, mockEventData); + + expect(mockLogAmplitudeEvent).not.toHaveBeenCalled(); + expect(mockLoggerWarn).not.toHaveBeenCalled(); + }); +}); diff --git a/__tests__/utils/numberOfDaysInRanges.test.ts b/__tests__/utils/numberOfDaysInRanges.test.ts index bc88ea51..6b0eac9b 100644 --- a/__tests__/utils/numberOfDaysInRanges.test.ts +++ b/__tests__/utils/numberOfDaysInRanges.test.ts @@ -46,4 +46,12 @@ describe.concurrent('numberOfDaysInRange', () => { ]) ).toBe(12); }); + + it('should return 0 when we have no periods in FravaaersPeriode', () => { + expect(numberOfDaysInRanges([])).toBe(0); + }); + + it('should return 0 when we have undefined periods in FravaaersPeriode', () => { + expect(numberOfDaysInRanges([undefined])).toBe(0); + }); }); diff --git a/__tests__/validators/valdiderEndringAvMaanedslonn.test.ts b/__tests__/validators/valdiderEndringAvMaanedslonn.test.ts index c2626ff5..f3d0aafb 100644 --- a/__tests__/validators/valdiderEndringAvMaanedslonn.test.ts +++ b/__tests__/validators/valdiderEndringAvMaanedslonn.test.ts @@ -32,4 +32,22 @@ describe.concurrent('valdiderEndringAvMaanedslonn', () => { } ]); }); + + it('should return error when harRefusjonEndringer is Ja and belop is negative', () => { + expect(valdiderEndringAvMaanedslonn('Ja', [{ belop: -1, dato: new Date() }])).toEqual([ + { + code: 'MANGLER_BELOP', + felt: 'lus-utbetaling-endring-belop-0' + } + ]); + }); + + it('should return error when harRefusjonEndringer is Ja and belop is a string', () => { + expect(valdiderEndringAvMaanedslonn('Ja', [{ belop: 'string', dato: new Date() }])).toEqual([ + { + code: 'MANGLER_BELOP', + felt: 'lus-utbetaling-endring-belop-0' + } + ]); + }); }); diff --git a/components/Arbeidsgiverperiode/Arbeidsgiverperiode.tsx b/components/Arbeidsgiverperiode/Arbeidsgiverperiode.tsx index 20e87581..7270fb9b 100644 --- a/components/Arbeidsgiverperiode/Arbeidsgiverperiode.tsx +++ b/components/Arbeidsgiverperiode/Arbeidsgiverperiode.tsx @@ -13,7 +13,7 @@ import ButtonTilbakestill from '../ButtonTilbakestill/ButtonTilbakestill'; import LenkeEksternt from '../LenkeEksternt/LenkeEksternt'; import { useEffect, useState } from 'react'; import LesMer from '../LesMer'; -import useAmplitude from '../../utils/useAmplitude'; +import logEvent from '../../utils/logEvent'; import { differenceInCalendarDays } from 'date-fns'; interface ArbeidsgiverperiodeProps { @@ -31,7 +31,6 @@ export default function Arbeidsgiverperiode({ arbeidsgiverperioder }: Arbeidsgiv const tilbakestillArbeidsgiverperiode = useBoundStore((state) => state.tilbakestillArbeidsgiverperiode); const slettAlleArbeidsgiverperioder = useBoundStore((state) => state.slettAlleArbeidsgiverperioder); const inngangFraKvittering = useBoundStore((state) => state.inngangFraKvittering); - const logEvent = useAmplitude(); const amplitudeComponent = 'Arbeidsgiverperiode'; const [arbeidsgiverperiodeDisabled, setArbeidsgiverperiodeDisabled] = useState(false); diff --git a/components/Bruttoinntekt/Bruttoinntekt.tsx b/components/Bruttoinntekt/Bruttoinntekt.tsx index 3bc5a747..0eb82b60 100644 --- a/components/Bruttoinntekt/Bruttoinntekt.tsx +++ b/components/Bruttoinntekt/Bruttoinntekt.tsx @@ -11,7 +11,7 @@ import ButtonEndre from '../ButtonEndre'; import formatDate from '../../utils/formatDate'; import LenkeEksternt from '../LenkeEksternt/LenkeEksternt'; import LesMer from '../LesMer'; -import useAmplitude from '../../utils/useAmplitude'; +import logEvent from '../../utils/logEvent'; import Aarsaksvelger from './Aarsaksvelger'; interface BruttoinntektProps { @@ -48,7 +48,6 @@ export default function Bruttoinntekt({ bestemmendeFravaersdag }: BruttoinntektP const henterData = useBoundStore((state) => state.henterData); const feilHentingAvInntektsdata = useBoundStore((state) => state.feilHentingAvInntektsdata); - const logEvent = useAmplitude(); const amplitudeComponent = 'BeregnetMånedslønn'; const clickTilbakestillMaanedsinntekt = (event: React.MouseEvent) => { diff --git a/components/Egenmelding/Egenmelding.tsx b/components/Egenmelding/Egenmelding.tsx index b19575ab..9eecea95 100644 --- a/components/Egenmelding/Egenmelding.tsx +++ b/components/Egenmelding/Egenmelding.tsx @@ -7,7 +7,7 @@ import EgenmeldingPeriode from './EgenmeldingPeriode'; import ButtonEndre from '../ButtonEndre'; import { useMemo } from 'react'; import Feilmelding from '../Feilmelding'; -import useAmplitude from '../../utils/useAmplitude'; +import logEvent from '../../utils/logEvent'; import { subDays } from 'date-fns'; import ButtonTilbakestill from '../ButtonTilbakestill'; @@ -37,7 +37,6 @@ export default function Egenmelding() { const tilbakestillEgenmelding = useBoundStore((state) => state.tilbakestillEgenmelding); const visFeilmeldingsTekst = useBoundStore((state) => state.visFeilmeldingsTekst); const visFeilmelding = useBoundStore((state) => state.visFeilmelding); - const logEvent = useAmplitude(); const clickSlettEgenmeldingsperiode = (periode: string) => { logEvent('knapp klikket', { diff --git a/pages/endring/[slug].tsx b/pages/endring/[slug].tsx index 943e0963..1fcfb50a 100644 --- a/pages/endring/[slug].tsx +++ b/pages/endring/[slug].tsx @@ -21,7 +21,7 @@ import RefusjonArbeidsgiverBelop from '../../components/RefusjonArbeidsgiver/Ref import { YesNo } from '../../state/state'; import { useRouter } from 'next/router'; import useHentKvitteringsdata from '../../utils/useHentKvitteringsdata'; -import useAmplitude from '../../utils/useAmplitude'; +import logEvent from '../../utils/logEvent'; import environment from '../../config/environment'; import RefusjonUtbetalingEndring from '../../components/RefusjonArbeidsgiver/RefusjonUtbetalingEndring'; import IngenTilgang from '../../components/IngenTilgang'; @@ -31,7 +31,7 @@ import parseIsoDate from '../../utils/parseIsoDate'; import Aarsaksvelger from '../../components/Bruttoinntekt/Aarsaksvelger'; import TextLabel from '../../components/TextLabel'; import ButtonEndre from '../../components/ButtonEndre'; -import useSendInnSkjema from 'utils/useSendInnSkjema'; +import useSendInnSkjema from '../../utils/useSendInnSkjema'; const Endring: NextPage = () => { const [endringBruttolonn, setEndringBruttolonn] = useBoundStore((state) => [ @@ -81,7 +81,7 @@ const Endring: NextPage = () => { const skjemaFeilet = useBoundStore((state) => state.skjemaFeilet); const gammeltSkjaeringstidspunkt = useBoundStore((state) => state.gammeltSkjaeringstidspunkt); const router = useRouter(); - const logEvent = useAmplitude(); + const refusjonEndringer = useBoundStore((state) => state.refusjonEndringer); const harRefusjonEndringer = useBoundStore((state) => state.harRefusjonEndringer); const fastsattInntekt = useBoundStore((state) => state.fastsattInntekt); diff --git a/utils/logEvent.ts b/utils/logEvent.ts new file mode 100644 index 00000000..3366d5cd --- /dev/null +++ b/utils/logEvent.ts @@ -0,0 +1,37 @@ +import { logAmplitudeEvent } from '@navikt/nav-dekoratoren-moduler'; +import { logger } from '@navikt/next-logger'; + +import env from '../config/environment'; + +type validEventNames = + | 'readmore lukket' + | 'readmore åpnet' + | 'navigere' + | 'alert vist' + | 'guidepanel vist' + | 'accordion åpnet' + | 'accordion lukket' + | 'knapp klikket' + | 'skjema åpnet' + | 'skjema fullført' + | 'skjema spørsmål besvart' + | 'skjema innsending feilet' + | 'skjema validering feilet' + | 'modal åpnet' + | 'modal lukket' + | 'filtervalg'; //Bruk kun navn fra taksonomien + +export default function logEvent(eventName: validEventNames, eventData: Record) { + if (window) { + if (env.amplitudeEnabled) { + logAmplitudeEvent({ + origin: 'spinntektsmelding-frontend', + eventName, + eventData + }).catch((e) => logger.warn(`Feil ved amplitude logging`, e)); + } else { + // eslint-disable-next-line no-console + console.log(`Logger ${eventName} - Event properties: ${JSON.stringify(eventData)}!`); + } + } +} diff --git a/utils/ugyldigEllerNegativtTall.ts b/utils/ugyldigEllerNegativtTall.ts index 6f132c88..c7ff6a85 100644 --- a/utils/ugyldigEllerNegativtTall.ts +++ b/utils/ugyldigEllerNegativtTall.ts @@ -1,3 +1,3 @@ export default function ugyldigEllerNegativtTall(tall?: number | null) { - return tall === undefined || tall === null || tall < 0 || Number.isNaN(tall); + return tall === undefined || tall === null || tall < 0 || Number.isNaN(tall) || typeof tall !== 'number'; } diff --git a/utils/useAmplitude.ts b/utils/useAmplitude.ts deleted file mode 100644 index 592bbef3..00000000 --- a/utils/useAmplitude.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { logAmplitudeEvent } from '@navikt/nav-dekoratoren-moduler'; -import { logger } from '@navikt/next-logger'; - -import env from '../config/environment'; -import useBoundStore from '../state/useBoundStore'; - -type validEventNames = - | 'readmore lukket' - | 'readmore åpnet' - | 'navigere' - | 'alert vist' - | 'guidepanel vist' - | 'accordion åpnet' - | 'accordion lukket' - | 'knapp klikket' - | 'skjema åpnet' - | 'skjema fullført' - | 'skjema spørsmål besvart' - | 'skjema innsending feilet' - | 'skjema validering feilet' - | 'modal åpnet' - | 'modal lukket' - | 'filtervalg'; //Bruk kun navn fra taksonomien - -export default function useAmplitude() { - const tracker = useBoundStore((state) => state.tracker); - - return (eventName: validEventNames, eventData: Record) => { - eventData['tracker'] = tracker; - - if (window) { - if (env.amplitudeEnabled) { - logAmplitudeEvent({ - origin: 'spinntektsmelding-frontend', - eventName, - eventData - }).catch((e) => logger.warn(`Feil ved amplitude logging`, e)); - } else { - // eslint-disable-next-line no-console - console.log(`Logger ${eventName} - Event properties: ${JSON.stringify(eventData)}!`); - } - } - }; -} diff --git a/utils/useSendInnSkjema.ts b/utils/useSendInnSkjema.ts index 3de991e8..f34c982b 100644 --- a/utils/useSendInnSkjema.ts +++ b/utils/useSendInnSkjema.ts @@ -1,5 +1,5 @@ -import useBoundStore from 'state/useBoundStore'; -import useAmplitude from './useAmplitude'; +import useBoundStore from '../state/useBoundStore'; +import logEvent from './logEvent'; import useValiderInntektsmelding from './useValiderInntektsmelding'; import useFyllInnsending, { InnsendingSkjema } from '../state/useFyllInnsending'; import isValidUUID from './isValidUUID'; @@ -7,8 +7,7 @@ import environment from '../config/environment'; import useErrorRespons, { ErrorResponse } from './useErrorResponse'; import { useRouter } from 'next/router'; -export default function useSendInnSkjema(innsendingFeiletIngenTilgang) { - const logEvent = useAmplitude(); +export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: boolean) => void) { const validerInntektsmelding = useValiderInntektsmelding(); const fyllFeilmeldinger = useBoundStore((state) => state.fyllFeilmeldinger); const fyllInnsending = useFyllInnsending(); diff --git a/validators/validerBehandlingsdager.ts b/validators/validerBehandlingsdager.ts index 4ca051e4..c31a5b11 100644 --- a/validators/validerBehandlingsdager.ts +++ b/validators/validerBehandlingsdager.ts @@ -15,7 +15,7 @@ export default function validerBehandlingsdager(dager: Array): valideringB return valideringBehandlingsdager.FLER_ENN_EN_I_UKEN; } - const sortedDays = [...dager].sort(); + const sortedDays = [...dager].sort((a, b) => b.getTime() - a.getTime()); for (let i = 0; i < sortedDays.length; i++) { if (differenceInCalendarDays(sortedDays[i], sortedDays[i + 1]) > 15) { diff --git a/validators/validerEndringAvMaanedslonn.ts b/validators/validerEndringAvMaanedslonn.ts index 9ba06107..8803a12b 100644 --- a/validators/validerEndringAvMaanedslonn.ts +++ b/validators/validerEndringAvMaanedslonn.ts @@ -34,6 +34,8 @@ export default function valdiderEndringAvMaanedslonn( }); } + console.log('endring.belop', endring.belop, ugyldigEllerNegativtTall(endring.belop)); + if (!endring.dato) { feilmeldinger.push({ felt: `lus-utbetaling-endring-dato-${index}`, From 9ee3990a95d04c7bb2b9217bd51f171bd8811319 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Mon, 18 Sep 2023 15:38:41 +0200 Subject: [PATCH 10/25] logger litt anderledes (#265) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * logger litt anderledes * Logger error objektet * Logger innsending også * Await henting av data --- pages/[slug].tsx | 3 ++- state/fetchInntektskjemaForNotifikasjon.ts | 4 ++-- utils/useHentKvitteringsdata.ts | 8 +++++++- utils/useHentSkjemadata.ts | 10 +++++++--- utils/useSendInnSkjema.ts | 8 ++++++++ 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/pages/[slug].tsx b/pages/[slug].tsx index a7d9d395..9701031d 100644 --- a/pages/[slug].tsx +++ b/pages/[slug].tsx @@ -101,7 +101,8 @@ const Home: NextPage = () => { setTidligereInntekter(inntektSisteTreMnd.tidligereInntekter); }) .catch((error) => { - logger.warn('Feil ved henting av tidliger inntektsdata', error); + logger.warn('Feil ved henting av tidliger inntektsdata i hovedskjema', error); + logger.warn(error); }); } } diff --git a/state/fetchInntektskjemaForNotifikasjon.ts b/state/fetchInntektskjemaForNotifikasjon.ts index 392bb4c4..3fce5c46 100644 --- a/state/fetchInntektskjemaForNotifikasjon.ts +++ b/state/fetchInntektskjemaForNotifikasjon.ts @@ -24,10 +24,10 @@ const fetchInntektskjemaForNotifikasjon = async (url: string, uuid: string) => { } try { return await res.json(); - } catch (_error) { + } catch (error) { const jsonError = new NetworkError('An error occurred while decoding the data.'); // Attach extra info to the error object. - jsonError.info = await res.json(); + jsonError.info = (error as Error).message; jsonError.status = res.status; throw jsonError; } diff --git a/utils/useHentKvitteringsdata.ts b/utils/useHentKvitteringsdata.ts index 0d7da7e3..19e22e01 100644 --- a/utils/useHentKvitteringsdata.ts +++ b/utils/useHentKvitteringsdata.ts @@ -3,6 +3,7 @@ import environment from '../config/environment'; import fetchKvitteringsdata from './fetchKvitteringsdata'; import useHentSkjemadata from './useHentSkjemadata'; import useKvitteringInit from '../state/useKvitteringInit'; +import { logger } from '@navikt/next-logger'; export default function useHentKvitteringsdata() { const initState = useKvitteringInit(); @@ -32,7 +33,12 @@ export default function useHentKvitteringsdata() { } if (error.status !== 200 && pathSlug) { - hentSkjemadata(pathSlug); + try { + await hentSkjemadata(pathSlug); + } catch (error: any) { + logger.warn('Feil ved henting av skjemadata i useHentKvitteringsdata', error); + logger.warn(error); + } } } }; diff --git a/utils/useHentSkjemadata.ts b/utils/useHentSkjemadata.ts index d9aa534b..6f5d50f3 100644 --- a/utils/useHentSkjemadata.ts +++ b/utils/useHentSkjemadata.ts @@ -10,7 +10,10 @@ import { logger } from '@navikt/next-logger'; export default function useHentSkjemadata() { const initState = useStateInit(); - const leggTilFeilmelding = useBoundStore((state) => state.leggTilFeilmelding); + const [leggTilFeilmelding, slettFeilmelding] = useBoundStore((state) => [ + state.leggTilFeilmelding, + state.slettFeilmelding + ]); const setSkalViseFeilmeldinger = useBoundStore((state) => state.setSkalViseFeilmeldinger); const setSkjemaFeilet = useBoundStore((state) => state.setSkjemaFeilet); const hentPaakrevdOpplysningstyper = useBoundStore((state) => state.hentPaakrevdOpplysningstyper); @@ -46,8 +49,9 @@ export default function useHentSkjemadata() { setSkjemaFeilet(); } - logger.warn('Feil ved henting av tidliger inntektsdata', error); - + logger.warn('Feil ved henting av skjemadata i useHentSkjemadata', error); + logger.warn(error); + slettFeilmelding('ukjent'); leggTilFeilmelding('ukjent', feiltekster.SERVERFEIL_IM); setSkalViseFeilmeldinger(true); } diff --git a/utils/useSendInnSkjema.ts b/utils/useSendInnSkjema.ts index f34c982b..128a641a 100644 --- a/utils/useSendInnSkjema.ts +++ b/utils/useSendInnSkjema.ts @@ -6,6 +6,7 @@ import isValidUUID from './isValidUUID'; import environment from '../config/environment'; import useErrorRespons, { ErrorResponse } from './useErrorResponse'; import { useRouter } from 'next/router'; +import { logger } from '@navikt/next-logger'; export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: boolean) => void) { const validerInntektsmelding = useValiderInntektsmelding(); @@ -90,6 +91,9 @@ export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: component: amplitudeComponent }); + logger.error('Feil ved innsending av skjema - 500', data); + logger.error(data); + break; } @@ -102,6 +106,10 @@ export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: } ]; errorResponse(errors); + + logger.error('Feil ved innsending av skjema - 404', data); + logger.error(data); + break; } From 9e2e1978cbac3541786488e6472ea2bb691638c7 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Mon, 18 Sep 2023 15:40:54 +0200 Subject: [PATCH 11/25] v0.2.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e8a076f..6c802962 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spinntektsmelding-frontend", - "version": "0.2.8", + "version": "0.2.9", "private": true, "scripts": { "dev": "next dev | pino-pretty", From 5c7b850c2bd38c6c17b7d6c4518e64cb298eedf8 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Tue, 19 Sep 2023 13:34:23 +0200 Subject: [PATCH 12/25] Kvittering andre system (#274) * Test av visning av ny kvitteringstype * Kvittering for eksternt system * logger litt anderledes (#265) * Await henting av data * Korrekt valg av kvitteringsdata --- .../components/KvitteringAnnetSystem.test.tsx | 37 ++++ .../KvitteringAnnetSystem.module.css | 10 + .../KvitteringAnnetSystem.tsx | 38 ++++ components/KvitteringAnnetSystem/index.ts | 3 + mockdata/kvittering-ekstern.json | 29 +++ mockdata/kvittering-eksternt-system.json | 8 + mockdata/kvittering-test.json | 29 +++ mockdata/kvittering-uten-agp.json | 40 ++++ pages/api/hentKvittering/[postId].ts | 2 +- pages/kvittering/[kvittid].tsx | 207 ++++++++++-------- state/useKvitteringInit.ts | 22 +- state/useSkjemadataStore.ts | 15 ++ 12 files changed, 344 insertions(+), 96 deletions(-) create mode 100644 __tests__/components/KvitteringAnnetSystem.test.tsx create mode 100644 components/KvitteringAnnetSystem/KvitteringAnnetSystem.module.css create mode 100644 components/KvitteringAnnetSystem/KvitteringAnnetSystem.tsx create mode 100644 components/KvitteringAnnetSystem/index.ts create mode 100644 mockdata/kvittering-ekstern.json create mode 100644 mockdata/kvittering-eksternt-system.json create mode 100644 mockdata/kvittering-test.json create mode 100644 mockdata/kvittering-uten-agp.json diff --git a/__tests__/components/KvitteringAnnetSystem.test.tsx b/__tests__/components/KvitteringAnnetSystem.test.tsx new file mode 100644 index 00000000..f3de625a --- /dev/null +++ b/__tests__/components/KvitteringAnnetSystem.test.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import KvitteringAnnetSystem from '../../components/KvitteringAnnetSystem/KvitteringAnnetSystem'; + +describe('KvitteringAnnetSystem', () => { + it('should render the component with the correct props', () => { + const props = { + arkivreferanse: '123456', + lenkeTilKvittering: 'Kvittering', + lenkeTilKvitteringHref: 'https://example.com/kvittering', + eksterntSystem: 'Eksternt system', + mottattDato: '2022-01-01' + }; + + const { getByText } = render(); + + expect(getByText('Mottatt inntektsmelding')).toBeInTheDocument(); + expect(getByText('Denne inntektsmeldingen er mottatt fra et eksternt system')).toBeInTheDocument(); + expect(getByText(/Vi har mottatt denne inntektsmeldingen fra Eksternt system/)).toBeInTheDocument(); + expect(getByText(`Arkivreferanse: [${props.arkivreferanse}]`)).toBeInTheDocument(); + expect(getByText(props.lenkeTilKvittering)).toHaveAttribute('href', props.lenkeTilKvitteringHref); + }); + + it('should render the component without optional props', () => { + const props = { + eksterntSystem: 'Eksternt system' + }; + + const { getByText, queryByText } = render(); + + expect(getByText('Mottatt inntektsmelding')).toBeInTheDocument(); + expect(getByText('Denne inntektsmeldingen er mottatt fra et eksternt system')).toBeInTheDocument(); + expect(getByText(/Vi har mottatt denne inntektsmeldingen fra Eksternt system/)).toBeInTheDocument(); + expect(queryByText('Arkivreferanse:')).toBeNull(); + expect(queryByText('Eventuell lenke til kvittering')).toBeNull(); + }); +}); diff --git a/components/KvitteringAnnetSystem/KvitteringAnnetSystem.module.css b/components/KvitteringAnnetSystem/KvitteringAnnetSystem.module.css new file mode 100644 index 00000000..79fadf30 --- /dev/null +++ b/components/KvitteringAnnetSystem/KvitteringAnnetSystem.module.css @@ -0,0 +1,10 @@ +.hovedinnhold { + margin: 2rem 0; + border: 1px solid #000; + border-radius: 5px; + padding: 1.5rem; +} + +.arkivreferanse { + margin-top: 1rem; +} diff --git a/components/KvitteringAnnetSystem/KvitteringAnnetSystem.tsx b/components/KvitteringAnnetSystem/KvitteringAnnetSystem.tsx new file mode 100644 index 00000000..88af2561 --- /dev/null +++ b/components/KvitteringAnnetSystem/KvitteringAnnetSystem.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { BodyLong, BodyShort, Link } from '@navikt/ds-react'; +import Heading1 from '../Heading1/Heading1'; +import Heading2 from '../Heading2/Heading2'; +import lokalStyles from './KvitteringAnnetSystem.module.css'; + +interface KvitteringAnnetSystemProps { + arkivreferanse?: string; + lenkeTilKvittering?: string; + lenkeTilKvitteringHref?: string; + eksterntSystem: string; + mottattDato?: string; +} + +export default function KvitteringAnnetSystem(props: KvitteringAnnetSystemProps) { + return ( + <> + Mottatt inntektsmelding +
+ Denne inntektsmeldingen er mottatt fra et eksternt system + + Vi har mottatt denne inntektsmeldingen fra {props.eksterntSystem}. Hvis du vil se innsendt informasjon eller + gjøre endringer må du bruke samme system som dere sendte inn denne inntektsmeldingen med. + + + {props.arkivreferanse && ( + Arkivreferanse: [{props.arkivreferanse}] + )} + + {props.lenkeTilKvittering && ( + + {props.lenkeTilKvittering}[Eventuell lenke til kvittering] + + )} +
+ + ); +} diff --git a/components/KvitteringAnnetSystem/index.ts b/components/KvitteringAnnetSystem/index.ts new file mode 100644 index 00000000..5437b1db --- /dev/null +++ b/components/KvitteringAnnetSystem/index.ts @@ -0,0 +1,3 @@ +import KvitteringAnnetSystem from './KvitteringAnnetSystem'; + +export default KvitteringAnnetSystem; diff --git a/mockdata/kvittering-ekstern.json b/mockdata/kvittering-ekstern.json new file mode 100644 index 00000000..2d80874b --- /dev/null +++ b/mockdata/kvittering-ekstern.json @@ -0,0 +1,29 @@ +{ + "kvitteringEkstern": null, + "kvitteringDokument": { + "orgnrUnderenhet": "810007842", + "identitetsnummer": "10486535275", + "fulltNavn": "ULTRAFIOLETT DAMESYKKEL", + "telefonnummer": "+4741359019", + "innsenderNavn": "Muskuløs Vals", + "virksomhetNavn": "ANSTENDIG PIGGSVIN BARNEHAGE", + "behandlingsdager": [], + "egenmeldingsperioder": [{ "fom": "2023-01-20", "tom": "2023-01-20" }], + "arbeidsgiverperioder": [{ "fom": "2023-01-20", "tom": "2023-02-04" }], + "bestemmendeFraværsdag": "2023-01-20", + "fraværsperioder": [{ "fom": "2023-01-23", "tom": "2023-02-22" }], + "inntekt": { "bekreftet": true, "beregnetInntekt": 45000, "endringÅrsak": null, "manueltKorrigert": false }, + "fullLønnIArbeidsgiverPerioden": { "utbetalerFullLønn": false, "begrunnelse": "LovligFravaer", "utbetalt": 30000 }, + "refusjon": { + "utbetalerHeleEllerDeler": true, + "refusjonPrMnd": 45000, + "refusjonOpphører": "2023-09-29", + "refusjonEndringer": [{ "beløp": 20000, "dato": "2023-09-20" }] + }, + "naturalytelser": [{ "naturalytelse": "BIL", "dato": "2023-09-29", "beløp": 6000 }], + "årsakInnsending": "Ny", + "bekreftOpplysninger": true, + "tidspunkt": "2023-09-19T08:08:29.639368431Z", + "forespurtData": ["arbeidsgiverperiode", "inntekt", "refusjon"] + } +} diff --git a/mockdata/kvittering-eksternt-system.json b/mockdata/kvittering-eksternt-system.json new file mode 100644 index 00000000..b9846361 --- /dev/null +++ b/mockdata/kvittering-eksternt-system.json @@ -0,0 +1,8 @@ +{ + "kvitteringEkstern": { + "avsenderSystem": "AltinnPortal", + "referanse": "AR123456", + "tidspunkt": "2023-09-19T08:08:29.639368431Z" + }, + "kvitteringDokument": null +} diff --git a/mockdata/kvittering-test.json b/mockdata/kvittering-test.json new file mode 100644 index 00000000..83a47d4d --- /dev/null +++ b/mockdata/kvittering-test.json @@ -0,0 +1,29 @@ +{ + "orgnrUnderenhet": "810007842", + "identitetsnummer": "16507927681", + "fulltNavn": "LEKKER SKOGFIOL", + "telefonnummer": "12345678", + "innsenderNavn": "Muskuløs Vals", + "virksomhetNavn": "ANSTENDIG PIGGSVIN BARNEHAGE", + "behandlingsdager": [], + "egenmeldingsperioder": [{ "fom": "2022-12-27", "tom": "2022-12-29" }], + "arbeidsgiverperioder": [ + { "fom": "2022-12-27", "tom": "2022-12-29" }, + { "fom": "2023-01-02", "tom": "2023-01-14" } + ], + "bestemmendeFraværsdag": "2023-01-02", + "fraværsperioder": [{ "fom": "2023-01-02", "tom": "2023-01-20" }], + "inntekt": { "bekreftet": true, "beregnetInntekt": 45000, "endringÅrsak": null, "manueltKorrigert": false }, + "fullLønnIArbeidsgiverPerioden": { "utbetalerFullLønn": true, "begrunnelse": null, "utbetalt": null }, + "refusjon": { + "utbetalerHeleEllerDeler": false, + "refusjonPrMnd": null, + "refusjonOpphører": null, + "refusjonEndringer": null + }, + "naturalytelser": null, + "årsakInnsending": "Endring", + "bekreftOpplysninger": true, + "tidspunkt": "2023-09-06T14:42:33.341249931+02:00", + "forespurtData": ["arbeidsgiverperiode", "inntekt", "refusjon"] +} diff --git a/mockdata/kvittering-uten-agp.json b/mockdata/kvittering-uten-agp.json new file mode 100644 index 00000000..57176edc --- /dev/null +++ b/mockdata/kvittering-uten-agp.json @@ -0,0 +1,40 @@ +{ + "orgnrUnderenhet": "810007842", + "identitetsnummer": "16507927681", + "fulltNavn": "LEKKER SKOGFIOL", + "telefonnummer": "+4741359019", + "innsenderNavn": "Muskuløs Vals", + "virksomhetNavn": "ANSTENDIG PIGGSVIN BARNEHAGE", + "behandlingsdager": [], + "egenmeldingsperioder": [], + "arbeidsgiverperioder": [], + "bestemmendeFraværsdag": "2023-01-02", + "fraværsperioder": [ + { + "fom": "2023-01-02", + "tom": "2023-01-20" + } + ], + "inntekt": { + "bekreftet": true, + "beregnetInntekt": 45000, + "endringÅrsak": null, + "manueltKorrigert": false + }, + "fullLønnIArbeidsgiverPerioden": { + "utbetalerFullLønn": false, + "begrunnelse": "ManglerOpptjening", + "utbetalt": 0 + }, + "refusjon": { + "utbetalerHeleEllerDeler": false, + "refusjonPrMnd": null, + "refusjonOpphører": null, + "refusjonEndringer": null + }, + "naturalytelser": null, + "årsakInnsending": "Ny", + "bekreftOpplysninger": true, + "tidspunkt": "2023-09-11T11:01:46.793968905+02:00", + "forespurtData": ["arbeidsgiverperiode", "inntekt", "refusjon"] +} diff --git a/pages/api/hentKvittering/[postId].ts b/pages/api/hentKvittering/[postId].ts index d8548a96..6d6fe16e 100644 --- a/pages/api/hentKvittering/[postId].ts +++ b/pages/api/hentKvittering/[postId].ts @@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import httpProxyMiddleware from 'next-http-proxy-middleware'; import environment from '../../../config/environment'; -import org from '../../../mockdata/kvittering-delvis-lonn.json'; +import org from '../../../mockdata/kvittering-eksternt-system.json'; const basePath = environment.hentKvitteringAPI; diff --git a/pages/kvittering/[kvittid].tsx b/pages/kvittering/[kvittid].tsx index 1539c391..c8456e0f 100644 --- a/pages/kvittering/[kvittid].tsx +++ b/pages/kvittering/[kvittid].tsx @@ -37,6 +37,7 @@ import env from '../../config/environment'; import { Periode } from '../../state/state'; import skjemaVariant from '../../config/skjemavariant'; import classNames from 'classnames/bind'; +import KvitteringAnnetSystem from '../../components/KvitteringAnnetSystem/KvitteringAnnetSystem'; const Kvittering: NextPage = () => { const router = useRouter(); @@ -76,6 +77,7 @@ const Kvittering: NextPage = () => { const sykefravaerperioder = useBoundStore((state) => state.sykefravaerperioder); const hentPaakrevdOpplysningstyper = useBoundStore((state) => state.hentPaakrevdOpplysningstyper); const setOpprinneligNyMaanedsinntekt = useBoundStore((state) => state.setOpprinneligNyMaanedsinntekt); + const kvitteringEksterntSystem = useBoundStore((state) => state.kvitteringEksterntSystem); const clickEndre = () => { const paakrevdeOpplysningstyper = hentPaakrevdOpplysningstyper(); @@ -95,11 +97,17 @@ const Kvittering: NextPage = () => { const paakrevdeOpplysninger = hentPaakrevdOpplysningstyper(); - const innsendingstidspunkt = + let innsendingstidspunkt = kvitteringInnsendt && isValid(kvitteringInnsendt) ? ` - ${formatDate(kvitteringInnsendt)} kl. ${formatTime(kvitteringInnsendt)}` : ''; + if (kvitteringEksterntSystem?.tidspunkt) { + const tidspunkt = new Date(kvitteringEksterntSystem.tidspunkt); + innsendingstidspunkt = + tidspunkt && isValid(tidspunkt) ? ` - ${formatDate(tidspunkt)} kl. ${formatTime(tidspunkt)}` : ''; + } + const ingenArbeidsgiverperioder = !harGyldigeArbeidsgiverperioder(arbeidsgiverperioder); useEffect(() => { @@ -134,114 +142,125 @@ const Kvittering: NextPage = () => {
- - -
-
- Fraværsperiode - {harAktiveEgenmeldingsperioder() && ( -
-
- Egenmelding - {egenmeldingsperioder?.map((periode) => ( - - ))} -
-
- )} -
-
- Sykmelding - {fravaersperioder?.map((periode) => ( - - ))} -
-
-
-
-
-
- Bestemmende fraværsdag - Bestemmende fraværsdag angir den dato som sykelønn skal beregnes utfra. -
-
Dato
-
- {bestemmendeFravaersdag ? formatDate(bestemmendeFravaersdag) : }{' '} + {kvitteringEksterntSystem?.avsenderSystem && ( + + )} + {!kvitteringEksterntSystem?.avsenderSystem && ( + <> + + +
+
+ Fraværsperiode + {harAktiveEgenmeldingsperioder() && ( +
+
+ Egenmelding + {egenmeldingsperioder?.map((periode) => ( + + ))} +
+
+ )} +
+
+ Sykmelding + {fravaersperioder?.map((periode) => ( + + ))}
- {visArbeidsgiverperiode && ( -
- Arbeidsgiverperiode - {!ingenArbeidsgiverperioder && ( - - Arbeidsgiver er ansvarlig for å betale ut lønn til den sykmeldte under arbeidsgiverpeioden. - Deretter betaler Nav lønn til den syke eller refunderer bedriften. - +
+
+
+ Bestemmende fraværsdag + Bestemmende fraværsdag angir den dato som sykelønn skal beregnes utfra. +
+
Dato
+
+ {bestemmendeFravaersdag ? formatDate(bestemmendeFravaersdag) : }{' '} +
+
+
+ {visArbeidsgiverperiode && ( +
+ Arbeidsgiverperiode + {!ingenArbeidsgiverperioder && ( + + Arbeidsgiver er ansvarlig for å betale ut lønn til den sykmeldte under arbeidsgiverpeioden. + Deretter betaler Nav lønn til den syke eller refunderer bedriften. + + )} + {ingenArbeidsgiverperioder && Det er ikke arbeidsgiverperiode.} + {arbeidsgiverperioder?.map((periode) => ( + + ))} +
)} - {ingenArbeidsgiverperioder && Det er ikke arbeidsgiverperiode.} - {arbeidsgiverperioder?.map((periode) => ( - - ))}
- )} +
-
-
- - Beregnet månedslønn - Registrert inntekt - {formatCurrency(bruttoinntekt.bruttoInntekt)} kr/måned - {bruttoinntekt.endringsaarsak && ( - <> -
Endret med årsak
+ + Beregnet månedslønn + Registrert inntekt + {formatCurrency(bruttoinntekt.bruttoInntekt)} kr/måned + {bruttoinntekt.endringsaarsak && ( + <> +
Endret med årsak
- {formatBegrunnelseEndringBruttoinntekt(bruttoinntekt.endringsaarsak)} - - - )} - - Refusjon - {visFullLonnIArbeidsgiverperioden && ( - <> + {formatBegrunnelseEndringBruttoinntekt(bruttoinntekt.endringsaarsak)} + + + )} + + Refusjon + {visFullLonnIArbeidsgiverperioden && ( + <> +
+ Betaler arbeidsgiver ut full lønn til arbeidstaker i arbeidsgiverperioden? +
+ + + )}
- Betaler arbeidsgiver ut full lønn til arbeidstaker i arbeidsgiverperioden? + Betaler arbeidsgiver lønn og krever refusjon etter arbeidsgiverperioden?
- - - )} -
- Betaler arbeidsgiver lønn og krever refusjon etter arbeidsgiverperioden? -
- - {visNaturalytelser && ( - <> + + {visNaturalytelser && ( + <> + + Eventuelle naturalytelser + + + )} - Eventuelle naturalytelser - )} - Kvittering - innsendt inntektsmelding{innsendingstidspunkt}
- + {!kvitteringEksterntSystem?.avsenderSystem && } Lukk diff --git a/state/useKvitteringInit.ts b/state/useKvitteringInit.ts index cf246877..697cd8ba 100644 --- a/state/useKvitteringInit.ts +++ b/state/useKvitteringInit.ts @@ -14,6 +14,7 @@ import { Periode } from './state'; import begrunnelseEndringBruttoinntekt from '../components/Bruttoinntekt/begrunnelseEndringBruttoinntekt'; import skjemaVariant from '../config/skjemavariant'; import { nanoid } from 'nanoid'; +import { SkjemaKvitteringEksterntSystem } from './useSkjemadataStore'; export interface KvitteringSkjema extends InnsendingSkjema { fulltNavn: string; @@ -24,6 +25,11 @@ export interface KvitteringSkjema extends InnsendingSkjema { tidspunkt?: string; } +interface KvitteringInit { + kvitteringEkstern: SkjemaKvitteringEksterntSystem | null; + kvitteringDokument: KvitteringSkjema | null; +} + export default function useKvitteringInit() { const initFravaersperiode = useBoundStore((state) => state.initFravaersperiode); const initEgenmeldingsperiode = useBoundStore((state) => state.initEgenmeldingsperiode); @@ -60,8 +66,22 @@ export default function useKvitteringInit() { const setTidligereInntektsdata = useBoundStore((state) => state.setTidligereInntektsdata); const setInngangFraKvittering = useBoundStore((state) => state.setInngangFraKvittering); const setOpprinneligNyMaanedsinntekt = useBoundStore((state) => state.setOpprinneligNyMaanedsinntekt); + const setSkjemaKvitteringEksterntSystem = useBoundStore((state) => state.setSkjemaKvitteringEksterntSystem); + + return async (kvitteringsData: KvitteringInit, slug: string) => { + let jsonData: KvitteringSkjema; + + if (kvitteringsData.kvitteringEkstern && kvitteringsData.kvitteringEkstern !== null) { + setSkjemaKvitteringEksterntSystem(kvitteringsData.kvitteringEkstern); + return; + } + + if (kvitteringsData.kvitteringDokument && kvitteringsData.kvitteringDokument !== null) { + jsonData = kvitteringsData.kvitteringDokument!; + } else { + jsonData = kvitteringsData as unknown as KvitteringSkjema; + } - return async (jsonData: KvitteringSkjema, slug: string) => { initFravaersperiode(jsonData.fraværsperioder); if (jsonData.egenmeldingsperioder) initEgenmeldingsperiode(jsonData.egenmeldingsperioder); diff --git a/state/useSkjemadataStore.ts b/state/useSkjemadataStore.ts index ee82e4e4..8d9fa5b1 100644 --- a/state/useSkjemadataStore.ts +++ b/state/useSkjemadataStore.ts @@ -17,6 +17,7 @@ export interface SkjemadataState { setDirekteInngangKvittering: () => void; setEndringBruttolonn: (endring: YesNo) => void; setEndringerAvRefusjon: (endring: YesNo) => void; + setSkjemaKvitteringEksterntSystem: (eksterntSystem: SkjemaKvitteringEksterntSystem) => void; tracker: string; henterInntektsdata: boolean; slug?: string | Array; @@ -27,6 +28,13 @@ export interface SkjemadataState { direkteInngangKvittering: boolean; endringBruttolonn?: YesNo; endringerAvRefusjon?: YesNo; + kvitteringEksterntSystem?: SkjemaKvitteringEksterntSystem; +} + +export interface SkjemaKvitteringEksterntSystem { + avsenderSystem: string; + referanse: string; + tidspunkt: string; } const useSkjemadataStore: StateCreator = (set) => ({ @@ -107,6 +115,13 @@ const useSkjemadataStore: StateCreator = state.endringerAvRefusjon = endring; }) ); + }, + setSkjemaKvitteringEksterntSystem: (eksterntSystem: SkjemaKvitteringEksterntSystem) => { + set( + produce((state: SkjemadataState) => { + state.kvitteringEksterntSystem = eksterntSystem; + }) + ); } }); From 51d90501de50b12b3aa31921dacbd1fa426e4884 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:34:49 +0200 Subject: [PATCH 13/25] Bump docker/login-action from 2 to 3 (#266) Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dev.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/prod.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index e1918f74..b7fc3e47 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -81,7 +81,7 @@ jobs: # path: build # - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41acc2d8..9bb75c90 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,7 +81,7 @@ jobs: # path: build # - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 41e05cb7..6fcc8430 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -51,7 +51,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} From 674a90db03a449638489b110889a1fc0ebea737c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:35:10 +0200 Subject: [PATCH 14/25] Bump docker/setup-buildx-action from 2 to 3 (#267) Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dev.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/prod.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index b7fc3e47..48a26c9a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -68,7 +68,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 # - uses: actions/setup-node@v3 # with: # node-version: '20.x' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9bb75c90..dd1d6e67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,7 +68,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 # - uses: actions/setup-node@v3 # with: # node-version: '20.x' diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 6fcc8430..f0964dcd 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -48,7 +48,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 From 60cd9a47b75b634f40b4bbc0694f3dec9fc397e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:35:30 +0200 Subject: [PATCH 15/25] Bump @vitest/ui from 0.33.0 to 0.34.4 (#269) Bumps [@vitest/ui](https://github.com/vitest-dev/vitest/tree/HEAD/packages/ui) from 0.33.0 to 0.34.4. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v0.34.4/packages/ui) --- updated-dependencies: - dependency-name: "@vitest/ui" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6c802962..40a0cce2 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@types/testing-library__jest-dom": "6.0.0", "@vitejs/plugin-react": "4.0.4", "@vitest/coverage-v8": "0.34.3", - "@vitest/ui": "0.33.0", + "@vitest/ui": "0.34.4", "axe-core": "4.7.2", "cross-env": "7.0.3", "cypress": "13.1.0", diff --git a/yarn.lock b/yarn.lock index 8cc4fc5c..fd19450f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1408,12 +1408,12 @@ dependencies: tinyspy "^2.1.1" -"@vitest/ui@0.33.0": - version "0.33.0" - resolved "https://registry.yarnpkg.com/@vitest/ui/-/ui-0.33.0.tgz#6ee8f1149d5398f929c5dd2697fd2096ecfe9c47" - integrity sha512-7gbAjLqt30R4bodkJAutdpy4ncv+u5IKTHYTow1c2q+FOxZUC9cKOSqMUxjwaaTwLN+EnDnmXYPtg3CoahaUzQ== +"@vitest/ui@0.34.4": + version "0.34.4" + resolved "https://registry.yarnpkg.com/@vitest/ui/-/ui-0.34.4.tgz#fb4389e1347b80cbb326d790e2b5416b99992f47" + integrity sha512-gz0m0r9ErFG32r+DRdwuLJpUDpbi+jrMcw9nJZAau48Fs4LDIBg561PvczvGqyYxzbyFU7vgkSnSlSDfK0d53w== dependencies: - "@vitest/utils" "0.33.0" + "@vitest/utils" "0.34.4" fast-glob "^3.3.0" fflate "^0.8.0" flatted "^3.2.7" @@ -1430,6 +1430,15 @@ loupe "^2.3.6" pretty-format "^29.5.0" +"@vitest/utils@0.34.4": + version "0.34.4" + resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-0.34.4.tgz#0b6bf5fe07223ebb6ec24cd1edc0137cb301ecfd" + integrity sha512-yR2+5CHhp/K4ySY0Qtd+CAL9f5Yh1aXrKfAT42bq6CtlGPh92jIDDDSg7ydlRow1CP+dys4TrOrbELOyNInHSg== + dependencies: + diff-sequences "^29.4.3" + loupe "^2.3.6" + pretty-format "^29.5.0" + abab@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" From 3cdc009d213abc50fb45b98f0c2bedc9e2be8d05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:35:50 +0200 Subject: [PATCH 16/25] Bump docker/build-push-action from 4 to 5 (#268) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v4...v5) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dev.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/prod.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 48a26c9a..5ce0b4ae 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -87,7 +87,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dd1d6e67..4642bceb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,7 +87,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: true diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index f0964dcd..16a05bb1 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -57,7 +57,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: true From ef9ab457bdc40b4f9f26e9d28d12427b733cc1b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:36:09 +0200 Subject: [PATCH 17/25] Bump @types/node from 20.6.0 to 20.6.2 (#270) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.6.0 to 20.6.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 40a0cce2..cad1431d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@testing-library/react": "14.0.0", "@testing-library/user-event": "14.4.3", "@types/jest-axe": "3.5.5", - "@types/node": "^20.6.0", + "@types/node": "^20.6.2", "@types/react": "18.2.21", "@types/react-dom": "18.2.7", "@types/testing-library__jest-dom": "6.0.0", diff --git a/yarn.lock b/yarn.lock index fd19450f..eb34505c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1220,10 +1220,10 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== -"@types/node@*", "@types/node@^20.6.0": - version "20.6.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.0.tgz#9d7daa855d33d4efec8aea88cd66db1c2f0ebe16" - integrity sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg== +"@types/node@*", "@types/node@^20.6.2": + version "20.6.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.2.tgz#a065925409f59657022e9063275cd0b9bd7e1b12" + integrity sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw== "@types/node@^16.18.39": version "16.18.42" From 4bca77309740dd9d92d937e869aff92ff03fa320 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:38:57 +0200 Subject: [PATCH 18/25] Bump @grafana/faro-web-tracing from 1.1.4 to 1.2.0 (#273) Bumps [@grafana/faro-web-tracing](https://github.com/grafana/faro-web-sdk/tree/HEAD/packages/web-tracing) from 1.1.4 to 1.2.0. - [Changelog](https://github.com/grafana/faro-web-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/grafana/faro-web-sdk/commits/v1.2.0/packages/web-tracing) --- updated-dependencies: - dependency-name: "@grafana/faro-web-tracing" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 31 +++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index cad1431d..8a68a21d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ }, "dependencies": { "@grafana/faro-web-sdk": "1.1.4", - "@grafana/faro-web-tracing": "1.1.4", + "@grafana/faro-web-tracing": "1.2.0", "@navikt/aksel-icons": "5.3.1", "@navikt/bedriftsmeny": "6.10.2", "@navikt/ds-css": "5.3.1", diff --git a/yarn.lock b/yarn.lock index eb34505c..f22ad0e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -459,7 +459,17 @@ "@opentelemetry/otlp-transformer" "^0.41.2" murmurhash-js "^1.0.0" -"@grafana/faro-web-sdk@1.1.4", "@grafana/faro-web-sdk@^1.1.4": +"@grafana/faro-core@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@grafana/faro-core/-/faro-core-1.2.0.tgz#ad58f8d504c1cbe4fb57f9ede66f17115faaaa3e" + integrity sha512-ITkem5LgH39GuMRiBPXaLyG1+TCPT0iLIymFFFX+ZJTWkx6Uy0J9N9+HWy/gXPnRFb+kCRt1CNCrFZYWGt8ZxA== + dependencies: + "@opentelemetry/api" "^1.4.1" + "@opentelemetry/api-metrics" "^0.33.0" + "@opentelemetry/otlp-transformer" "^0.41.2" + murmurhash-js "^1.0.0" + +"@grafana/faro-web-sdk@1.1.4": version "1.1.4" resolved "https://registry.yarnpkg.com/@grafana/faro-web-sdk/-/faro-web-sdk-1.1.4.tgz#bf4f93e234f0dabf60b7641c795690074c0bf506" integrity sha512-eyrwi01VWkoaBZVYo3fbyakW/nN6Dhz/dYgaWHOx3Mt0pH+q8IrIAF5oNoy9QGNCsdmld/sbIL+jV6yoyojYDA== @@ -468,12 +478,21 @@ ua-parser-js "^1.0.32" web-vitals "^3.1.1" -"@grafana/faro-web-tracing@1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@grafana/faro-web-tracing/-/faro-web-tracing-1.1.4.tgz#0768527f93fd0bf3e1e2315861be3933ea6867ed" - integrity sha512-JtAfnR/vBORMnyrsrKWnlxGIB+7qZYj3envV7nSCrYaXiVCErLhb2k6feyKBIMif14kX/H/FHw4maDWo2RW4hQ== +"@grafana/faro-web-sdk@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@grafana/faro-web-sdk/-/faro-web-sdk-1.2.0.tgz#3b40b9cf8ab535214ad517ebad6f8a125426d518" + integrity sha512-fQCbEq4Gyn96K/GatpUCBP6iQyK48EBpnf/RvWoLTUmN+ac0/dn+3c+NPZULhqMBHI10cAv9ol9wsGKXj4yYzw== + dependencies: + "@grafana/faro-core" "^1.2.0" + ua-parser-js "^1.0.32" + web-vitals "^3.1.1" + +"@grafana/faro-web-tracing@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@grafana/faro-web-tracing/-/faro-web-tracing-1.2.0.tgz#7c6dc3502f6ba8338b34b1cda1e70a24bfb8e9be" + integrity sha512-+YA8nCwchMAbAkx69kF4/VNI8IspkZF+NHe5igDBb5HWkR4jD1ihiaziebIBv/2N1FYI+lMb5iyQdoTKJhMtOQ== dependencies: - "@grafana/faro-web-sdk" "^1.1.4" + "@grafana/faro-web-sdk" "^1.2.0" "@opentelemetry/api" "^1.4.1" "@opentelemetry/context-zone" "^1.15.2" "@opentelemetry/core" "^1.15.2" From 57e39a4701cf729b12bdf161edb001e971ae1132 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:42:14 +0200 Subject: [PATCH 19/25] Bump @testing-library/cypress from 9.0.0 to 10.0.1 (#271) Bumps [@testing-library/cypress](https://github.com/kentcdodds/cypress-testing-library) from 9.0.0 to 10.0.1. - [Release notes](https://github.com/kentcdodds/cypress-testing-library/releases) - [Changelog](https://github.com/testing-library/cypress-testing-library/blob/main/CHANGELOG.md) - [Commits](https://github.com/kentcdodds/cypress-testing-library/compare/v9.0.0...v10.0.1) --- updated-dependencies: - dependency-name: "@testing-library/cypress" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 24 +++++------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 8a68a21d..c4142328 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "zustand": "4.3.8" }, "devDependencies": { - "@testing-library/cypress": "9.0.0", + "@testing-library/cypress": "10.0.1", "@testing-library/jest-dom": "6.1.3", "@testing-library/react": "14.0.0", "@testing-library/user-event": "14.4.3", diff --git a/yarn.lock b/yarn.lock index f22ad0e0..778a8b52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1101,13 +1101,13 @@ dependencies: tslib "^2.4.0" -"@testing-library/cypress@9.0.0": - version "9.0.0" - resolved "https://registry.yarnpkg.com/@testing-library/cypress/-/cypress-9.0.0.tgz#3facad49c4654a99bbd138f83f33b415d2d6f097" - integrity sha512-c1XiCGeHGGTWn0LAU12sFUfoX3qfId5gcSE2yHode+vsyHDWraxDPALjVnHd4/Fa3j4KBcc5k++Ccy6A9qnkMA== +"@testing-library/cypress@10.0.1": + version "10.0.1" + resolved "https://registry.yarnpkg.com/@testing-library/cypress/-/cypress-10.0.1.tgz#15abae0edb83237316ec6d07e152b71a50b38387" + integrity sha512-e8uswjTZIBhaIXjzEcrQQ8nHRWHgZH7XBxKuIWxZ/T7FxfWhCR48nFhUX5nfPizjVOKSThEfOSv67jquc1ASkw== dependencies: "@babel/runtime" "^7.14.6" - "@testing-library/dom" "^8.1.0" + "@testing-library/dom" "^9.0.0" "@testing-library/dom@9.3.1", "@testing-library/dom@^9.0.0": version "9.3.1" @@ -1123,20 +1123,6 @@ lz-string "^1.5.0" pretty-format "^27.0.2" -"@testing-library/dom@^8.1.0": - version "8.20.1" - resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.20.1.tgz#2e52a32e46fc88369eef7eef634ac2a192decd9f" - integrity sha512-/DiOQ5xBxgdYRC8LNk7U+RWat0S3qRLeIw3ZIkMQ9kkVlRmwD/Eg8k8CqIpD6GW7u20JIUOfMKbxtiLutpjQ4g== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/runtime" "^7.12.5" - "@types/aria-query" "^5.0.1" - aria-query "5.1.3" - chalk "^4.1.0" - dom-accessibility-api "^0.5.9" - lz-string "^1.5.0" - pretty-format "^27.0.2" - "@testing-library/jest-dom@*", "@testing-library/jest-dom@6.1.3": version "6.1.3" resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.1.3.tgz#443118c9e4043f96396f120de2c7122504a079c5" From 5a8c59b093434d6f687892002bf66953b1ccc42d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:42:31 +0200 Subject: [PATCH 20/25] Bump @testing-library/user-event from 14.4.3 to 14.5.1 (#272) Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.4.3 to 14.5.1. - [Release notes](https://github.com/testing-library/user-event/releases) - [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md) - [Commits](https://github.com/testing-library/user-event/compare/v14.4.3...v14.5.1) --- updated-dependencies: - dependency-name: "@testing-library/user-event" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c4142328..42ad21e2 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@testing-library/cypress": "10.0.1", "@testing-library/jest-dom": "6.1.3", "@testing-library/react": "14.0.0", - "@testing-library/user-event": "14.4.3", + "@testing-library/user-event": "14.5.1", "@types/jest-axe": "3.5.5", "@types/node": "^20.6.2", "@types/react": "18.2.21", diff --git a/yarn.lock b/yarn.lock index 778a8b52..63015ba5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1146,10 +1146,10 @@ "@testing-library/dom" "^9.0.0" "@types/react-dom" "^18.0.0" -"@testing-library/user-event@14.4.3": - version "14.4.3" - resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.4.3.tgz#af975e367743fa91989cd666666aec31a8f50591" - integrity sha512-kCUc5MEwaEMakkO5x7aoD+DLi02ehmEM2QCGWvNqAS1dV/fAvORWEjnjsEIvml59M7Y5kCkWN6fCCyPOe8OL6Q== +"@testing-library/user-event@14.5.1": + version "14.5.1" + resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.5.1.tgz#27337d72046d5236b32fd977edee3f74c71d332f" + integrity sha512-UCcUKrUYGj7ClomOo2SpNVvx4/fkd/2BbIHDCle8A0ax+P3bU7yJwDBDrS6ZwdTMARWTGODX1hEsCcO+7beJjg== "@tootallnate/once@2": version "2.0.0" From 126fe94a5aba1dd40a9a887c418af434d25f448c Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Tue, 19 Sep 2023 14:22:17 +0200 Subject: [PATCH 21/25] v0.2.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42ad21e2..557a56d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spinntektsmelding-frontend", - "version": "0.2.9", + "version": "0.2.10", "private": true, "scripts": { "dev": "next dev | pino-pretty", From b99a0f1b78b9ac1720734e292ada469aff737e31 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 20 Sep 2023 08:45:52 +0200 Subject: [PATCH 22/25] =?UTF-8?q?Venter=20med=20=C3=A5=20gj=C3=B8re=20knap?= =?UTF-8?q?pen=20tilgjengelig=20til=20dokumentet=20er=20sendt=20inn,=20?= =?UTF-8?q?=E2=80=A6=20(#275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Venter med å gjøre knappen tilgjengelig til dokumentet er sendt inn, eller feiler * Setter ned ventetiden på lokal mockbackend --- pages/[slug].tsx | 8 +-- .../api/innsendingInntektsmelding/[postId].ts | 4 +- pages/endring/[slug].tsx | 8 +-- utils/useSendInnSkjema.ts | 71 +++++++++---------- 4 files changed, 44 insertions(+), 47 deletions(-) diff --git a/pages/[slug].tsx b/pages/[slug].tsx index 9701031d..05ba5480 100644 --- a/pages/[slug].tsx +++ b/pages/[slug].tsx @@ -74,12 +74,10 @@ const Home: NextPage = () => { const submitForm = (event: React.FormEvent) => { event.preventDefault(); setSenderInn(true); - const send = async () => { - await sendInnSkjema(opplysningerBekreftet, false, pathSlug, 'Hovedskjema'); - }; - send(); - setSenderInn(false); + sendInnSkjema(opplysningerBekreftet, false, pathSlug, 'Hovedskjema').finally(() => { + setSenderInn(false); + }); }; const clickOpplysningerBekreftet = (event: React.MouseEvent) => { diff --git a/pages/api/innsendingInntektsmelding/[postId].ts b/pages/api/innsendingInntektsmelding/[postId].ts index 3c5ce538..2e51e0ed 100644 --- a/pages/api/innsendingInntektsmelding/[postId].ts +++ b/pages/api/innsendingInntektsmelding/[postId].ts @@ -51,7 +51,9 @@ const handler = (req: NextApiRequest, res: NextApiResponse) => { } ] }; - return res.status(201).json(innsendteData); + setTimeout(() => { + return res.status(201).json(innsendteData); + }, 100); } else if (env == 'production') { return httpProxyMiddleware(req, res, { target: basePath, diff --git a/pages/endring/[slug].tsx b/pages/endring/[slug].tsx index 1fcfb50a..6fb8757d 100644 --- a/pages/endring/[slug].tsx +++ b/pages/endring/[slug].tsx @@ -179,11 +179,11 @@ const Endring: NextPage = () => { event.preventDefault(); setSenderInn(true); - const send = async () => { - await sendInnSkjema(opplysningerBekreftet, true, pathSlug!, amplitudeComponent); - }; - send(); + sendInnSkjema(opplysningerBekreftet, true, pathSlug!, amplitudeComponent).finally(() => { + setSenderInn(false); + }); + setSenderInn(false); }; diff --git a/utils/useSendInnSkjema.ts b/utils/useSendInnSkjema.ts index 128a641a..99446639 100644 --- a/utils/useSendInnSkjema.ts +++ b/utils/useSendInnSkjema.ts @@ -43,33 +43,31 @@ export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: fyllFeilmeldinger([]); - const postData = async () => { - if (!isValidUUID(pathSlug)) { - const errors: Array = [ - { - value: 'Innsending av skjema feilet', - error: 'Innsending av skjema feilet. Ugyldig identifikator', - property: 'server' - } - ]; - - logEvent('skjema validering feilet', { - tittel: 'Ugyldig UUID ved innsending', - component: amplitudeComponent - }); - errorResponse(errors); - - return false; - } - - const data = await fetch(`${environment.innsendingUrl}/${pathSlug}`, { - method: 'POST', - body: JSON.stringify(skjemaData), - headers: { - 'Content-Type': 'application/json' + if (!isValidUUID(pathSlug)) { + const errors: Array = [ + { + value: 'Innsending av skjema feilet', + error: 'Innsending av skjema feilet. Ugyldig identifikator', + property: 'server' } + ]; + + logEvent('skjema validering feilet', { + tittel: 'Ugyldig UUID ved innsending', + component: amplitudeComponent }); + errorResponse(errors); + return false; + } + + return fetch(`${environment.innsendingUrl}/${pathSlug}`, { + method: 'POST', + body: JSON.stringify(skjemaData), + headers: { + 'Content-Type': 'application/json' + } + }).then((data) => { switch (data.status) { case 201: setKvitteringInnsendt(new Date()); @@ -80,7 +78,7 @@ export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: const errors: Array = [ { value: 'Innsending av skjema feilet', - error: 'Innsending av skjema feilet', + error: 'Det er akkurat nå en feil i systemet hos oss. Vennligst prøv igjen om en stund.', property: 'server' } ]; @@ -124,20 +122,19 @@ export default function useSendInnSkjema(innsendingFeiletIngenTilgang: (feilet: } default: - const resultat = await data.json(); - - logEvent('skjema innsending feilet', { - tittel: 'Innsending feilet', - component: amplitudeComponent + return data.json().then((resultat) => { + logEvent('skjema innsending feilet', { + tittel: 'Innsending feilet', + component: amplitudeComponent + }); + + if (resultat.errors) { + const errors: Array = resultat.errors; + errorResponse(errors); + } }); - - if (resultat.errors) { - const errors: Array = resultat.errors; - errorResponse(errors); - } } - }; - postData(); + }); } }; } From 1c15a9fb73c315c8ca972e76741451ec3a2ae57b Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 20 Sep 2023 08:46:55 +0200 Subject: [PATCH 23/25] v0.2.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 557a56d5..59e6502f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spinntektsmelding-frontend", - "version": "0.2.10", + "version": "0.2.11", "private": true, "scripts": { "dev": "next dev | pino-pretty", From e815dd084dd5fbd4d28b005841b1b11aaeb05142 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 20 Sep 2023 09:41:35 +0200 Subject: [PATCH 24/25] Utkommentert kode --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3d5016ed..4a59ecae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,6 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc ./ RUN --mount=type=secret,id=NODE_AUTH_TOKEN \ echo '//npm.pkg.github.com/:_authToken='$(cat /run/secrets/NODE_AUTH_TOKEN) >> .npmrc -# RUN npm config set always-auth true # Er ikke støttet lengre, men kan den bare slettes? - RUN yarn --frozen-lockfile --ignore-scripts From 47e094acc081a76d6579aeda7d1ffa5e6fdbcc98 Mon Sep 17 00:00:00 2001 From: Kent Fjellstad Date: Wed, 20 Sep 2023 09:51:17 +0200 Subject: [PATCH 25/25] Mode fix --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a59ecae..0a5a747b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,9 +56,9 @@ COPY --from=builder /app/public ./public # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs --chmod=644 /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs --chmod=444 /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs --chmod=644 /app/.next/static ./.next/static +COPY --from=builder --chown=nextjs:nodejs --chmod=444 /app/.next/static ./.next/static USER nextjs