Skip to content

Commit

Permalink
Monthpicker-fix + div annet fix
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed May 23, 2024
1 parent 5159165 commit c975640
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default ({ path }: InntektsinformasjonForm) => {
)

const handleDateChange = (selectedDate: Date) => {
selectedDate.setHours(6)
selectedDate?.setHours(6)
setDate(selectedDate)
formMethods.setValue(
`${path}.sisteAarMaaned`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Panel from '@/components/ui/panel/Panel'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import React from 'react'

export const BrregErFrVisning = ({ harDagligLederRolle }) => {
export const BrregErFrVisning = ({ harDagligLederRolle }: any) => {
if (!harDagligLederRolle) {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export const Inntekt = ({ inntekt }: any) => {
)
}

export const InntektVisning = ({ inntektListe }) => {
export const InntektVisning = ({ inntektListe }: any) => {
if (!inntektListe || inntektListe.length < 1) {
return null
}

return (
<Panel heading="Inntekt A-ordningen">
<div className="person-visning_content">
<DollyFieldArray data={inntektListe} header={null} nested>
<DollyFieldArray data={inntektListe} nested>
{(inntekt: any) => {
return <Inntekt inntekt={inntekt} />
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export const Skattemelding = ({ skattemelding }: any) => {
)
}

export const SkattemeldingVisning = ({ skattemeldingListe }) => {
export const SkattemeldingVisning = ({ skattemeldingListe }: any) => {
if (!skattemeldingListe || skattemeldingListe.length < 1) {
return null
}

return (
<Panel heading="Skattemelding">
<div className="person-visning_content">
<DollyFieldArray data={skattemeldingListe} header={null} nested>
<DollyFieldArray data={skattemeldingListe} nested>
{(skattemelding: any) => {
return <Skattemelding skattemelding={skattemelding} />
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const TjenestepensjonsavtaleVisning = ({ tpListe }: any) => {
return (
<Panel heading="Tjenestepensjonsavtale">
<div className="person-visning_content">
<DollyFieldArray data={tpListe} header={null} nested>
<DollyFieldArray data={tpListe} nested>
{(tjenestepensjonsavtale: any) => {
return <Tjenestepensjonsavtale tjenestepensjonsavtale={tjenestepensjonsavtale} />
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { MonthPicker, useMonthpicker } from '@navikt/ds-react'
import { addYears, isDate, subYears } from 'date-fns'
import { useFormContext } from 'react-hook-form'
import _ from 'lodash'
import { useEffect } from 'react'

interface MonthpickerProps {
name: string
label: string
date?: Date
handleDateChange?: (dato: string, type: string) => void
onChange?: (date: Date) => void
isClearable?: boolean
minDate?: Date
maxDate?: Date
}
Expand All @@ -22,14 +22,12 @@ export const Monthpicker = ({
date = null,
handleDateChange,
onChange,
isClearable = false,
minDate = null,
maxDate = null,
...props
}: MonthpickerProps) => {
const formMethods = useFormContext()
const val = formMethods.watch(name)
// console.log('val: ', val) //TODO - SLETT MEG

function getEksisterendeVerdi() {
if (name.includes('navArbeidsforholdPeriode')) {
return val?.year ? new Date(val?.year, val?.monthValue) : null
Expand All @@ -50,7 +48,6 @@ export const Monthpicker = ({
fromDate: minDate || subYears(new Date(), 125),
toDate: maxDate || addYears(new Date(), 5),
onMonthChange: (selectedDate) => {
// console.log('selectedDate: ', selectedDate) //TODO - SLETT MEG
selectedDate?.setHours(12)
onChange ? onChange(selectedDate) : handleDateChange(selectedDate)
},
Expand All @@ -60,19 +57,13 @@ export const Monthpicker = ({
: new Date(formattedDate)
: undefined,
})
// console.log('name: ', name) //TODO - SLETT MEG
// console.log('date: ', date) //TODO - SLETT MEG
// console.log('formattedDate: ', formattedDate) //TODO - SLETT MEG

if (!val && inputProps.value) {
reset()
}
// TODO sjekk om reset funker med oppdatert getUpdatedRequest
useEffect(() => {
if (!val && inputProps.value) {
reset()
}
}, [val])

// if (name === 'tjenestepensjonsavtale.periode') {
// console.log('monthpickerProps: ', monthpickerProps) //TODO - SLETT MEG
// console.log('inputProps: ', inputProps) //TODO - SLETT MEG
// }
return (
<InputWrapper size={'small'}>
<Label name={name} label={label}>
Expand Down
13 changes: 5 additions & 8 deletions apps/dolly-frontend/src/main/js/src/pages/tenorSoek/SoekForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,17 @@ export const SoekForm = ({ setRequest, setMarkertePersoner, mutate }: any) => {
delete request[key]
} else if (typeof request[key] === 'object' && !(request[key] instanceof Date)) {
request[key] = getUpdatedRequest(request[key])
if (Object.keys(request[key]).length === 0) delete request[key]
// if (Object.keys(request[key]).length === 0) {
// delete request[key]
// } else {
// request[key] = getUpdatedRequest(request[key])
// }
if (Object.keys(request[key]).length === 0) {
delete request[key]
} else {
request[key] = getUpdatedRequest(request[key])
}
}
}
return Array.isArray(request) ? request.filter((val) => val) : request
}
//TODO Sjekk ordentlig om dette funker

const handleChange = (value: any, path: string) => {
// console.log('value: ', value) //TODO - SLETT MEG
if (isDate(value)) {
value = fixTimezone(value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default () => {
if (state.side > 0) {
setState({
...state,
personListe: [...state.personListe, ...response?.data?.data?.personer],
personListe: [...state.personListe, ...response.data.data.personer],
nesteSide: response?.data?.data?.nesteSide,
})
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const InntektVisning = ({ data }: any) => {
return (
<SubOverskriftExpandable label={`Inntekt A-ordningen (${data.length})`} iconKind="inntektstub">
<div>
<DollyFieldArray data={data} header={null} nested>
<DollyFieldArray data={data} nested>
{(inntekt: any) => {
return (
<TabsVisning kildedata={inntekt.tenorMetadata?.kildedata}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const SkattemeldingVisning = ({ data }: any) => {
return (
<SubOverskriftExpandable label={`Skattemelding (${data.length})`} iconKind="bankkonto">
<div>
<DollyFieldArray data={data} header={null} nested>
<DollyFieldArray data={data} nested>
{(skattemelding: any) => {
return (
<TabsVisning kildedata={skattemelding.tenorMetadata?.kildedata}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const TjenestepensjonsavtaleVisning = ({ data }: any) => {
isExpanded={true}
>
<div>
<DollyFieldArray data={data} header={null} nested>
<DollyFieldArray data={data} nested>
{(tjenestepensjonsavtale: any) => {
return (
<TabsVisning kildedata={tjenestepensjonsavtale.tenorMetadata?.kildedata}>
Expand Down

0 comments on commit c975640

Please sign in to comment.