Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/oppsumeringsdokument-service-500-feil
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum committed Feb 23, 2024
2 parents 8dfa0d9 + 5b32d38 commit b67bb36
Show file tree
Hide file tree
Showing 43 changed files with 4,292 additions and 3,781 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ import { ERROR_NAVIGATE_IDENT } from '../../src/ducks/errors/ErrorMessages'

const personFragmentNaviger = new RegExp(/dolly-backend\/api\/v1\/ident\/naviger\/12345678912/)

describe('Navigering til ident som finnes i bestilling og tilbake igjen til bestillingen', () => {
it('passes', () => {
cy.visit('gruppe')

cy.get('div').contains('Testytest').click()

cy.dollyGet(CypressSelector.TOGGLE_VISNING_BESTILLINGER).click()

cy.dollyGet(CypressSelector.BUTTON_OPEN_BESTILLING).each((element) => {
cy.wrap(element).click()
})

cy.get('Button').contains('12345678912').click()

cy.dollyGet(CypressSelector.TOGGLE_VISNING_PERSONER).should('have.attr', 'aria-checked', 'true')
cy.dollyGet(CypressSelector.BUTTON_TIDLIGEREBESTILLINGER_NAVIGER).click()

cy.dollyGet(CypressSelector.TOGGLE_VISNING_BESTILLINGER).should(
'have.attr',
'aria-checked',
'true',
)
})
})

