diff --git a/apps/dolly-frontend/src/main/js/package-lock.json b/apps/dolly-frontend/src/main/js/package-lock.json
index ec997444229..d6094648b74 100644
--- a/apps/dolly-frontend/src/main/js/package-lock.json
+++ b/apps/dolly-frontend/src/main/js/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "dolly",
- "version": "3.0.4",
+ "version": "3.0.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dolly",
- "version": "3.0.4",
+ "version": "3.0.6",
"license": "ISC",
"dependencies": {
"@babel/preset-flow": "^7.18.6",
@@ -3120,15 +3120,15 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ=="
},
"node_modules/@types/lodash": {
- "version": "4.14.202",
- "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.202.tgz",
- "integrity": "sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==",
+ "version": "4.17.0",
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
+ "integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==",
"dev": true
},
"node_modules/@types/node": {
- "version": "20.11.26",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.26.tgz",
- "integrity": "sha512-YwOMmyhNnAWijOBQweOJnQPl068Oqd4K3OFbTc6AHJwzweUwwWG3GIFY74OKks2PJUDkQPeddOQES9mLn1CTEQ==",
+ "version": "20.11.27",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.27.tgz",
+ "integrity": "sha512-qyUZfMnCg1KEz57r7pzFtSGt49f6RPkPBis3Vo4PbS7roQEDn22hiHzl/Lo1q4i4hDEgBJmBF/NTNg2XR0HbFg==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
@@ -3196,9 +3196,9 @@
"dev": true
},
"node_modules/@types/react-dom": {
- "version": "18.2.21",
- "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.21.tgz",
- "integrity": "sha512-gnvBA/21SA4xxqNXEwNiVcP0xSGHh/gi1VhWv9Bl46a0ItbTT5nFY+G9VSQpaG/8N/qdJpJ+vftQ4zflTtnjLw==",
+ "version": "18.2.22",
+ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.22.tgz",
+ "integrity": "sha512-fHkBXPeNtfvri6gdsMYyW+dW7RXFo6Ad09nLFK0VQWR7yGLai/Cyvyj696gbwYvBnhGtevUG9cET0pmUbMtoPQ==",
"dev": true,
"dependencies": {
"@types/react": "*"
@@ -4950,9 +4950,9 @@
"integrity": "sha512-LO/lzYRw134LMDVnLyAf1dHE5tyO6axEFkR3TXjQIOmMkAM9YL6QsiUwuXzZAmFnuDJcs4hayOgyIYtViXFrLw=="
},
"node_modules/cypress": {
- "version": "13.6.6",
- "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.6.6.tgz",
- "integrity": "sha512-S+2S9S94611hXimH9a3EAYt81QM913ZVA03pUmGDfLTFa5gyp85NJ8dJGSlEAEmyRsYkioS1TtnWtbv/Fzt11A==",
+ "version": "13.7.0",
+ "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.7.0.tgz",
+ "integrity": "sha512-UimjRSJJYdTlvkChcdcfywKJ6tUYuwYuk/n1uMMglrvi+ZthNhoRYcxnWgTqUtkl17fXrPAsD5XT2rcQYN1xKA==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
@@ -5397,9 +5397,9 @@
}
},
"node_modules/electron-to-chromium": {
- "version": "1.4.701",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.701.tgz",
- "integrity": "sha512-K3WPQ36bUOtXg/1+69bFlFOvdSm0/0bGqmsfPDLRXLanoKXdA+pIWuf/VbA9b+2CwBFuONgl4NEz4OEm+OJOKA=="
+ "version": "1.4.705",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.705.tgz",
+ "integrity": "sha512-LKqhpwJCLhYId2VVwEzFXWrqQI5n5zBppz1W9ehhTlfYU8CUUW6kClbN8LHF/v7flMgRdETS772nqywJ+ckVAw=="
},
"node_modules/emoji-regex": {
"version": "9.2.2",
@@ -10249,9 +10249,9 @@
}
},
"node_modules/require-in-the-middle": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-7.2.0.tgz",
- "integrity": "sha512-3TLx5TGyAY6AOqLBoXmHkNql0HIf2RGbuMgCDT2WO/uGVAPJs6h7Kl+bN6TIZGd9bWhWPwnDnTHGtW8Iu77sdw==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-7.2.1.tgz",
+ "integrity": "sha512-u5XngygsJ+XV2dBV/Pl4SrcNpUXQfmYmXtuFeHDXfzk4i4NnGnret6xKWkkJHjMHS/16yMV9pEAlAunqmjllkA==",
"dependencies": {
"debug": "^4.1.1",
"module-details-from-path": "^1.0.3",
@@ -10583,9 +10583,9 @@
"dev": true
},
"node_modules/sass": {
- "version": "1.71.1",
- "resolved": "https://registry.npmjs.org/sass/-/sass-1.71.1.tgz",
- "integrity": "sha512-wovtnV2PxzteLlfNzbgm1tFXPLoZILYAMJtvoXXkD7/+1uP41eKkIt1ypWq5/q2uT94qHjXehEYfmjKOvjL9sg==",
+ "version": "1.72.0",
+ "resolved": "https://registry.npmjs.org/sass/-/sass-1.72.0.tgz",
+ "integrity": "sha512-Gpczt3WA56Ly0Mn8Sl21Vj94s1axi9hDIzDFn9Ph9x3C3p4nNyvsqJoQyVXKou6cBlfFWEgRW4rT8Tb4i3XnVA==",
"dev": true,
"dependencies": {
"chokidar": ">=3.0.0 <4.0.0",
@@ -12019,14 +12019,14 @@
}
},
"node_modules/vite-tsconfig-paths": {
- "version": "4.3.1",
- "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.3.1.tgz",
- "integrity": "sha512-cfgJwcGOsIxXOLU/nELPny2/LUD/lcf1IbfyeKTv2bsupVbTH/xpFtdQlBmIP1GEK2CjjLxYhFfB+QODFAx5aw==",
+ "version": "4.3.2",
+ "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.3.2.tgz",
+ "integrity": "sha512-0Vd/a6po6Q+86rPlntHye7F31zA2URZMbH8M3saAZ/xR9QoGN/L21bxEGfXdWmFdNkqPpRdxFT7nmNe12e9/uA==",
"dev": true,
"dependencies": {
"debug": "^4.1.1",
"globrex": "^0.1.2",
- "tsconfck": "^3.0.1"
+ "tsconfck": "^3.0.3"
},
"peerDependencies": {
"vite": "*"
diff --git a/apps/dolly-frontend/src/main/js/package.json b/apps/dolly-frontend/src/main/js/package.json
index 1f28751bcf2..65f4d589edc 100644
--- a/apps/dolly-frontend/src/main/js/package.json
+++ b/apps/dolly-frontend/src/main/js/package.json
@@ -1,6 +1,6 @@
{
"name": "dolly",
- "version": "3.0.4",
+ "version": "3.0.6",
"type": "module",
"description": "",
"main": "index.js",
diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/aareg/form/partials/arbeidsforholdForm.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/aareg/form/partials/arbeidsforholdForm.tsx
index 88b0a17ace8..aa8ad5257dd 100644
--- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/aareg/form/partials/arbeidsforholdForm.tsx
+++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/aareg/form/partials/arbeidsforholdForm.tsx
@@ -89,8 +89,16 @@ export const ArbeidsforholdForm = ({
}
const { setError, watch, control, getValues, setValue, trigger, resetField } = useFormContext()
- const [navArbeidsforholdPeriode, setNavArbeidsforholdPeriode] = useState(null as unknown as Date)
- const { tidligereBestillinger } = useContext(BestillingsveilederContext)
+ const eksisterendeArbeidsforholdPeriode = watch(`${path}.navArbeidsforholdPeriode`)
+ const [navArbeidsforholdPeriode, setNavArbeidsforholdPeriode] = useState(
+ eksisterendeArbeidsforholdPeriode
+ ? new Date(
+ eksisterendeArbeidsforholdPeriode.year,
+ eksisterendeArbeidsforholdPeriode.monthValue,
+ )
+ : null,
+ )
+ const { tidligereBestillinger }: any = useContext(BestillingsveilederContext)
const tidligereAaregBestillinger = hentUnikeAaregBestillinger(tidligereBestillinger)
const erLaastArbeidsforhold =
(arbeidsgiverType === ArbeidsgiverTyper.felles ||
@@ -101,12 +109,13 @@ export const ArbeidsforholdForm = ({
if (_.isEmpty(tidligereAaregBestillinger) || harGjortFormEndringer()) {
return
}
- resetField('aareg', {
- defaultValue: tidligereAaregBestillinger?.map((aaregBestilling) => {
+ setValue(
+ 'aareg',
+ tidligereAaregBestillinger?.map((aaregBestilling) => {
aaregBestilling.isOppdatering = true
return aaregBestilling
}),
- })
+ )
trigger('aareg')
}, [watch('aareg')])
@@ -306,6 +315,7 @@ export const ArbeidsforholdForm = ({
date={navArbeidsforholdPeriode}
label="NAV arbeidsforholdsperiode"
onChange={setNavArbeidsforholdPeriode}
+ value={navArbeidsforholdPeriode}
isClearable={true}
/>
{arbeidsforholdstype === 'forenkletOppgjoersordning' && (
diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/datepicker/Datepicker.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/datepicker/Datepicker.tsx
index dca3e42330c..09ace0a2cd0 100644
--- a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/datepicker/Datepicker.tsx
+++ b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/datepicker/Datepicker.tsx
@@ -1,5 +1,5 @@
import { registerLocale } from 'react-datepicker'
-import { addYears, subYears } from 'date-fns'
+import { addYears, isDate, subYears } from 'date-fns'
import locale_nb from 'date-fns/locale/nb'
import { Label } from '@/components/ui/form/inputs/label/Label'
import { InputWrapper } from '@/components/ui/form/inputWrapper/InputWrapper'
@@ -10,11 +10,12 @@ import './Datepicker.less'
import { useFormContext } from 'react-hook-form'
import { DatePicker, useDatepicker } from '@navikt/ds-react'
import _ from 'lodash'
+import { formatDate } from '@/utils/DataFormatter'
registerLocale('nb', locale_nb)
function addHours(date, amount) {
- date.setHours(amount, 0, 0)
+ date.setHours(amount)
return date
}
@@ -30,23 +31,36 @@ export const Datepicker = ({
maxDate,
}) => {
const formMethods = useFormContext()
- const eksisterendeVerdi = formMethods.watch(name)
- const { datepickerProps, inputProps, selectedDay } = useDatepicker({
+
+ const getSelectedDay = () => {
+ const selected = formMethods.watch(name)
+ if (_.isNil(selected) || _.isEmpty(selected)) {
+ return undefined
+ } else if (isDate(selected)) {
+ return fixTimezone(selected)
+ } else {
+ return fixTimezone(new Date(selected))
+ }
+ }
+
+ const { datepickerProps, inputProps } = useDatepicker({
fromDate: minDate || subYears(new Date(), 125),
toDate: maxDate || addYears(new Date(), 5),
onDateChange: onChange || onBlur,
- defaultSelected: !_.isEmpty(eksisterendeVerdi) ? new Date(eksisterendeVerdi) : undefined,
disabled: excludeDates,
+ defaultSelected: getSelectedDay(),
})
+ const selectedDay = getSelectedDay()
return (
)
diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/monthpicker/Monthpicker.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/monthpicker/Monthpicker.tsx
index b52186d5a29..40bce233630 100644
--- a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/monthpicker/Monthpicker.tsx
+++ b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/monthpicker/Monthpicker.tsx
@@ -1,7 +1,7 @@
import { Label } from '@/components/ui/form/inputs/label/Label'
import { InputWrapper } from '@/components/ui/form/inputWrapper/InputWrapper'
import { MonthPicker, useMonthpicker } from '@navikt/ds-react'
-import { addYears, subYears } from 'date-fns'
+import { addYears, isDate, subYears } from 'date-fns'
import { useFormContext } from 'react-hook-form'
import _ from 'lodash'
@@ -28,24 +28,42 @@ export const Monthpicker = ({
...props
}: MonthpickerProps) => {
const formMethods = useFormContext()
- const eksisterendeVerdi = formMethods.watch(name)
+ const val = formMethods.watch(name)
- const formattedDate = date instanceof Date || date === null ? date : new Date(date)
+ function getEksisterendeVerdi() {
+ if (name.includes('navArbeidsforholdPeriode')) {
+ return val?.year ? new Date(val?.year, val?.monthValue) : null
+ }
+ return val
+ }
- const { monthpickerProps, inputProps, selectedMonth } = useMonthpicker({
+ const eksisterendeVerdi = getEksisterendeVerdi()
+
+ const formattedDate =
+ eksisterendeVerdi instanceof Date
+ ? eksisterendeVerdi
+ : date instanceof Date || date === null
+ ? date
+ : new Date(date)
+
+ const { monthpickerProps, inputProps } = useMonthpicker({
fromDate: minDate || subYears(new Date(), 125),
toDate: maxDate || addYears(new Date(), 5),
onMonthChange: (selectedDate) => {
- selectedDate?.setHours(12, 0, 0, 0)
+ selectedDate?.setHours(12)
onChange ? onChange(selectedDate) : handleDateChange(selectedDate)
},
- defaultSelected: !_.isEmpty(eksisterendeVerdi) ? new Date(eksisterendeVerdi) : undefined,
+ defaultSelected: !_.isNil(formattedDate)
+ ? isDate(formattedDate)
+ ? formattedDate
+ : new Date(formattedDate)
+ : undefined,
})
return (