Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tenor soek ny funksjonalitet #3495

Merged
merged 8 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -0,0 +1,17 @@
import Panel from '@/components/ui/panel/Panel'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import React from 'react'

export const BrregErFrVisning = ({ harDagligLederRolle }: any) => {
if (!harDagligLederRolle) {
return null
}

return (
<Panel heading="Enhetsregisteret og Foretaksregisteret">
<div className="person-visning_content">
<TitleValue title="Roller" value="Daglig leder" />
</div>
</Panel>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Panel from '@/components/ui/panel/Panel'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import React from 'react'
import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import { arrayToString, codeToNorskLabel, oversettBoolean } from '@/utils/DataFormatter'

export const Inntekt = ({ inntekt }: any) => {
return (
<>
<TitleValue title="Periode" value={inntekt.periode} />
<TitleValue title="Opplysningspliktig" value={inntekt.opplysningspliktig} />
<TitleValue
title="Inntektstype"
value={arrayToString(inntekt.inntektstype?.map((type: string) => codeToNorskLabel(type)))}
/>
<TitleValue
title="Beskrivelse"
value={arrayToString(inntekt.beskrivelse?.map((beskr: string) => codeToNorskLabel(beskr)))}
/>
<TitleValue
title="Forskuddstrekk"
value={arrayToString(
inntekt.forskuddstrekk?.map((trekk: string) => codeToNorskLabel(trekk)),
)}
/>
<TitleValue title="Har historikk" value={oversettBoolean(inntekt.harHistorikk)} />
</>
)
}

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} nested>
{(inntekt: any) => {
return <Inntekt inntekt={inntekt} />
}}
</DollyFieldArray>
</div>
</Panel>
)
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
import React from 'react'
import Loading from '@/components/ui/loading/Loading'
import Icon from '@/components/ui/icon/Icon'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import _get from 'lodash/get'
import { BrregErFrVisning } from '@/components/fagsystem/skatteetaten/visning/BrregErFrVisning'
import { InntektVisning } from '@/components/fagsystem/skatteetaten/visning/InntektVisning'
import { TjenestepensjonsavtaleVisning } from '@/components/fagsystem/skatteetaten/visning/TjenestepensjonsavtaleVisning'
import { SkattemeldingVisning } from '@/components/fagsystem/skatteetaten/visning/SkattemeldingVisning'

type SkatteetatenVisningProps = {
data: {
tenorRelasjoner: string[]
tenorRelasjoner: any
}
loading: boolean
}

