@@ -4,41 +4,21 @@ import { ParsedHtml } from 'components/_common/parsedHtml/ParsedHtml';
4
4
import { ContentType , ContentCommonProps } from 'types/content-props/_content-common' ;
5
5
import { IllustrationStatic } from 'components/_common/illustration/static/IllustrationStatic' ;
6
6
import { PictogramsProps } from 'types/content-props/pictograms' ;
7
- import { stripXpPathPrefix } from 'utils/urls' ;
8
7
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase' ;
9
8
import { LenkeInline } from 'components/_common/lenke/lenkeInline/LenkeInline' ;
9
+ import { LinkWithIngressMixin } from 'types/component-props/_mixins' ;
10
10
import style from './ContactStepPage.module.scss' ;
11
11
12
- export type LinkInternal = {
13
- external ?: never ;
14
- internal : { internalContent : Pick < ContentCommonProps , '_path' > } ;
15
- _selected : 'internal' ;
16
- } ;
17
-
18
- export type LinkExternal = {
19
- external : { externalUrl : string } ;
20
- internal ?: never ;
21
- _selected : 'external' ;
22
- } ;
23
-
24
- export type Link = LinkInternal | LinkExternal ;
25
-
26
- export interface LinkPanel {
27
- label : string ;
28
- explanation ?: string ;
29
- link : Link ;
30
- }
31
-
32
12
export type ContactStepPageProps = ContentCommonProps & {
33
13
type : ContentType . ContactStepPage ;
34
14
data : {
35
15
title : string ;
36
16
illustration : PictogramsProps ;
37
17
textAboveTitle ?: string ;
38
18
html : string ;
39
- linksHeading : string ;
40
- linksSubHeadline : string ;
41
- links : LinkPanel [ ] ;
19
+ linkPanelsHeading : string ;
20
+ linkPanelsSubHeading : string ;
21
+ linkPanels : LinkWithIngressMixin [ ] ;
42
22
link : {
43
23
internal : {
44
24
target : { _path : string } ;
@@ -55,21 +35,12 @@ export const ContactStepPage = (props: ContactStepPageProps) => {
55
35
illustration,
56
36
textAboveTitle,
57
37
html,
58
- links : linkPanels ,
59
- linksHeading : linksPanelHeading ,
60
- linksSubHeadline : linksPanelSubHeadline ,
38
+ linkPanelsHeading ,
39
+ linkPanelsSubHeading ,
40
+ linkPanels ,
61
41
link,
62
42
} = data ;
63
43
64
- const getHref = ( link : Link ) => {
65
- if ( link . _selected === 'internal' ) {
66
- return stripXpPathPrefix ( link . internal ?. internalContent . _path ) ;
67
- }
68
- return link . external . externalUrl ;
69
- } ;
70
-
71
- const { target, text } = link . internal ;
72
-
73
44
return (
74
45
< div className = { style . contactStepPage } >
75
46
< IllustrationStatic illustration = { illustration } className = { style . pictogram } />
@@ -86,40 +57,39 @@ export const ContactStepPage = (props: ContactStepPageProps) => {
86
57
< div className = { style . content } >
87
58
< ParsedHtml htmlProps = { html } />
88
59
89
- { linksPanelHeading && (
60
+ { linkPanelsHeading && (
90
61
< Heading size = "medium" level = "2" >
91
- { linksPanelHeading }
62
+ { linkPanelsHeading }
92
63
</ Heading >
93
64
) }
94
- { linksPanelSubHeadline && < BodyShort > { linksPanelSubHeadline } </ BodyShort > }
65
+ { linkPanelsSubHeading && < BodyShort > { linkPanelsSubHeading } </ BodyShort > }
95
66
96
- { linkPanels && linkPanels . length > 0 && (
97
- < ul className = { style . linkPanels } >
98
- { linkPanels . map ( ( linkPanel , index ) => (
99
- < li key = { index } >
100
- < LinkPanel
101
- as = { LenkeBase }
102
- href = { getHref ( linkPanel . link ) }
103
- className = { style . linkPanel }
104
- // TODO finn utav analytics
105
- // analyticsComponent={'mellomsteg'}
106
- // analyticsLinkGroup={currentStepData.stepsHeadline}
107
- // analyticsLabel={step.label}s
108
- >
109
- < LinkPanel . Title > { linkPanel . label } </ LinkPanel . Title >
110
- { linkPanel . explanation && (
111
- < LinkPanel . Description >
112
- { linkPanel . explanation }
113
- </ LinkPanel . Description >
114
- ) }
115
- </ LinkPanel >
116
- </ li >
117
- ) ) }
118
- </ ul >
119
- ) }
67
+ < ul className = { style . linkPanels } >
68
+ { linkPanels . map ( ( linkPanel , index ) => (
69
+ < li key = { index } >
70
+ < LinkPanel
71
+ as = { LenkeBase }
72
+ //TODO finn utav ekstern lenke
73
+ href = { linkPanel . link . internal . target . _path }
74
+ className = { style . linkPanel }
75
+ // TODO finn utav analytics
76
+ // analyticsComponent={'mellomsteg'}
77
+ // analyticsLinkGroup={currentStepData.stepsHeadline}
78
+ // analyticsLabel={step.label}s
79
+ >
80
+ < LinkPanel . Title > { linkPanel . link . internal . text } </ LinkPanel . Title >
81
+ { linkPanel . ingress && (
82
+ < LinkPanel . Description >
83
+ { linkPanel . ingress }
84
+ </ LinkPanel . Description >
85
+ ) }
86
+ </ LinkPanel >
87
+ </ li >
88
+ ) ) }
89
+ </ ul >
120
90
</ div >
121
91
< div className = { style . link } >
122
- < LenkeInline href = { target . _path } > { text } </ LenkeInline >
92
+ < LenkeInline href = { link . internal . target . _path } > { link . internal . text } </ LenkeInline >
123
93
</ div >
124
94
</ div >
125
95
) ;
0 commit comments