Skip to content

Commit

Permalink
* Refaktor av fullmakt for gamle bestillinger og ferdigstilt oppsett …
Browse files Browse the repository at this point in the history
…for nye fullmakt frontend
  • Loading branch information
stigus committed Oct 16, 2024
1 parent aca6e70 commit 3ce440e
Show file tree
Hide file tree
Showing 20 changed files with 2,262 additions and 631 deletions.
2,446 changes: 2,118 additions & 328 deletions apps/dolly-frontend/src/main/js/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ const mapFullmakt = (bestillingData, data) => {
const fullmaktData = {
header: 'Fullmakt',
itemRows: bestillingData.fullmakt.map((item, idx) => {
console.log('item: ', item) //TODO - SLETT MEG
return [
{ numberHeader: `Fullmakt ${idx + 1}` },
obj('Områder', omraaderArrayToString(item.omraade)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type FullmaktTypes = {
export type FullmaktType = {
gyldigFraOgMed: string
gyldigTilOgMed?: string
fullmaktsgiver: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import Panel from '@/components/ui/panel/Panel'
import { erForsteEllerTest, panelError } from '@/components/ui/form/formUtils'
import { useFormContext } from 'react-hook-form'
import { useFullmaktOmraader } from '@/utils/hooks/useFullmakt'
import { Omraade } from '@/components/fagsystem/fullmakt/FullmaktTypes'
import { Omraade } from '@/components/fagsystem/fullmakt/FullmaktType'
import { Option } from '@/service/SelectOptionsOppslag'
import Loading from '@/components/ui/loading/Loading'
import { ErrorMessage } from '@hookform/error-message'

interface FullmaktProps {
formMethods: UseFormReturn
Expand Down Expand Up @@ -120,7 +121,7 @@ export const Fullmakt = ({
<div className="flexbox--flex-wrap">
<FormDollyFieldArray
name={`${path}.omraade`}
header="Områder"
header="Område"
newEntry={{ tema: '', handling: [] }}
>
{(path: string) => (
Expand All @@ -135,22 +136,23 @@ export const Fullmakt = ({
options={omraadeKodeverk.filter(
(option: Option) => !chosenTemaValues.includes(option.value),
)}
size="xlarge"
size="grow"
isClearable={false}
normalFontPlaceholder={true}
/>
<FormSelect
name={`${path}.handling`}
label="Handling"
options={Options('fullmaktHandling')}
size="grow"
size="xlarge"
onChange={(val: Option[]) => {
formMethods.setValue(
`${path}.handling`,
val?.some((opt) => opt.value?.includes('*'))
? alleHandlinger
: val.map((opt) => opt.value),
)
formMethods.trigger(path)
}}
isClearable={true}
isMulti={true}
Expand All @@ -163,14 +165,24 @@ export const Fullmakt = ({
<PdlPersonExpander
path={path}
nyPersonPath={`${path}.nyFullmektig`}
eksisterendePersonPath={`${path}.motpartsPersonident`}
eksisterendePersonPath={`${path}.fullmektig`}
fullmektigsNavnPath={`${path}.fullmektigsNavn`}
label={'FULLMEKTIG'}
formMethods={formMethods}
isExpanded={isTestnorgeIdent || !!formMethods.watch(`${path}.motpartsPersonident`)}
isExpanded={isTestnorgeIdent || !!formMethods.watch(`${path}.fullmektig`)}
toggleExpansion={!isTestnorgeIdent}
eksisterendeNyPerson={eksisterendeNyPerson}
/>
<AvansertForm path={path} kanVelgeMaster={false} />
{formMethods.formState.errors && (
<ErrorMessage
name={`${path}.omraade`}
errors={formMethods.formState.errors}
render={({ message }) => (
<p style={{ color: '#ba3a26', fontStyle: 'italic' }}>{message}</p>
)}
/>
)}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import { formatDate, oversettBoolean } from '@/utils/DataFormatter'
import { FullmaktType } from '@/components/fagsystem/fullmakt/FullmaktType'
import { Fragment } from 'react'

type FullmaktProps = {
idx: number
fullmakt: FullmaktType
}

export const Fullmakt = ({ fullmakt, idx }: FullmaktProps) => {
return (
<Fragment key={idx}>
<TitleValue title="Fullmektig" value={fullmakt?.fullmektig} />
<TitleValue title="Fullmektigs navn" value={fullmakt?.fullmektigsNavn} />
<TitleValue title="Gyldig fra" value={formatDate(fullmakt?.gyldigFraOgMed)} />
<TitleValue title="Gyldig til" value={formatDate(fullmakt?.gyldigTilOgMed)} />
{fullmakt?.omraade?.map((omraade, index) => (
<TitleValue key={index} title={omraade?.tema} value={omraade?.handling.join(', ')} />
))}
<TitleValue
title="Registrert"
value={fullmakt?.registrert && formatDate(fullmakt.registrert)}
/>
<TitleValue title="Kilde" value={fullmakt?.kilde} />
<TitleValue title="Opphørt" value={oversettBoolean(fullmakt?.opphoert)} />
</Fragment>
)
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import { formatDate, oversettBoolean } from '@/utils/DataFormatter'
import { FullmaktTypes } from '@/components/fagsystem/fullmakt/FullmaktTypes'
import { FullmaktType } from '@/components/fagsystem/fullmakt/FullmaktType'
import { useFullmektig } from '@/utils/hooks/useFullmakt'
import React, { useEffect, useState } from 'react'
import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import { Fullmakt } from '@/components/fagsystem/fullmakt/visning/Fullmakt'
import { ErrorBoundary } from '@/components/ui/appError/ErrorBoundary'
import SubOverskrift from '@/components/ui/subOverskrift/SubOverskrift'

type FullmaktProps = {
ident: string
data: FullmaktTypes
}

export const FullmaktVisning = ({ ident, data }: FullmaktProps) => {
export const FullmaktVisning = ({ ident }: FullmaktProps) => {
const { fullmektig } = useFullmektig(ident)
if (!data?.fullmaktsgiver && fullmektig?.size === 0) {
const [fullmaktData, setFullmaktData] = useState([])

useEffect(() => {
if (fullmektig?.length > 0) {
setFullmaktData(fullmektig)
}
}, [fullmektig])

if (!fullmektig || fullmektig.length === 0) {
return null
}
console.log('fullmektig: ', fullmektig) //TODO - SLETT MEG

return (
<>
<TitleValue title="Fullmaktsgiver" value={data?.fullmaktsgiver} />
<TitleValue title="Gyldig fra" value={formatDate(data?.gyldigFraOgMed)} />
<TitleValue title="Gyldig til" value={formatDate(data?.gyldigTilOgMed)} />
{data?.omraade?.map((omraade, index) => (
<TitleValue key={index} title={omraade.tema} value={omraade.handling.join(', ')} />
))}
<TitleValue title="Registrert" value={data?.registrert && formatDate(data.registrert)} />
<TitleValue title="Kilde" value={data?.kilde} />
<TitleValue title="Opphørt" value={oversettBoolean(data?.opphoert)} />
</>
<ErrorBoundary>
<div>
<SubOverskrift label="Fullmakt" iconKind="fullmakt" />
<div className="person-visning_content">
<DollyFieldArray data={fullmaktData} header="" nested>
{(item: FullmaktType, idx: number) => <Fullmakt fullmakt={item} idx={idx} />}
</DollyFieldArray>
</div>
</div>
</ErrorBoundary>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import { TpsfVisning } from '@/components/fagsystem/tpsf/visning/Visning'
import { DokarkivVisning } from '@/components/fagsystem/dokarkiv/visning'
import { HistarkVisning } from '@/components/fagsystem/histark/visning'
import { SykemeldingVisning } from '@/components/fagsystem/sykdom/visning/Visning'
import { FullmaktVisning } from './fullmakt/visning/FullmaktVisning'

export {
TpsfVisning,
KrrVisning,
PdlfVisning,
FullmaktVisning,
ArenaVisning,
AaregVisning,
UdiVisning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { PdlPersonInfo } from '@/components/fagsystem/pdl/visning/partials/PdlPe
import { IdentInfo } from '@/components/fagsystem/pdlf/visning/partials/Identinfo'
import { GeografiskTilknytning } from '@/components/fagsystem/pdlf/visning/partials/GeografiskTilknytning'
import { PdlNasjonalitet } from '@/components/fagsystem/pdl/visning/partials/nasjonalitet/PdlNasjonalitet'
import { PdlFullmakt } from '@/components/fagsystem/pdl/visning/partials/PdlFullmakt'
import { PdlSikkerhetstiltak } from '@/components/fagsystem/pdl/visning/partials/PdlSikkerhetstiltak'
import { PdlData } from '@/pages/gruppe/PersonVisning/PersonMiljoeinfo/PdlDataTyper'
import { TilrettelagtKommunikasjon } from '@/components/fagsystem/pdlf/visning/partials/TilrettelagtKommunikasjon'
Expand All @@ -24,6 +23,8 @@ import { PdlDeltBosted } from '@/components/fagsystem/pdl/visning/partials/adres
import { Doedsfall } from '@/components/fagsystem/pdlf/visning/partials/Doedsfall'
import { PdlVergemaal } from '@/components/fagsystem/pdl/visning/partials/vergemaal/PdlVergemaal'
import { getBankkontoData } from '@/components/fagsystem/pdlf/visning/PdlfVisning'
import { FullmaktVisning } from '@/components/fagsystem'
import React from 'react'

type PdlVisningProps = {
pdlData: PdlData
Expand Down Expand Up @@ -58,7 +59,6 @@ export const PdlVisning = ({
opphold,
kontaktadresse,
adressebeskyttelse,
fullmakt,
utenlandskIdentifikasjonsnummer,
falskIdentitet,
sikkerhetstiltak,
Expand All @@ -72,6 +72,10 @@ export const PdlVisning = ({
const identtype = pdlfPerson?.identtype
const tmpPdlforvalter = tmpPersoner?.pdlforvalter

const gjeldendeIdent = hentIdenter?.identer?.find(
(id) => !id.historisk && id.gruppe === 'FOLKEREGISTERIDENT',
)

return (
<ErrorBoundary>
<div className={miljoeVisning ? 'boks' : ''}>
Expand All @@ -80,14 +84,14 @@ export const PdlVisning = ({
tpsMessagingData={fagsystemData?.tpsMessaging}
tpsMessagingLoading={loading?.tpsMessaging}
/>
<FullmaktVisning ident={gjeldendeIdent?.ident} />
<IdentInfo pdlResponse={hentIdenter} />
<Foedsel data={hentPerson} erPdlVisning />
<Doedsfall data={doedsfall} erPdlVisning />
<GeografiskTilknytning data={hentGeografiskTilknytning} />
<PdlNasjonalitet data={hentPerson} />
<Telefonnummer data={telefonnummer} erPdlVisning />
<PdlVergemaal data={vergemaalEllerFremtidsfullmakt} />
<PdlFullmakt data={fullmakt} />
<PdlSikkerhetstiltak data={sikkerhetstiltak} />
<TilrettelagtKommunikasjon data={tilrettelagtKommunikasjon} />
<TpsMBankkonto
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export const getInitialNyIdent = (master = 'FREG') => ({

export const initialFullmakt = {
omraade: [{ tema: '', handling: [] }] as any,
gyldigFraOgMed: null as unknown as string,
gyldigFraOgMed: new Date(),
gyldigTilOgMed: null as unknown as string,
fullmektig: null as unknown as string,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { usePdlOptions } from '@/utils/hooks/useSelectOptions'
interface PdlEksisterendePersonValues {
nyPersonPath?: string
eksisterendePersonPath: string
fullmektigsNavnPath?: string
label: string
formMethods: UseFormReturn
idx: number
Expand All @@ -29,11 +30,12 @@ export const PdlEksisterendePerson = ({
formMethods,
idx,
disabled = false,
nyIdentValg = null,
eksisterendeNyPerson = null,
nyIdentValg = null as unknown as NyIdent,
eksisterendeNyPerson = null as unknown as Option,
fullmektigsNavnPath = null as unknown as string,
ident,
}: PdlEksisterendePersonValues) => {
const opts = useContext(BestillingsveilederContext)
const opts: any = useContext(BestillingsveilederContext)

const antall = opts?.antall || 1
const gruppeId = opts?.gruppeId || opts?.gruppe?.id || window.location.pathname.split('/')?.[2]
Expand Down Expand Up @@ -169,7 +171,11 @@ export const PdlEksisterendePerson = ({
<FormSelect
name={eksisterendePersonPath}
onChange={(person) => {
const navn = person?.label?.match(/-\s(.*?)\s\(/)
formMethods.setValue(eksisterendePersonPath, person?.value || null)
if (fullmektigsNavnPath) {
formMethods.setValue(fullmektigsNavnPath, navn?.[1] || person?.label || null)
}
formMethods.trigger('pdldata.person')
}}
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface PdlPersonValues {
path: string
nyPersonPath: string
eksisterendePersonPath: string
fullmektigsNavnPath?: string
eksisterendeNyPerson?: Option
label: string
formMethods: UseFormReturn
Expand All @@ -22,6 +23,7 @@ export const PdlPersonExpander = ({
path,
nyPersonPath,
eksisterendePersonPath,
fullmektigsNavnPath,
eksisterendeNyPerson = null,
label,
formMethods,
Expand Down Expand Up @@ -55,6 +57,7 @@ export const PdlPersonExpander = ({
path={path}
nyPersonPath={nyPersonPath}
eksisterendePersonPath={eksisterendePersonPath}
fullmektigsNavnPath={fullmektigsNavnPath}
label={label}
formMethods={formMethods}
nyIdentValg={nyIdentValg}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface PdlPersonValues {
path: string
nyPersonPath: string
eksisterendePersonPath: string
fullmektigsNavnPath?: string
label: string
formMethods: UseFormReturn
nyIdentValg?: NyIdent
Expand Down Expand Up @@ -46,6 +47,7 @@ export const PdlPersonForm = ({
path,
nyPersonPath,
eksisterendePersonPath,
fullmektigsNavnPath,
label,
formMethods,
nyIdentValg = null,
Expand Down Expand Up @@ -131,6 +133,7 @@ export const PdlPersonForm = ({
formMethods={formMethods}
nyIdentValg={nyIdentValg}
eksisterendeNyPerson={eksisterendeNyPerson}
fullmektigsNavnPath={fullmektigsNavnPath}
disabled={opts?.antall > 1}
/>
)}
Expand Down
Loading

0 comments on commit 3ce440e

Please sign in to comment.