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