Skip to content

Commit

Permalink
Merge pull request #1781 from navikt/sla-sammen-lokalkontor-og-kontor…
Browse files Browse the repository at this point in the history
…sider

Slå sammen lokalkontor og kontorsider
  • Loading branch information
terjeofnorway authored Jul 15, 2024
2 parents 2e8af32 + 14aa655 commit 933bc8e
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 86 deletions.
2 changes: 0 additions & 2 deletions src/components/ContentMapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { SituationPage } from './pages/situation-page/SituationPage';
import { GuidePage } from './pages/guide-page/GuidePage';
import { OverviewPage } from './pages/overview-page/OverviewPage';
import { OfficeEditorialPage } from './pages/office-editorial-page/OfficeEditorialPage';
import { OfficeBranchPage } from './pages/office-branch-page/OfficeBranchPage';
import { ThemedArticlePage } from './pages/themed-article-page/ThemedArticlePage';
import { ProductPage } from './pages/product-page/ProductPage';
import { ProductDetailsPage } from './pages/product-details-page/ProductDetailsPage';
Expand Down Expand Up @@ -53,7 +52,6 @@ const contentToReactComponent: {
[ContentType.Overview]: OverviewPage,
[ContentType.GenericPage]: GenericPage,
[ContentType.OfficeEditorialPage]: OfficeEditorialPage,
[ContentType.OfficeBranchPage]: OfficeBranchPage,
[ContentType.OfficePage]: OfficePage,
[ContentType.CurrentTopicPage]: CurrentTopicPage,
[ContentType.PressLandingPage]: PressLandingPage,
Expand Down

This file was deleted.

29 changes: 0 additions & 29 deletions src/components/pages/office-branch-page/OfficeBranchPage.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/pages/office-page/OfficePage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$margin: 2rem;

.officeBranchPage {
.officePage {
display: flex;
flex-direction: column;
}
Expand Down
23 changes: 19 additions & 4 deletions src/components/pages/office-page/OfficePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,38 @@ import React from 'react';
import { ComponentMapper } from 'components/ComponentMapper';
import { OfficePageProps } from 'types/content-props/dynamic-page-props';
import { classNames } from 'utils/classnames';
import { logger } from 'srcCommon/logger';

import { OfficePageHeader } from 'components/pages/office-branch-page/office-page-header/OfficePageHeader';
import { OfficeDetails } from 'components/pages/office-branch-page/office-details/OfficeDetails';
import { OfficePageHeader } from 'components/pages/office-page/office-page-header/OfficePageHeader';
import { OfficeDetails } from 'components/pages/office-page/office-details/OfficeDetails';

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

export const OfficePage = (props: OfficePageProps) => {
const officeNorgData = props.data.officeNorgData.data;
const isOfficeBranch = officeNorgData.type === 'LOKAL';
const editorialPage = props.editorial;

if (!officeNorgData) {
logger.error('No office data exists for this office page');
return null;
}

if (isOfficeBranch && !editorialPage) {
logger.error(`No editorial page found for office branch ${props.displayName}`);
return null;
}

const page = isOfficeBranch && editorialPage ? editorialPage.page : props.page;

return (
<div className={styles.officeBranchPage}>
<div className={styles.officePage}>
{officeNorgData && (
<OfficePageHeader officeDetails={officeNorgData} showTimeStamp={false} />
)}
{officeNorgData && <OfficeDetails officeData={officeNorgData} />}
<div className={classNames(styles.content, styles.pageContent)}>
<ComponentMapper componentProps={props.page} pageProps={props} />
<ComponentMapper componentProps={page} pageProps={props} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExpansionCard, BodyShort, Heading } from '@navikt/ds-react';
import { usePageContentProps } from 'store/pageContext';
import { translator } from 'translations';
import { OfficeDetailsData } from 'types/content-props/office-details-props';
import { officeDetailsFormatAddress } from 'components/pages/office-branch-page/office-details/utils';
import { officeDetailsFormatAddress } from 'components/pages/office-page/office-details/utils';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BodyShort } from '@navikt/ds-react';
import { LenkeBase } from 'components/_common/lenke/LenkeBase';
import { AudienceContact } from 'types/content-props/office-details-props';
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-branch-page/office-details/utils';
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-page/office-details/utils';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { BodyLong, BodyShort, Heading } from '@navikt/ds-react';
import { PhoneFillIcon } from '@navikt/aksel-icons';
import { OfficeDetailsProps } from 'components/pages/office-branch-page/office-details/OfficeDetails';
import { OfficeDetailsProps } from 'components/pages/office-page/office-details/OfficeDetails';
import { translator } from 'translations';
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-branch-page/office-details/utils';
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-page/office-details/utils';
import { usePageContentProps } from 'store/pageContext';
import { forceArray } from 'utils/arrays';
import { LenkeBase } from 'components/_common/lenke/LenkeBase';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Heading, BodyLong, BodyShort } from '@navikt/ds-react';
import {
officeDetailsFormatAddress,
officeDetailsFormatPhoneNumber,
} from 'components/pages/office-branch-page/office-details/utils';
} from 'components/pages/office-page/office-details/utils';
import { OfficeInfoEmail } from 'components/parts/_legacy/office-information/OfficeInfoEmail';
import ArtikkelDato from 'components/parts/_legacy/main-article/komponenter/ArtikkelDato';
import { LenkeInline } from 'components/_common/lenke/LenkeInline';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
LegacyOfficeOpeningHoursProps,
} from 'types/content-props/office-information-props';
import { forceArray } from 'utils/arrays';
import { officeDetailsFormatAddress } from 'components/pages/office-branch-page/office-details/utils';
import { officeDetailsFormatAddress } from 'components/pages/office-page/office-details/utils';
import { OpeningHours } from './OpeningHours';

import style from './Reception.module.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ export const OfficeEditorialDetailPart = ({
);
}

if (pageProps.type !== ContentType.OfficeBranchPage) {
if (pageProps.type !== ContentType.OfficePage) {
return null;
}

const officeData = pageProps.data.officeNorgData.data;

if (!officeData) {
return null;
}

Expand All @@ -73,5 +79,5 @@ export const OfficeEditorialDetailPart = ({
return null;
}

return <DetailComponent officeData={pageProps.data} />;
return <DetailComponent officeData={officeData} />;
};
3 changes: 0 additions & 3 deletions src/types/content-props/_content-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
DynamicPageProps,
GenericPageProps,
GuidePageProps,
OfficeBranchPageProps,
OfficeEditorialPageProps,
CurrentTopicPageProps,
ProductDetailsProps,
Expand Down Expand Up @@ -72,7 +71,6 @@ export enum ContentType {
ProductPage = 'no.nav.navno:content-page-with-sidemenus',
ProductDetails = 'no.nav.navno:product-details',
OfficeEditorialPage = 'no.nav.navno:office-editorial-page',
OfficeBranchPage = 'no.nav.navno:office-branch',
GuidePage = 'no.nav.navno:guide-page',
ThemedArticlePage = 'no.nav.navno:themed-article-page',
CurrentTopicPage = 'no.nav.navno:current-topic-page',
Expand Down Expand Up @@ -174,7 +172,6 @@ type SpecificContentProps =
| ProductPageProps
| SituationPageProps
| OfficeEditorialPageProps
| OfficeBranchPageProps
| OfficePageProps
| PictogramsProps
| GlobalValuesProps
Expand Down
7 changes: 1 addition & 6 deletions src/types/content-props/dynamic-page-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@ export type OfficeEditorialPageProps = ContentCommonProps & {
page: LayoutComponentProps;
};

export type OfficeBranchPageProps = ContentCommonProps & {
type: ContentType.OfficeBranchPage;
data: OfficeDetailsData;
editorial: OfficeEditorialPageProps;
};

export type OfficePageProps = ContentCommonProps & {
type: ContentType.OfficePage;
data: {
title: string;
officeNorgData: OptionSetSingle<{ data: OfficeDetailsData }>;
};
page: LayoutComponentProps;
editorial?: OfficeEditorialPageProps;
};

export type CurrentTopicPageProps = ContentCommonProps & {
Expand Down
1 change: 0 additions & 1 deletion src/utils/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const contentTypesWithWhiteHeader: ReadonlySet<ContentType> = new Set([
ContentType.FrontPageNested,
ContentType.GenericPage,
ContentType.GuidePage,
ContentType.OfficeBranchPage,
ContentType.OfficePage,
ContentType.OfficeEditorialPage,
ContentType.Overview,
Expand Down

0 comments on commit 933bc8e

Please sign in to comment.