From 22bd3b0b22bc1cd8399c2a2b10c5cdac250477cc Mon Sep 17 00:00:00 2001 From: Betsy Carina Traran Date: Tue, 3 Dec 2024 12:37:36 +0100 Subject: [PATCH] Fix toggle mellom ny og eksisterende relatert person tom ny ident --- .../steg/steg1/paneler/Familierelasjoner.tsx | 37 +---------------- .../steg/steg1/paneler/Personinformasjon.tsx | 1 + .../fagsystem/fullmakt/form/FullmaktForm.tsx | 7 +++- .../fagsystem/pdlf/form/initialValues.tsx | 1 + .../pdlf/form/partials/nyIdent/nyIdent.tsx | 16 ++++++++ .../partials/pdlPerson/PdlPersonExpander.tsx | 6 ++- .../form/partials/pdlPerson/PdlPersonForm.tsx | 41 +++++++++++-------- .../components/ui/background/Background.tsx | 4 +- 8 files changed, 56 insertions(+), 57 deletions(-) diff --git a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Familierelasjoner.tsx b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Familierelasjoner.tsx index 8585d017e9..3c87df4f91 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Familierelasjoner.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Familierelasjoner.tsx @@ -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') diff --git a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Personinformasjon.tsx b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Personinformasjon.tsx index f5d0c7d107..27cd4af4c8 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Personinformasjon.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Personinformasjon.tsx @@ -404,6 +404,7 @@ PersoninformasjonPanel.initialValues = ({ set, opts, setMulti, del, has }) => { set('fullmakt', [ { ...initialFullmakt, + nyFullmektig: initialPdlPerson, master: identMaster === 'PDL' || identtype === 'NPID' ? 'PDL' : 'FREG', }, ]) diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/fullmakt/form/FullmaktForm.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/fullmakt/form/FullmaktForm.tsx index 11895dcebc..253308ecbe 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/fullmakt/form/FullmaktForm.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/fullmakt/form/FullmaktForm.tsx @@ -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]) @@ -207,7 +208,11 @@ export const FullmaktForm = () => { {(path: string) => } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/initialValues.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/initialValues.tsx index 3d41db54fa..0afb1d0274 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/initialValues.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/initialValues.tsx @@ -347,6 +347,7 @@ export const getInitialNyIdent = (master = 'FREG') => ({ nyttNavn: { hasMellomnavn: false, }, + eksisterendePerson: false, kilde: 'Dolly', master: master, }) diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/nyIdent/nyIdent.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/nyIdent/nyIdent.tsx index b1ce98a163..779f925922 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/nyIdent/nyIdent.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/nyIdent/nyIdent.tsx @@ -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 (
{toggleExpansion && @@ -62,6 +64,8 @@ export const PdlPersonExpander = ({ formMethods={formMethods} nyIdentValg={nyIdentValg} eksisterendeNyPerson={eksisterendeNyPerson} + initialNyIdent={initialNyIdent} + initialEksisterendePerson={initialEksisterendePerson} /> )}
diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/pdlPerson/PdlPersonForm.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/pdlPerson/PdlPersonForm.tsx index 6e0b8be8c7..3b4ec21aeb 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/pdlPerson/PdlPersonForm.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/pdlPerson/PdlPersonForm.tsx @@ -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 } @@ -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) } diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/background/Background.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/background/Background.tsx index 66365607f4..dec5bce3e5 100644 --- a/apps/dolly-frontend/src/main/js/src/components/ui/background/Background.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/ui/background/Background.tsx @@ -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}