Skip to content

Conversation

stigus
Copy link
Contributor

@stigus stigus commented Oct 17, 2025

Lagt til fritt adressefelt i kontaktadresser for å støtte gammelt format.

…e i fritt format' in address handling.

- Refactor address-related components to utilize new formats and improve readability.
- Update validation schemas to include new address formats.
- Enhance the Kontaktadresse component to display new address formats correctly.
#deploy-test-frontend
@stigus stigus requested a review from a team as a code owner October 17, 2025 07:38
@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 07:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Formålet med PR er å legge til støtte for kontaktadresser i fritt format (postadresse og utenlandsk adresse) ved å introdusere nye adressetyper og tilhørende datamodell, skjema- og visningslogikk samt test-selektorer.

  • Nye adressetyper og enum-verdier for fritt format er lagt til.
  • Skjemavalidering, initialverdier og visningskomponenter er oppdatert til å håndtere adresselinjer som liste.
  • Test-selektorer og panel-tilpasninger er utvidet for å støtte automatisert testing av de nye felt-typene.

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
SelectOptions.tsx La til nye adressetypevalg for fritt format.
PdlDataTyper.tsx Endret typer for fritt format til å bruke adresselinjer-array og eksporterte typene.
Panel.tsx La til støtte for videresending av ekstra props via rest-spread.
Kontaktadresse.tsx Refaktorerte logikk for adressetypehåndtering og la til nye komponenter for fritt format.
adresser.tsx Utvidet Yup-skjema og forbedret fradato-håndtering med sikrere indeksfjerning.
Kontaktadresse/Kontaktadresse.tsx Integrerte nye adressetypekomponenter og test-id attributter.
adressetyper/index.tsx Eksporterte nye adressetypekomponenter for fritt format.
UtenlandskAdresseIFrittFormat.tsx Ny komponent for utenlandsk adresse i fritt format.
PostadresseIFrittFormat.tsx Ny komponent for postadresse i fritt format.
initialValues.tsx Initialverdier lagt til for nye adressetyper i fritt format.
PdlTypes.tsx Nye enum-verdier for adressetyper i fritt format.
Adresse.tsx Panel og attributt utvidet med test-id for adresser.
BestillingKriterieMapper.tsx Viser og mapper nye fritt format adressetyper i bestillingsoppsummering.
Selectors.tsx Nye test-selektorer for adresser og adressetypevalg.
globalSetup.tsx Forbedret init-script typing ved å fjerne ts-ignore.
Comments suppressed due to low confidence (2)

apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/partials/adresser/kontaktadresse/Kontaktadresse.tsx:1

  • [nitpick] If-else kjeden kan forenkles ved å bruke en map fra string value til riktig Adressetype enum, f.eks. const enumMap: Record<string, Adressetype> = {...}; dette reduserer gjentakelse og gjør det enklere å utvide.
import React, { useContext, useEffect } from 'react'

apps/dolly-frontend/src/main/js/src/components/fagsystem/pdlf/form/validation/partials/adresser.tsx:1

  • Tidligere ville splice(null, 1) fjerne første element når ingen match fantes; guard på adresseIndex !== null forhindrer feilaktig fjerning. Endringen retter en konkret logisk feil.
import * as Yup from 'yup'

Comment on lines 177 to 178
{ value: 'POSTADRESSE_I_FRITT_FORMAT', label: 'Postadresse i fritt format' },
{ value: 'UTENLANDSK_ADRESSE_I_FRITT_FORMAT', label: 'Utenlandsk adresse i fritt format' },
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Disse label-verdiene er hardkodet i stedet for å bruke samme kodeverks-/adresseressurs som de øvrige (f.eks. adresser.vegadresse). For konsistens og enklere vedlikehold bør de hentes fra samme struktur som de andre adressetypene.

Copilot uses AI. Check for mistakes.

iconType = null as unknown as string,
forceOpen = false,
setPanelOpen = null,
...rest
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Det mangler en eksplisitt props-type som inkluderer HTMLDivElement-attributter; uten dette blir rest implicit any og svekker typesikkerhet. Foreslå å definere et interface og bruke React.HTMLAttributes for å typetilpasse ...rest.