// Midlertidig visning av daglig leder-rolle fra Tenor. Skrives om naar det er behov for aa vise flere Tenor-data.
// Midlertidig visning av data fra Tenor. Skrives kanskje om naar det er behov for aa vise flere Tenor-data.
export const SkatteetatenVisning = ({ data, loading }: SkatteetatenVisningProps) => {
if (loading) {
return <Loading label="Laster Tenor-data ..." />
}

const harDagligLederRolle = data?.tenorRelasjoner?.includes('BrregErFr')
const tenorRelasjoner = data?.tenorRelasjoner
if (!data || !tenorRelasjoner) {
return null
}

if (!data || !harDagligLederRolle) {
const tjenestepensjonavtaleListe = tenorRelasjoner.tjenestepensjonavtale
const harDagligLederRolle = _get(tenorRelasjoner, 'brreg-er-fr')?.length > 0
const skattemeldingListe = tenorRelasjoner.skattemelding
const inntektListe = tenorRelasjoner.inntekt

if (
!data &&
(!tjenestepensjonavtaleListe || tjenestepensjonavtaleListe.length < 1) &&
!harDagligLederRolle &&
(!skattemeldingListe || skattemeldingListe.length < 1) &&
(!inntektListe || inntektListe.length < 1)
) {
return null
}

return (
<div style={{ marginTop: '15px' }}>
<div style={{ margin: '15px 0 20px 0' }}>
<div className="sub-overskrift" style={{ backgroundColor: '#4B797A', color: '#fff' }}>
<Icon fontSize={'1.5rem'} kind="tenor" />
<h3>Data fra Tenor</h3>
</div>
<h4 style={{ margin: '10px 0' }}>Enhetsregisteret og Foretaksregisteret</h4>
<div className="person-visning_content">
<TitleValue title="Roller" value="Daglig leder" />
</div>
<TjenestepensjonsavtaleVisning tpListe={tjenestepensjonavtaleListe} />
<BrregErFrVisning harDagligLederRolle={harDagligLederRolle} />
<SkattemeldingVisning skattemeldingListe={skattemeldingListe} />
<InntektVisning inntektListe={inntektListe} />
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import { codeToNorskLabel } from '@/utils/DataFormatter'
import Panel from '@/components/ui/panel/Panel'
import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import React from 'react'

export const Skattemelding = ({ skattemelding }: any) => {
return (
<>
<TitleValue title="Inntektsår" value={skattemelding.inntektsaar} />
<TitleValue
title="Type skattemelding"
value={codeToNorskLabel(skattemelding.skattemeldingstype)}
/>
</>
)
}

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

return (
<Panel heading="Skattemelding">
<div className="person-visning_content">
<DollyFieldArray data={skattemeldingListe} nested>
{(skattemelding: any) => {
return <Skattemelding skattemelding={skattemelding} />
}}
</DollyFieldArray>
</div>
</Panel>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Panel from '@/components/ui/panel/Panel'
import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import React from 'react'

export const Tjenestepensjonsavtale = ({ tjenestepensjonsavtale }: any) => {
return (
<>
<TitleValue title="Inntektsmottaker" value={tjenestepensjonsavtale?.inntektsmottaker} />
<TitleValue
title="Pensjonsinnretning"
value={tjenestepensjonsavtale?.pensjonsinnretningOrgnr}
/>
<TitleValue
title="Opplysningspliktig"
value={tjenestepensjonsavtale?.opplysningspliktigOrgnr}
/>
<TitleValue title="Periode" value={tjenestepensjonsavtale?.periode} />
</>
)
}

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

return (
<Panel heading="Tjenestepensjonsavtale">
<div className="person-visning_content">
<DollyFieldArray data={tpListe} nested>
{(tjenestepensjonsavtale: any) => {
return <Tjenestepensjonsavtale tjenestepensjonsavtale={tjenestepensjonsavtale} />
}}
</DollyFieldArray>
</div>
</Panel>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const P_FormDatepicker = ({ addHour = true, ...props }) => {
props.afterChange(date)
}
let val = fixTimezone(date)?.toISOString().substring(0, 19) || null
if (addHour) {
if (addHour && value instanceof Date) {
val = addHours(new Date(fixTimezone(date)), 3)
.toISOString()
.substring(0, 19)
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,10 +22,8 @@ export const Monthpicker = ({
date = null,
handleDateChange,
onChange,
isClearable = false,
minDate = null,
maxDate = null,
...props
}: MonthpickerProps) => {
const formMethods = useFormContext()
const val = formMethods.watch(name)
Expand All @@ -46,7 +44,7 @@ export const Monthpicker = ({
? date
: new Date(date)

const { monthpickerProps, inputProps } = useMonthpicker({
const { monthpickerProps, inputProps, reset } = useMonthpicker({
fromDate: minDate || subYears(new Date(), 125),
toDate: maxDate || addYears(new Date(), 5),
onMonthChange: (selectedDate) => {
Expand All @@ -60,6 +58,12 @@ export const Monthpicker = ({
: undefined,
})

useEffect(() => {
if (!val && inputProps.value) {
reset()
}
}, [val])

return (
<InputWrapper size={'small'}>
<Label name={name} label={label}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import {
ChatElipsisIcon,
CheckmarkCircleIcon,
ChevronDownIcon,
ChevronDownDoubleCircleIcon,
ChevronUpIcon,
ChevronUpDoubleCircleIcon,
EarthIcon,
EnvelopeClosedIcon,
EraserIcon,
Expand Down Expand Up @@ -102,6 +104,8 @@ export const icons = {
kryss: XMarkIcon,
'chevron-down': ChevronDownIcon,
'chevron-up': ChevronUpIcon,
'chevron-down-double-circle': ChevronDownDoubleCircleIcon,
'chevron-up-double-circle': ChevronUpDoubleCircleIcon,
'thumbs-up': ThumbUpFillIcon,
'thumbs-down': ThumbDownFillIcon,
lock: PadlockLockedIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import { SigrunstubPensjonsgivendeVisning } from '@/components/fagsystem/sigruns
import { useUdistub } from '@/utils/hooks/useUdistub'
import useBoolean from '@/utils/hooks/useBoolean'
import { MalModal, malTyper } from '@/pages/minSide/maler/MalModal'
import { useTenorOversikt } from '@/utils/hooks/useTenorSoek'
import { useTenorIdent } from '@/utils/hooks/useTenorSoek'
import { SkatteetatenVisning } from '@/components/fagsystem/skatteetaten/visning/SkatteetatenVisning'
import PdlVisningConnector from '@/components/fagsystem/pdl/visning/PdlVisningConnector'

Expand Down Expand Up @@ -234,9 +234,8 @@ export default ({
ident.ident,
)

const { response: tenorData, loading: loadingTenorData } = useTenorOversikt(
ident?.master === 'PDL' ? { identifikator: ident.ident } : null,
1,
const { person: tenorData, loading: loadingTenorData } = useTenorIdent(
ident?.master === 'PDL' ? ident.ident : null,
)

const getGruppeIdenter = () => {
Expand Down Expand Up @@ -529,7 +528,9 @@ export default ({
/>
<HistarkVisning data={histarkData} loading={loadingHistarkData} />
<SkatteetatenVisning
data={tenorData?.data?.data?.personer?.find((person: any) => person?.id === ident.ident)}
data={tenorData?.data?.data?.dokumentListe?.find((dokument: any) =>
dokument.identifikator?.includes(ident.ident),
)}
loading={loadingTenorData}
/>
<PersonMiljoeinfo
Expand Down
Loading
Loading