Skip to content

Commit 08e44d4

Browse files
committed
bruk LinkWithIngressMixin
1 parent 6a88fc9 commit 08e44d4

File tree

1 file changed

+34
-64
lines changed

1 file changed

+34
-64
lines changed

packages/nextjs/src/components/pages/contact-step-page/ContactStepPage.tsx

+34-64
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,21 @@ import { ParsedHtml } from 'components/_common/parsedHtml/ParsedHtml';
44
import { ContentType, ContentCommonProps } from 'types/content-props/_content-common';
55
import { IllustrationStatic } from 'components/_common/illustration/static/IllustrationStatic';
66
import { PictogramsProps } from 'types/content-props/pictograms';
7-
import { stripXpPathPrefix } from 'utils/urls';
87
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase';
98
import { LenkeInline } from 'components/_common/lenke/lenkeInline/LenkeInline';
9+
import { LinkWithIngressMixin } from 'types/component-props/_mixins';
1010
import style from './ContactStepPage.module.scss';
1111

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-
3212
export type ContactStepPageProps = ContentCommonProps & {
3313
type: ContentType.ContactStepPage;
3414
data: {
3515
title: string;
3616
illustration: PictogramsProps;
3717
textAboveTitle?: string;
3818
html: string;
39-
linksHeading: string;
40-
linksSubHeadline: string;
41-
links: LinkPanel[];
19+
linkPanelsHeading: string;
20+
linkPanelsSubHeading: string;
21+
linkPanels: LinkWithIngressMixin[];
4222
link: {
4323
internal: {
4424
target: { _path: string };
@@ -55,21 +35,12 @@ export const ContactStepPage = (props: ContactStepPageProps) => {
5535
illustration,
5636
textAboveTitle,
5737
html,
58-
links: linkPanels,
59-
linksHeading: linksPanelHeading,
60-
linksSubHeadline: linksPanelSubHeadline,
38+
linkPanelsHeading,
39+
linkPanelsSubHeading,
40+
linkPanels,
6141
link,
6242
} = data;
6343

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-
7344
return (
7445
<div className={style.contactStepPage}>
7546
<IllustrationStatic illustration={illustration} className={style.pictogram} />
@@ -86,40 +57,39 @@ export const ContactStepPage = (props: ContactStepPageProps) => {
8657
<div className={style.content}>
8758
<ParsedHtml htmlProps={html} />
8859

89-
{linksPanelHeading && (
60+
{linkPanelsHeading && (
9061
<Heading size="medium" level="2">
91-
{linksPanelHeading}
62+
{linkPanelsHeading}
9263
</Heading>
9364
)}
94-
{linksPanelSubHeadline && <BodyShort>{linksPanelSubHeadline}</BodyShort>}
65+
{linkPanelsSubHeading && <BodyShort>{linkPanelsSubHeading}</BodyShort>}
9566

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>
12090
</div>
12191
<div className={style.link}>
122-
<LenkeInline href={target._path}>{text}</LenkeInline>
92+
<LenkeInline href={link.internal.target._path}>{link.internal.text}</LenkeInline>
12393
</div>
12494
</div>
12595
);

0 commit comments

Comments
 (0)