Copilot uses AI. Check for mistakes.

Comment on lines +52 to +67
const adressetypeFieldMap: Record<string, string> = {
VEGADRESSE: 'vegadresse',
UTENLANDSK_ADRESSE: 'utenlandskAdresse',
POSTBOKSADRESSE: 'postboksadresse',
POSTADRESSE_I_FRITT_FORMAT: 'postadresseIFrittFormat',
UTENLANDSK_ADRESSE_I_FRITT_FORMAT: 'utenlandskAdresseIFrittFormat',
}

const adressetypeInitialMap: Record<string, any> = {
VEGADRESSE: initialVegadresse,
UTENLANDSK_ADRESSE: initialUtenlandskAdresse,
POSTBOKSADRESSE: initialPostboksadresse,
POSTADRESSE_I_FRITT_FORMAT: initialPostadresseIFrittFormat,
UTENLANDSK_ADRESSE_I_FRITT_FORMAT: initialUtenlandskAdresseIFrittFormat,
}

Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Bruk av Record<string, ...> og magic strings gjør det enklere å introdusere tastefeil og vanskeligere å endre enum-verdier. Anbefaler å typifisere nøklene med Adressetype og erstatte string-literalene med enum-referanser for typesikkerhet.

Copilot uses AI. Check for mistakes.

Comment on lines 33 to 56
return (
<div className="flexbox--flex-wrap">
<FormDollyFieldArray
name={`${path}.adresselinjer`}
header="Adresselinje"
newEntry=""
canBeEmpty={false}
handleNewEntry={handleNewEntry}
errorText={
showError ? 'Fyll inn gjeldende adresselinje før du legger til en ny' : undefined
}
>
{(linePath: string, idx: number) => (
<FormTextInput name={linePath} label={`Adresselinje ${idx + 1}`} />
)}
</FormDollyFieldArray>
<FormSelect
name={`${path}.postnummer`}
label="Postnummer"
kodeverk={AdresseKodeverk.Postnummer}
size="large"
/>
</div>
)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne komponenten dupliserer nesten identisk struktur og logikk med UtenlandskAdresseIFrittFormat. Vurder å abstrahere en felles fritt-format adressekomponent med props for feltspesifikke input-felter (f.eks. postnummer vs postkode/by/land) for å redusere duplisering og gjøre vedlikehold enklere.

Copilot generated this review using guidance from repository custom instructions.

Copy link
Contributor

@betsytraran betsytraran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ser supert ut, noen styling-greier bare 🤩


return (
<div className="flexbox--flex-wrap">
<FormDollyFieldArray
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hadde vært finere å hatt denne som nested kanskje? Samme for Utenlandsk adresse.

}
>
{(linePath: string, idx: number) => (
<FormTextInput name={linePath} label={`Adresselinje ${idx + 1}`} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siden dette er et fritekstfelt, og eneste felt på linja, hadde det vært nice om det var litt bredere? Samme for Utenlandsk adresse.


return (
<div className="flexbox--flex-wrap">
<FormDollyFieldArray
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ser også at array-feltet ikke fyller hele bredden, men det bør det gjøre (slik som utenlandsk adresse gjør).

- Update Attributt component to align checkbox items vertically
- Refactor PostadresseIFrittFormat and UtenlandskAdresseIFrittFormat to utilize FrittFormatAdresse for address input
- Enhance styling for better layout in dollyFieldArray.less

#deploy-test-frontend
… handling

- Update header from "Adresselinje" to "Adresselinjer" in FrittFormatAdresse
- Change size prop from "large" to "xlarge" for address type selection in Kontaktadresse
- Modify labels for historical address options in SelectOptions

#deploy-test-frontend
@stigus stigus merged commit 04f5e5a into master Oct 20, 2025
13 of 14 checks passed
@stigus stigus deleted the feature/dolly-fritt-format-post-utenland branch October 20, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants