Skip to content

Commit

Permalink
Fix toggle mellom ny og eksisterende relatert person tom ny ident
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed Dec 3, 2024
1 parent 62cdfc3 commit 22bd3b0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,42 +134,7 @@ FamilierelasjonPanel.initialValues = ({ set, opts, del, has }: any) => {
label: 'Sivilstand (har partner)',
checked: has('pdldata.person.sivilstand'),
add() {
// set('pdldata.person.sivilstand', [getInitialSivilstand(initialMaster)])
//TODO: Settes tilbake naar ferdig med testing
set('pdldata.person.sivilstand', [
{
type: 'GIFT',
sivilstandsdato: '2010-11-08T00:00:00',
bekreftelsesdato: null,
borIkkeSammen: false,
nyRelatertPerson: {
identtype: 'FNR',
kjoenn: 'KVINNE',
foedtEtter: null,
foedtFoer: null,
alder: null,
syntetisk: true,
nyttNavn: {
hasMellomnavn: false,
},
statsborgerskapLandkode: 'MDA',
gradering: null,
},
kilde: 'Dolly',
master: 'FREG',
eksisterendePerson: false,
},
{
type: 'GIFT',
sivilstandsdato: '2020-11-10T00:00:00',
relatertVedSivilstand: '22488522675',
bekreftelsesdato: null,
borIkkeSammen: false,
kilde: 'Dolly',
master: 'FREG',
eksisterendePerson: true,
},
])
set('pdldata.person.sivilstand', [getInitialSivilstand(initialMaster)])
},
remove() {
del('pdldata.person.sivilstand')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ PersoninformasjonPanel.initialValues = ({ set, opts, setMulti, del, has }) => {
set('fullmakt', [
{
...initialFullmakt,
nyFullmektig: initialPdlPerson,
master: identMaster === 'PDL' || identtype === 'NPID' ? 'PDL' : 'FREG',
},
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const FullmaktForm = () => {
const fullmaktValues = formMethods.watch('fullmakt')
const opts: any = useContext(BestillingsveilederContext)
const val = formMethods.watch(fullmaktAttributter)
const { identtype, identMaster } = opts

if ((!fullmaktValues || fullmaktValues?.length === 0) && val.some((v) => v)) {
formMethods.setValue('fullmakt', [initialFullmakt])
Expand All @@ -207,7 +208,11 @@ export const FullmaktForm = () => {
<FormDollyFieldArray
name="fullmakt"
header="Fullmakt"
newEntry={initialFullmakt}
newEntry={{
...initialFullmakt,
nyFullmektig: initialPdlPerson,
master: identMaster === 'PDL' || identtype === 'NPID' ? 'PDL' : 'FREG',
}}
canBeEmpty={false}
>
{(path: string) => <Fullmakt formMethods={formMethods} path={path} opts={opts} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export const getInitialNyIdent = (master = 'FREG') => ({
nyttNavn: {
hasMellomnavn: false,
},
eksisterendePerson: false,
kilde: 'Dolly',
master: master,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,29 @@ export const NyIdent = ({ formMethods }: NyIdentForm) => {
obj[key] = formMethods.watch(path)[key]
return obj
}, {})
// console.log('nyIdentValg: ', nyIdentValg) //TODO - SLETT MEG

const initialNyIdent = {
...getInitialNyIdent(),
kilde: formMethods.watch(`${path}.kilde`),
master: formMethods.watch(`${path}.master`),
}

const initialEksisterendePerson = {
eksisterendeIdent: '',
kilde: formMethods.watch(`${path}.kilde`),
master: formMethods.watch(`${path}.master`),
}

console.log('initialNyIdent: ', initialNyIdent) //TODO - SLETT MEG
return (
<div className="flexbox--flex-wrap">
<PdlPersonExpander
path={path}
nyPersonPath={path}
eksisterendePersonPath={`${path}.eksisterendeIdent`}
initialNyIdent={initialNyIdent}
initialEksisterendePerson={initialEksisterendePerson}
label="NY IDENTITET"
formMethods={formMethods}
nyIdentValg={nyIdentValg}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const PdlPersonExpander = ({
eksisterendePersonPath,
fullmektigsNavnPath,
eksisterendeNyPerson = null,
initialNyIdent = null,
initialEksisterendePerson = null,
label,
formMethods,
nyIdentValg = null,
Expand All @@ -39,7 +41,7 @@ export const PdlPersonExpander = ({
setSkjulPersonValg()
}
}, [])

console.log('nyIdentValg: ', nyIdentValg) //TODO - SLETT MEG
return (
<div className="flexbox--full-width">
{toggleExpansion &&
Expand All @@ -62,6 +64,8 @@ export const PdlPersonExpander = ({
formMethods={formMethods}
nyIdentValg={nyIdentValg}
eksisterendeNyPerson={eksisterendeNyPerson}
initialNyIdent={initialNyIdent}
initialEksisterendePerson={initialEksisterendePerson}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@ export const PdlPersonForm = ({
formMethods,
nyIdentValg = null,
eksisterendeNyPerson = null,
initialNyIdent = null,
initialEksisterendePerson = null,
}: PdlPersonValues) => {
const { gruppeId } = useParams()
const gruppe = useAsync(async () => {
return await DollyApi.getGruppeById(gruppeId)
}, [])
// console.log('path: ', path) //TODO - SLETT MEG
// console.log('nyPersonPath: ', nyPersonPath) //TODO - SLETT MEG
// console.log('eksisterendePersonPath: ', eksisterendePersonPath) //TODO - SLETT MEG
// console.log('nyIdentValg: ', nyIdentValg) //TODO - SLETT MEG
console.log('eksisterendeNyPerson: ', eksisterendeNyPerson) //TODO - SLETT MEG

const getType = () => {
if (formMethods.watch(`${path}.eksisterendePerson`)) {
return PersonType.EKSISTERENDE_PERSON
}
const eksisterende = formMethods.watch(eksisterendePersonPath)
return eksisterende ? PersonType.EKSISTERENDE_PERSON : PersonType.NY_PERSON
}
Expand All @@ -71,32 +81,27 @@ export const PdlPersonForm = ({

const isTestnorgeIdent = opts?.identMaster === 'PDL'

const parentPath = path.substring(0, path.lastIndexOf('.'))

useEffect(() => {
setType(getType())
}, [formMethods.watch('pdldata.person.sivilstand')?.length])

// useEffect(() => {
// formMethods.setValue(nyPersonPath, type === PersonType.NY_PERSON ? initialPdlPerson : undefined)
// formMethods.setValue(
// eksisterendePersonPath,
// type === PersonType.EKSISTERENDE_PERSON ? eksisterendeNyPerson?.value : undefined,
// )
// if (path) {
// formMethods.setValue(`${path}.eksisterendePerson`, type === PersonType.EKSISTERENDE_PERSON)
// }
// formMethods.trigger()
// }, [type, path])
}, [formMethods.watch(parentPath)?.length])

//TODO: funker denne for alle tilfeller? F.eks. fullmakt?
const handleTypeChange = (value: string) => {
setType(value)
formMethods.setValue(
nyPersonPath,
value === PersonType.NY_PERSON ? initialPdlPerson : undefined,
)
formMethods.setValue(
eksisterendePersonPath,
value === PersonType.EKSISTERENDE_PERSON ? eksisterendeNyPerson?.value : undefined,
value === PersonType.NY_PERSON ? initialNyIdent || initialPdlPerson : undefined,
)
if (value === PersonType.EKSISTERENDE_PERSON && initialEksisterendePerson) {
formMethods.setValue(path, initialEksisterendePerson)
} else {
formMethods.setValue(
eksisterendePersonPath,
value === PersonType.EKSISTERENDE_PERSON ? eksisterendeNyPerson?.value : undefined,
)
}
if (path) {
formMethods.setValue(`${path}.eksisterendePerson`, value === PersonType.EKSISTERENDE_PERSON)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ const animateNedboer = (millimeterNedboer: number, nedBoerType: NEDBOER_TYPE) =>

export const Background = (props: any) => {
const { millimeterNedboer = 0, nedBoerType } = useWeatherFyrstikkAlleen()
const nedboer = animateNedboer(millimeterNedboer, nedBoerType)
const nedboer = isChristmas
? animateNedboer(millimeterNedboer, NEDBOER_TYPE.SNOW)
: animateNedboer(millimeterNedboer, nedBoerType)
return (
<>
{!isEaster && nedboer}
Expand Down

0 comments on commit 22bd3b0

Please sign in to comment.