-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/dolly fritt format post utenland #3982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…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.
There was a problem hiding this 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'
{ value: 'POSTADRESSE_I_FRITT_FORMAT', label: 'Postadresse i fritt format' }, | ||
{ value: 'UTENLANDSK_ADRESSE_I_FRITT_FORMAT', label: 'Utenlandsk adresse i fritt format' }, |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
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 |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
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.
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, | ||
} | ||
|
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
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.
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> | ||
) |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
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.
...ponents/fagsystem/pdlf/form/partials/adresser/adressetyper/UtenlandskAdresseIFrittFormat.tsx
Show resolved
Hide resolved
#deploy-test-frontend
There was a problem hiding this 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 |
There was a problem hiding this comment.
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}`} /> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Lagt til fritt adressefelt i kontaktadresser for å støtte gammelt format.