File tree 3 files changed +13
-5
lines changed
skribenten-web/frontend/src
routes/saksnummer_/$saksId/brevvelger/-components/endreMottaker
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ const OppsummeringAvMottaker = (props: { saksId: string; mottaker: Nullable<Mott
32
32
</ BodyShort >
33
33
) }
34
34
{ props . mottaker . type === "UtenlandskAdresse" && (
35
- < BodyShort size = "small" > { getCountryNameByKode ( props . mottaker . landkode , landData ) } </ BodyShort >
35
+ < BodyShort size = "small" > { getCountryNameByKode ( props . mottaker . landkode , landData || [ ] ) } </ BodyShort >
36
36
) }
37
37
</ VStack >
38
38
) ;
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ const OppsummeringAvAdresse = (properties: { type: Nullable<string>; adresse: Ad
89
89
< InversedTableRow label = "Adresselinje 3" value = { properties . adresse . linje3 } />
90
90
< InversedTableRow label = "Postnummer" value = { properties . adresse . postnr } />
91
91
< InversedTableRow label = "Poststed" value = { properties . adresse . poststed } />
92
- < InversedTableRow label = "Land" value = { getCountryNameByKode ( properties . adresse . land , landData ) } />
92
+ < InversedTableRow label = "Land" value = { getCountryNameByKode ( properties . adresse . land , landData || [ ] ) } />
93
93
</ Table . Body >
94
94
</ Table >
95
95
) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,15 @@ type Land = {
7
7
/**
8
8
* Hent landnavn basert på landkode
9
9
*/
10
- export const getCountryNameByKode = ( kode : Nullable < string > , landData : Land [ ] | undefined ) : Nullable < string > => {
11
- const country = landData ?. find ( ( land ) => land . kode === kode ) ;
12
- return country ? country . navn : kode ;
10
+ export const getCountryNameByKode = ( kode : Nullable < string > , landData : Land [ ] ) : string => {
11
+ if ( ! Array . isArray ( landData ) ) {
12
+ return kode || "" ;
13
+ }
14
+
15
+ if ( landData ) {
16
+ const country = landData . find ( ( land ) => land . kode === kode ) ;
17
+ return country ? country . navn : kode || "" ;
18
+ }
19
+
20
+ return kode || "" ;
13
21
} ;
You can’t perform that action at this time.
0 commit comments