Skip to content

Commit

Permalink
Fikset oppholdsadresse
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed May 6, 2024
1 parent be2d049 commit be9ea24
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const PdlVisning = ({
const pdlfPerson = fagsystemData?.pdlforvalter?.person
const identtype = pdlfPerson?.identtype
const tmpPdlforvalter = tmpPersoner?.pdlforvalter
console.log('pdlfPerson: ', pdlfPerson) //TODO - SLETT MEG

return (
<ErrorBoundary>
<div className={miljoeVisning ? 'boks' : ''}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@/components/fagsystem/pdlf/visning/partials/Oppholdsadresse'
import { OppholdsadresseData } from '@/pages/gruppe/PersonVisning/PersonMiljoeinfo/PdlDataTyper'
import { ArrayHistorikk } from '@/components/ui/historikk/ArrayHistorikk'
import _ from 'lodash'

type PdlOppholdsadresseProps = {
data: Array<OppholdsadresseData>
Expand All @@ -18,6 +19,7 @@ type AdresseProps = {
data: OppholdsadresseData
idx?: number
alleData?: Array<OppholdsadresseData>
tmpData?: any
tmpPersoner?: any
ident?: string
identtype?: string
Expand All @@ -36,6 +38,7 @@ const AdresseVisningRedigerbar = ({
data,
idx,
alleData,
tmpData,
tmpPersoner,
ident,
identtype,
Expand All @@ -47,6 +50,7 @@ const AdresseVisningRedigerbar = ({
oppholdsadresseData={data}
idx={idx}
data={alleData}
tmpData={tmpData}
tmpPersoner={tmpPersoner}
ident={ident}
erPdlVisning={false}
Expand All @@ -68,6 +72,11 @@ export const PdlOppholdsadresse = ({
return null
}

const tmpData = _.get(tmpPersoner, `${ident}.person.oppholdsadresse`)
if ((!data || data.length === 0) && (!tmpData || tmpData.length < 1)) {
return null
}

const gyldigeAdresser = data.filter(
(adresse: OppholdsadresseData) => !adresse.metadata?.historisk,
)
Expand All @@ -84,6 +93,7 @@ export const PdlOppholdsadresse = ({
data={gyldigeAdresser}
pdlfData={pdlfData}
historiskData={historiskeAdresser}
tmpData={tmpData}
tmpPersoner={tmpPersoner}
ident={ident}
identtype={identtype}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type OppholdsadresseVisningTypes = {
oppholdsadresseData: any
idx: number
data: Array<any>
tmpData: any
tmpPersoner: Array<OppholdsadresseData>
ident: string
erPdlVisning: boolean
Expand Down Expand Up @@ -58,13 +59,17 @@ export const OppholdsadresseVisning = ({
oppholdsadresseData,
idx,
data,
tmpData,
tmpPersoner,
ident,
erPdlVisning,
identtype,
master,
}: OppholdsadresseVisningTypes) => {
const initOppholdsadresse = Object.assign(_.cloneDeep(getInitialOppholdsadresse()), data[idx])
const initOppholdsadresse = Object.assign(
_.cloneDeep(getInitialOppholdsadresse()),
data[idx] || tmpData?.[idx],
)
const initialValues = { oppholdsadresse: initOppholdsadresse }

const redigertOppholdsadressePdlf = _.get(tmpPersoner, `${ident}.person.oppholdsadresse`)?.find(
Expand Down Expand Up @@ -109,7 +114,12 @@ export const Oppholdsadresse = ({
identtype,
erRedigerbar = true,
}: OppholdsadresseTypes) => {
if (!data || data.length === 0) {
if ((!data || data.length === 0) && (!tmpPersoner || Object.keys(tmpPersoner).length < 1)) {
return null
}

const tmpData = _.get(tmpPersoner, `${ident}.person.oppholdsadresse`)
if ((!data || data.length === 0) && (!tmpData || tmpData.length < 1)) {
return null
}

Expand All @@ -118,13 +128,14 @@ export const Oppholdsadresse = ({
<SubOverskrift label="Oppholdsadresse" iconKind="adresse" />
<div className="person-visning_content">
<ErrorBoundary>
<DollyFieldArray data={data} header="" nested>
<DollyFieldArray data={data || tmpData} header="" nested>
{(adresse: any, idx: number) =>
erRedigerbar ? (
<OppholdsadresseVisning
oppholdsadresseData={adresse}
idx={idx}
data={data}
tmpData={tmpData}
tmpPersoner={tmpPersoner}
ident={ident}
erPdlVisning={erPdlVisning}
Expand Down

0 comments on commit be9ea24

Please sign in to comment.