Skip to content

Commit

Permalink
fiks relativ import og hook i funksjon
Browse files Browse the repository at this point in the history
  • Loading branch information
bdahle committed May 10, 2024
1 parent 40a7318 commit a2723c2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/components/_common/section-navigation/SectionNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react';
import { ComponentType } from 'types/component-props/_component-common';
import { RegionProps } from 'types/component-props/layouts';
import { PartType } from 'types/component-props/parts';
import { translator } from 'translations';
import { Language, translator } from 'translations';
import { usePageContentProps } from 'store/pageContext';
import { AnalyticsEvents } from 'utils/amplitude';
import { LenkeInline } from 'components/_common/lenke/LenkeInline';
import { getAnchorId } from '../relatedSituations/RelatedSituations';
import { getAnchorId } from 'components/_common/relatedSituations/RelatedSituations';

import styles from './SectionNavigation.module.scss';

Expand All @@ -20,12 +20,11 @@ type Anchor = {
title: string;
};

const getAnchorsFromComponents = (region?: RegionProps) => {
const getAnchorsFromComponents = (language: Language, region?: RegionProps) => {
if (!region) {
return [];
}

const { language } = usePageContentProps();
const getStringPart = translator('related', language);
const otherOffersTitle = getStringPart('otherOffers');

Expand All @@ -47,19 +46,18 @@ const getAnchorsFromComponents = (region?: RegionProps) => {
component.descriptor === PartType.RelatedSituations
) {
acc.push({
anchorId: getAnchorId(otherOffersTitle),
anchorId: getAnchorId(otherOffersTitle) as string,
title: (component.config?.title || getStringPart('otherOffers')) as string,
});
}

return acc;
}, []);
};

export const SectionNavigation = ({ introRegion, contentRegion }: SectionNavigationProps) => {
const { language } = usePageContentProps();
const introAnchors = getAnchorsFromComponents(introRegion);
const contentAnchors = getAnchorsFromComponents(contentRegion);
const introAnchors = getAnchorsFromComponents(language, introRegion);
const contentAnchors = getAnchorsFromComponents(language, contentRegion);
const allAnchors = [...introAnchors, ...contentAnchors];

if (allAnchors.length === 0) {
Expand Down

0 comments on commit a2723c2

Please sign in to comment.