describe('Navigering til ident som finnes i gruppe 1', () => {
it('passes', () => {
cy.visit('gruppe')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export enum CypressSelector {
BUTTON_MALMODAL_LAGRE = 'button-malmodal-lagre',
BUTTON_GJENOPPRETT_GRUPPE = 'button-gjenopprett-gruppe',
BUTTON_REDIGER_GRUPPE = 'button-rediger-gruppe',
BUTTON_TIDLIGEREBESTILLINGER_NAVIGER = 'button-tidligerebestillinger-naviger',
SELECT_PERSON_SEARCH = 'select-person-search',
SELECT_TAGS = 'select-tags',
HOVER_MILJOE = 'hover-miljoe',
Expand Down
646 changes: 307 additions & 339 deletions apps/dolly-frontend/src/main/js/package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions apps/dolly-frontend/src/main/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
"react-toastify": "^10.0.0",
"react-use": "^17.4.0",
"react-window": "^1.8.7",
"redux": "^4.2.0",
"redux": "^5.0.1",
"redux-actions": "^3.0.0",
"redux-first-history": "^5.1.1",
"redux-first-history": "^5.2.0",
"redux-promise-middleware": "^6.1.2",
"redux-thunk": "^2.4.1",
"redux-thunk": "^3.1.0",
"regenerator-runtime": "^0.14.0",
"reselect": "^4.1.6",
"reselect": "^5.1.0",
"styled-components": "^6.0.1",
"use-react-router-breadcrumbs": "^4.0.0",
"uuid": "^9.0.0",
Expand All @@ -74,11 +74,11 @@
},
"devDependencies": {
"@hookform/error-message": "^2.0.1",
"@navikt/ds-css": "^5.0.3",
"@navikt/ds-css": "^6.1.0",
"@navikt/ds-icons": "^3.4.3",
"@navikt/ds-react": "^5.15.0",
"@redux-devtools/extension": "^3.2.3",
"@reduxjs/toolkit": "^1.8.4",
"@navikt/ds-react": "^6.1.0",
"@redux-devtools/extension": "^3.3.0",
"@reduxjs/toolkit": "^2.2.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.0",
"@types/lodash": "^4.14.182",
Expand All @@ -87,7 +87,7 @@
"@types/react-datepicker": "^6.0.0",
"@types/react-dom": "^18.0.6",
"@types/react-highlight-words": "^0.16.4",
"@types/react-redux": "^7.1.24",
"@types/react-redux": "^7.1.33",
"@types/react-router-dom": "^5.3.3",
"@types/react-syntax-highlighter": "^15.5.4",
"@types/react-window": "^1.8.5",
Expand All @@ -112,7 +112,7 @@
"prettier": "^3.0.0",
"react-dropzone": "^14.2.3",
"react-pdf": "^7.0.3",
"react-redux": "^8.0.2",
"react-redux": "^9.1.0",
"react-router-dom": "^6.3.0",
"resq": "^1.10.2",
"rollup-plugin-node-externals": "^7.0.1",
Expand Down
8 changes: 4 additions & 4 deletions apps/dolly-frontend/src/main/js/src/Store.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { combineReducers } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { thunk } from 'redux-thunk'
import { createPromise } from 'redux-promise-middleware'
import gruppeReducer from '@/ducks/gruppe'
import fagsystemReducer from '@/ducks/fagsystem'
Expand All @@ -14,7 +14,7 @@ import redigertePersonerReducer from '@/ducks/redigertePersoner'
import commonReducer from '@/ducks/common'
import { createReduxHistoryContext, LOCATION_CHANGE } from 'redux-first-history'
import { createBrowserHistory } from 'history'
import { configureStore } from '@reduxjs/toolkit'
import { configureStore, Tuple } from '@reduxjs/toolkit'

const locationMiddleware = (reduxStore) => (next) => (action) => {
if (action.type === LOCATION_CHANGE) {
Expand All @@ -34,7 +34,7 @@ const { createReduxHistory, routerMiddleware, routerReducer } = createReduxHisto
const allMiddleware = [
routerMiddleware,
locationMiddleware,
thunkMiddleware,
thunk,
createPromise({ promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAILURE'] }),
]

Expand All @@ -56,7 +56,7 @@ const rootReducer = () =>

export const store = configureStore({
reducer: rootReducer(),
middleware: allMiddleware,
middleware: () => new Tuple(...allMiddleware),
})

// Infer the `RootState` and `AppDispatch` types from the store itself
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
import { useToggle } from 'react-use'
import ExpandButton from '@/components/ui/button/ExpandButton/ExpandButton'
import { navigerTilPerson } from '@/ducks/finnPerson'
import { useDispatch } from 'react-redux'
import Button from '@/components/ui/button/Button'
import { useState } from 'react'
import Loading from '@/components/ui/loading/Loading'
import styled from 'styled-components'

const NavigerTilIdentButton = styled(Button)`
&&& {
margin-left: unset;
font-size: 15px;
}
span {
margin-top: 0;
padding-left: 0;
}
`

function IdentList({ identer }: { identer: string[] }) {
const dispatch = useDispatch()
const [loading, setLoading] = useState(false)
return (
<ul>
{identer.map((ident, idx) => (
<li key={idx}>{ident}</li>
))}
{identer.map((ident, idx) =>
loading ? (
<Loading label={'Navigerer...'} key={idx} />
) : (
<NavigerTilIdentButton
onClick={() => {
setLoading(true)
return dispatch(navigerTilPerson(ident))
}}
key={idx}
>
{ident}
</NavigerTilIdentButton>
),
)}
</ul>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react'
import React, { useContext, useEffect } from 'react'
import { harAvhukedeAttributter } from '@/components/bestillingsveileder/utils'
import { BestillingsveilederContext } from '@/components/bestillingsveileder/BestillingsveilederContext'
import { SigrunstubForm } from '@/components/fagsystem/sigrunstub/form/Form'
Expand Down Expand Up @@ -46,6 +46,12 @@ export const Steg2 = () => {
const opts: any = useContext(BestillingsveilederContext)
const formMethods = useFormContext()

useEffect(() => {
if (opts.gruppe?.id) {
formMethods.setValue('gruppeId', opts.gruppe?.id)
}
}, [])

const leggTil = opts.is.leggTil
const importTestnorge = opts.is.importTestnorge
const gruppe = opts.gruppe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export const initialArbeidsforholdOrg = {
arbeidstidsordning: 'ikkeSkift',
avtaltArbeidstimerPerUke: 37.5,
},
navArbeidsforholdPeriode: null,
navArbeidsforholdPeriode: undefined,
antallTimerForTimeloennet: [],
utenlandsopphold: [],
permisjon: [],
permittering: [],
}

export const initialArbeidsforholdPers = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ export const ArbeidsforholdForm = ({
)
}

const harGjortFormEndringer = (formValues) => {
if (formValues.length > 1) {
const harGjortFormEndringer = () => {
if (watch('aareg').length > 1) {
return true
}
return !_.isEqual(getValues('aareg'), [initialArbeidsforholdOrg])
return !_.isEqual(
_.omit(watch('aareg')?.[0], ['ansettelsesPeriode']),
_.omit(initialArbeidsforholdOrg, ['ansettelsesPeriode']),
)
}

const { setError, watch, getValues, setValue: setFieldValue, trigger } = useFormContext()
const { setError, watch, getValues, setValue, trigger } = useFormContext()
const [navArbeidsforholdPeriode, setNavArbeidsforholdPeriode] = useState(null as unknown as Date)
const { tidligereBestillinger } = useContext(BestillingsveilederContext)
const tidligereAaregBestillinger = hentUnikeAaregBestillinger(tidligereBestillinger)
Expand All @@ -95,18 +98,18 @@ export const ArbeidsforholdForm = ({
arbeidsforholdIndex < tidligereAaregBestillinger?.length

useEffect(() => {
if (_.isEmpty(tidligereAaregBestillinger) || harGjortFormEndringer(getValues('aareg'))) {
if (_.isEmpty(tidligereAaregBestillinger) || harGjortFormEndringer()) {
return
}
setFieldValue(
setValue(
'aareg',
tidligereAaregBestillinger.map((aaregBestilling) => {
tidligereAaregBestillinger?.map((aaregBestilling) => {
aaregBestilling.isOppdatering = true
return aaregBestilling
}),
)
trigger()
}, [getValues('aareg')])
trigger('aareg')
}, [watch('aareg')])

const gjeldendeArbeidsgiver = watch(`${path}.arbeidsgiver`)

Expand All @@ -120,7 +123,7 @@ export const ArbeidsforholdForm = ({
const value = isDate(field)
? fixTimezone(field)
: field?.value || field?.target?.value || null
setFieldValue(`${path}.${fieldPath}`, value)
setValue(`${path}.${fieldPath}`, value)
trigger()
}
} else {
Expand All @@ -140,7 +143,7 @@ export const ArbeidsforholdForm = ({
_.set(amelding[idx], `arbeidsforhold[${arbeidsforholdIndex}]`, arbeidsforholdClone)
}
})
setFieldValue('aareg[0].amelding', amelding)
setValue('aareg[0].amelding', amelding)
trigger('aareg[0].amelding')
}
}
Expand All @@ -153,14 +156,14 @@ export const ArbeidsforholdForm = ({
arbeidsgiverType === ArbeidsgiverTyper.felles ||
arbeidsgiverType === ArbeidsgiverTyper.fritekst
) {
setFieldValue(path, {
setValue(path, {
...initialForenkletOppgjoersordningOrg,
arbeidsforholdstype: event.value,
arbeidsgiver: gjeldendeArbeidsgiver,
})
trigger()
} else if (arbeidsgiverType === ArbeidsgiverTyper.privat) {
setFieldValue(path, {
setValue(path, {
...initialForenkletOppgjoersordningPers,
arbeidsforholdstype: event.value,
arbeidsgiver: gjeldendeArbeidsgiver,
Expand All @@ -174,36 +177,36 @@ export const ArbeidsforholdForm = ({
arbeidsgiverType === ArbeidsgiverTyper.felles ||
arbeidsgiverType === ArbeidsgiverTyper.fritekst
) {
setFieldValue(path, {
setValue(path, {
...initialArbeidsforholdOrg,
arbeidsforholdstype: event.value,
arbeidsgiver: gjeldendeArbeidsgiver,
})
trigger()
} else if (arbeidsgiverType === ArbeidsgiverTyper.privat) {
setFieldValue(path, {
setValue(path, {
...initialArbeidsforholdPers,
arbeidsforholdstype: event.value,
arbeidsgiver: gjeldendeArbeidsgiver,
})
trigger()
}
} else {
setFieldValue(`${path}.arbeidsforholdstype`, event.value)
setValue(`${path}.arbeidsforholdstype`, event.value)
trigger()
}
if (event.value === 'maritimtArbeidsforhold') {
setFieldValue(`${path}.fartoy`, initialFartoy)
setValue(`${path}.fartoy`, initialFartoy)
trigger()
} else {
setFieldValue(`${path}.fartoy`, undefined)
setValue(`${path}.fartoy`, undefined)
trigger()
}
}
}

useEffect(() => {
setFieldValue(
setValue(
`${path}.navArbeidsforholdPeriode`,
navArbeidsforholdPeriode
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,21 @@ export const AlderspensjonForm = () => {
const harAlder =
_has(formMethods.getValues(), 'pdldata.opprettNyPerson.alder') &&
_has(formMethods.getValues(), 'pdldata.opprettNyPerson.foedtFoer')
const alderNyPerson = _get(formMethods.getValues(), 'pdldata.opprettNyPerson.alder')
const foedtFoer = _get(formMethods.getValues(), 'pdldata.opprettNyPerson.foedtFoer')
const harUgyldigAlder =
(alderNyPerson && alderNyPerson < 62) ||
(isDate(foedtFoer) && add(foedtFoer, { years: 62 }) > new Date())
return { harAlder, alderNyPerson, foedtFoer, harUgyldigAlder }
const alderNyPerson = formMethods.watch('pdldata.opprettNyPerson.alder')
const foedtFoer =
formMethods.watch('pdldata.opprettNyPerson.foedtFoer') &&
new Date(formMethods.watch('pdldata.opprettNyPerson.foedtFoer'))
const iverksettelsesdato =
formMethods.watch('pensjonforvalter.alderspensjon.iverksettelsesdato') &&
new Date(formMethods.watch('pensjonforvalter.alderspensjon.iverksettelsesdato'))
const harGyldigAlder =
(alderNyPerson && alderNyPerson > 61) ||
(isDate(foedtFoer) && add(foedtFoer, { years: 62 }) < new Date()) ||
(isDate(foedtFoer) && add(foedtFoer, { years: 62 }) < iverksettelsesdato)
return { harAlder, alderNyPerson, foedtFoer, harGyldigAlder }
}

const { harAlder, alderNyPerson, foedtFoer, harUgyldigAlder } = sjekkAlderFelt()
const { harAlder, alderNyPerson, foedtFoer, harGyldigAlder } = sjekkAlderFelt()

const alderLeggTilPerson = getAlder(
_get(opts, 'personFoerLeggTil.pdl.hentPerson.foedsel[0].foedselsdato'),
Expand Down Expand Up @@ -191,10 +197,10 @@ export const AlderspensjonForm = () => {
iconType="pensjon"
startOpen={erForsteEllerTest(formMethods.getValues(), [alderspensjonPath])}
>
{nyBestilling && (!harAlder || harUgyldigAlder) && (
{nyBestilling && (!harAlder || !harGyldigAlder) && (
<StyledAlert variant={'warning'} size={'small'}>
For å sikre at personen har rett på alderspensjon må alder settes til 62 år eller
høyere.
høyere. Eventuelt må iverksettelsesdato settes til etter personen har fylt 62 år.
</StyledAlert>
)}
{((leggTil && alderLeggTilPerson < 62) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ InntektsmeldingForm.validation = {
'$inntektsmelding.inntekter[0].arbeidsgiverPrivat.arbeidsgiverFnr',
requiredString.matches(/^\d{11}$/, 'Ident må være et tall med 11 siffer'),
),
}),
}).nullable(),
arbeidsforhold: Yup.object({
beregnetInntekt: Yup.object({
beloep: requiredNumber.typeError(messages.required),
Expand Down
Loading

0 comments on commit b67bb36

Please sign in to comment.