From 3c7789d4acdea925e873f7fb7c4d97c39e5b4ebf Mon Sep 17 00:00:00 2001 From: Terje Karlsen Date: Tue, 16 Apr 2024 09:10:01 +0200 Subject: [PATCH 1/2] Fjerner office-branch-page og legger lokalkontor til office-page --- src/components/ContentMapper.tsx | 2 -- .../OfficeBranchPage.module.scss | 32 ------------------ .../office-branch-page/OfficeBranchPage.tsx | 29 ---------------- .../pages/office-page/OfficePage.module.scss | 2 +- .../pages/office-page/OfficePage.tsx | 33 +++++++++++++++++-- .../office-details/OfficeDetails.module.scss | 0 .../office-details/OfficeDetails.tsx | 0 .../OfficeInformation.module.scss | 0 .../officeInformation/OfficeInformation.tsx | 2 +- .../phonePoster/AudienceChannels.module.scss | 0 .../phonePoster/AudienceChannels.tsx | 2 +- .../phonePoster/PhonePoster.module.scss | 0 .../phonePoster/PhonePoster.tsx | 4 +-- .../office-details/utils.ts | 0 .../OfficePageHeader.module.scss | 0 .../office-page-header/OfficePageHeader.tsx | 0 .../OfficeInformationLegacyPart.tsx | 2 +- .../reception/Reception.tsx | 2 +- .../OfficeEditorialDetailPart.tsx | 10 ++++-- src/types/content-props/_content-common.ts | 3 -- src/types/content-props/dynamic-page-props.ts | 7 +--- src/utils/appearance.ts | 1 - 22 files changed, 46 insertions(+), 85 deletions(-) delete mode 100644 src/components/pages/office-branch-page/OfficeBranchPage.module.scss delete mode 100644 src/components/pages/office-branch-page/OfficeBranchPage.tsx rename src/components/pages/{office-branch-page => office-page}/office-details/OfficeDetails.module.scss (100%) rename src/components/pages/{office-branch-page => office-page}/office-details/OfficeDetails.tsx (100%) rename src/components/pages/{office-branch-page => office-page}/office-details/officeInformation/OfficeInformation.module.scss (100%) rename src/components/pages/{office-branch-page => office-page}/office-details/officeInformation/OfficeInformation.tsx (98%) rename src/components/pages/{office-branch-page => office-page}/office-details/phonePoster/AudienceChannels.module.scss (100%) rename src/components/pages/{office-branch-page => office-page}/office-details/phonePoster/AudienceChannels.tsx (97%) rename src/components/pages/{office-branch-page => office-page}/office-details/phonePoster/PhonePoster.module.scss (100%) rename src/components/pages/{office-branch-page => office-page}/office-details/phonePoster/PhonePoster.tsx (94%) rename src/components/pages/{office-branch-page => office-page}/office-details/utils.ts (100%) rename src/components/pages/{office-branch-page => office-page}/office-page-header/OfficePageHeader.module.scss (100%) rename src/components/pages/{office-branch-page => office-page}/office-page-header/OfficePageHeader.tsx (100%) diff --git a/src/components/ContentMapper.tsx b/src/components/ContentMapper.tsx index d00436142..3b9b05875 100644 --- a/src/components/ContentMapper.tsx +++ b/src/components/ContentMapper.tsx @@ -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'; @@ -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, diff --git a/src/components/pages/office-branch-page/OfficeBranchPage.module.scss b/src/components/pages/office-branch-page/OfficeBranchPage.module.scss deleted file mode 100644 index a39cd6b14..000000000 --- a/src/components/pages/office-branch-page/OfficeBranchPage.module.scss +++ /dev/null @@ -1,32 +0,0 @@ -@use 'common' as common; - -$margin: 2rem; - -.officeBranchPage { - display: flex; - flex-direction: column; -} -.pageContent { - display: flex; - flex-direction: column; - - :global { - .layout__section-with-header { - max-width: common.$sectionMaxWidth; - margin-bottom: $margin; - } - } -} - -.content { - margin-top: 2rem; - display: flex; - justify-content: flex-start; - align-self: center; - width: 100%; - max-width: common.$contentMaxWidth; - - & > * { - width: 100%; - } -} diff --git a/src/components/pages/office-branch-page/OfficeBranchPage.tsx b/src/components/pages/office-branch-page/OfficeBranchPage.tsx deleted file mode 100644 index 986ab883d..000000000 --- a/src/components/pages/office-branch-page/OfficeBranchPage.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { ComponentMapper } from 'components/ComponentMapper'; -import { OfficeBranchPageProps } from 'types/content-props/dynamic-page-props'; -import { classNames } from 'utils/classnames'; -import { logger } from 'srcCommon/logger'; -import { OfficePageHeader } from './office-page-header/OfficePageHeader'; -import { OfficeDetails } from './office-details/OfficeDetails'; - -import styles from './OfficeBranchPage.module.scss'; - -export const OfficeBranchPage = (props: OfficeBranchPageProps) => { - const editorialPage = props.editorial; - - if (!editorialPage) { - logger.error(`No editorial page found for ${props.displayName}`); - } - - return ( -
- - -
- {editorialPage && ( - - )} -
-
- ); -}; diff --git a/src/components/pages/office-page/OfficePage.module.scss b/src/components/pages/office-page/OfficePage.module.scss index a39cd6b14..84bc654da 100644 --- a/src/components/pages/office-page/OfficePage.module.scss +++ b/src/components/pages/office-page/OfficePage.module.scss @@ -2,7 +2,7 @@ $margin: 2rem; -.officeBranchPage { +.officePage { display: flex; flex-direction: column; } diff --git a/src/components/pages/office-page/OfficePage.tsx b/src/components/pages/office-page/OfficePage.tsx index 74a513db4..54a0e1496 100644 --- a/src/components/pages/office-page/OfficePage.tsx +++ b/src/components/pages/office-page/OfficePage.tsx @@ -2,17 +2,44 @@ 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 (isOfficeBranch && !editorialPage) { + logger.error(`No editorial page found for ${props.displayName}`); + return null; + } + + if (!officeNorgData) { + logger.error('No office data exists for this office page'); + return null; + } + + if (officeNorgData.type === 'LOKAL') { + return ( +
+ + +
+ {editorialPage && ( + + )} +
+
+ ); + } return ( -
+
{officeNorgData && ( )} diff --git a/src/components/pages/office-branch-page/office-details/OfficeDetails.module.scss b/src/components/pages/office-page/office-details/OfficeDetails.module.scss similarity index 100% rename from src/components/pages/office-branch-page/office-details/OfficeDetails.module.scss rename to src/components/pages/office-page/office-details/OfficeDetails.module.scss diff --git a/src/components/pages/office-branch-page/office-details/OfficeDetails.tsx b/src/components/pages/office-page/office-details/OfficeDetails.tsx similarity index 100% rename from src/components/pages/office-branch-page/office-details/OfficeDetails.tsx rename to src/components/pages/office-page/office-details/OfficeDetails.tsx diff --git a/src/components/pages/office-branch-page/office-details/officeInformation/OfficeInformation.module.scss b/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.module.scss similarity index 100% rename from src/components/pages/office-branch-page/office-details/officeInformation/OfficeInformation.module.scss rename to src/components/pages/office-page/office-details/officeInformation/OfficeInformation.module.scss diff --git a/src/components/pages/office-branch-page/office-details/officeInformation/OfficeInformation.tsx b/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx similarity index 98% rename from src/components/pages/office-branch-page/office-details/officeInformation/OfficeInformation.tsx rename to src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx index ee669f983..0eab7334b 100644 --- a/src/components/pages/office-branch-page/office-details/officeInformation/OfficeInformation.tsx +++ b/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx @@ -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'; diff --git a/src/components/pages/office-branch-page/office-details/phonePoster/AudienceChannels.module.scss b/src/components/pages/office-page/office-details/phonePoster/AudienceChannels.module.scss similarity index 100% rename from src/components/pages/office-branch-page/office-details/phonePoster/AudienceChannels.module.scss rename to src/components/pages/office-page/office-details/phonePoster/AudienceChannels.module.scss diff --git a/src/components/pages/office-branch-page/office-details/phonePoster/AudienceChannels.tsx b/src/components/pages/office-page/office-details/phonePoster/AudienceChannels.tsx similarity index 97% rename from src/components/pages/office-branch-page/office-details/phonePoster/AudienceChannels.tsx rename to src/components/pages/office-page/office-details/phonePoster/AudienceChannels.tsx index 2b56d7765..899e60ff6 100644 --- a/src/components/pages/office-branch-page/office-details/phonePoster/AudienceChannels.tsx +++ b/src/components/pages/office-page/office-details/phonePoster/AudienceChannels.tsx @@ -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'; diff --git a/src/components/pages/office-branch-page/office-details/phonePoster/PhonePoster.module.scss b/src/components/pages/office-page/office-details/phonePoster/PhonePoster.module.scss similarity index 100% rename from src/components/pages/office-branch-page/office-details/phonePoster/PhonePoster.module.scss rename to src/components/pages/office-page/office-details/phonePoster/PhonePoster.module.scss diff --git a/src/components/pages/office-branch-page/office-details/phonePoster/PhonePoster.tsx b/src/components/pages/office-page/office-details/phonePoster/PhonePoster.tsx similarity index 94% rename from src/components/pages/office-branch-page/office-details/phonePoster/PhonePoster.tsx rename to src/components/pages/office-page/office-details/phonePoster/PhonePoster.tsx index 3a46f6260..fd4d1c7a3 100644 --- a/src/components/pages/office-branch-page/office-details/phonePoster/PhonePoster.tsx +++ b/src/components/pages/office-page/office-details/phonePoster/PhonePoster.tsx @@ -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'; diff --git a/src/components/pages/office-branch-page/office-details/utils.ts b/src/components/pages/office-page/office-details/utils.ts similarity index 100% rename from src/components/pages/office-branch-page/office-details/utils.ts rename to src/components/pages/office-page/office-details/utils.ts diff --git a/src/components/pages/office-branch-page/office-page-header/OfficePageHeader.module.scss b/src/components/pages/office-page/office-page-header/OfficePageHeader.module.scss similarity index 100% rename from src/components/pages/office-branch-page/office-page-header/OfficePageHeader.module.scss rename to src/components/pages/office-page/office-page-header/OfficePageHeader.module.scss diff --git a/src/components/pages/office-branch-page/office-page-header/OfficePageHeader.tsx b/src/components/pages/office-page/office-page-header/OfficePageHeader.tsx similarity index 100% rename from src/components/pages/office-branch-page/office-page-header/OfficePageHeader.tsx rename to src/components/pages/office-page/office-page-header/OfficePageHeader.tsx diff --git a/src/components/parts/_legacy/office-information/OfficeInformationLegacyPart.tsx b/src/components/parts/_legacy/office-information/OfficeInformationLegacyPart.tsx index a9ed531e5..8ffd37e80 100644 --- a/src/components/parts/_legacy/office-information/OfficeInformationLegacyPart.tsx +++ b/src/components/parts/_legacy/office-information/OfficeInformationLegacyPart.tsx @@ -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 { translator } from 'translations'; import ArtikkelDato from 'components/parts/_legacy/main-article/komponenter/ArtikkelDato'; diff --git a/src/components/parts/_legacy/office-information/reception/Reception.tsx b/src/components/parts/_legacy/office-information/reception/Reception.tsx index 3cbe92374..1395b1d06 100644 --- a/src/components/parts/_legacy/office-information/reception/Reception.tsx +++ b/src/components/parts/_legacy/office-information/reception/Reception.tsx @@ -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'; diff --git a/src/components/parts/office-editorial-detail/OfficeEditorialDetailPart.tsx b/src/components/parts/office-editorial-detail/OfficeEditorialDetailPart.tsx index a29b64929..d5a5911a9 100644 --- a/src/components/parts/office-editorial-detail/OfficeEditorialDetailPart.tsx +++ b/src/components/parts/office-editorial-detail/OfficeEditorialDetailPart.tsx @@ -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; } @@ -73,5 +79,5 @@ export const OfficeEditorialDetailPart = ({ return null; } - return ; + return ; }; diff --git a/src/types/content-props/_content-common.ts b/src/types/content-props/_content-common.ts index 7f91d8661..89811280a 100644 --- a/src/types/content-props/_content-common.ts +++ b/src/types/content-props/_content-common.ts @@ -24,7 +24,6 @@ import { DynamicPageProps, GenericPageProps, GuidePageProps, - OfficeBranchPageProps, OfficeEditorialPageProps, CurrentTopicPageProps, ProductDetailsProps, @@ -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', @@ -173,7 +171,6 @@ type SpecificContentProps = | ProductPageProps | SituationPageProps | OfficeEditorialPageProps - | OfficeBranchPageProps | OfficePageProps | AnimatedIconsProps | GlobalValuesProps diff --git a/src/types/content-props/dynamic-page-props.ts b/src/types/content-props/dynamic-page-props.ts index 3533224f9..62fc50db8 100644 --- a/src/types/content-props/dynamic-page-props.ts +++ b/src/types/content-props/dynamic-page-props.ts @@ -62,12 +62,6 @@ 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: { @@ -75,6 +69,7 @@ export type OfficePageProps = ContentCommonProps & { officeNorgData: OptionSetSingle<{ data: OfficeDetailsData }>; }; page: LayoutComponentProps; + editorial?: OfficeEditorialPageProps; }; export type CurrentTopicPageProps = ContentCommonProps & { diff --git a/src/utils/appearance.ts b/src/utils/appearance.ts index 8d4afd89d..86172ef65 100644 --- a/src/utils/appearance.ts +++ b/src/utils/appearance.ts @@ -17,7 +17,6 @@ const contentTypesWithWhiteHeader: ReadonlySet = new Set([ ContentType.FrontPageNested, ContentType.GenericPage, ContentType.GuidePage, - ContentType.OfficeBranchPage, ContentType.OfficePage, ContentType.OfficeEditorialPage, ContentType.Overview, From 5a5c7440db3d449e7631a9fad5348675d9b0a07e Mon Sep 17 00:00:00 2001 From: Terje Karlsen Date: Tue, 16 Apr 2024 09:21:20 +0200 Subject: [PATCH 2/2] Forbedrer felles OfficePage-struktur --- .../pages/office-page/OfficePage.tsx | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/components/pages/office-page/OfficePage.tsx b/src/components/pages/office-page/OfficePage.tsx index 54a0e1496..cefcf945f 100644 --- a/src/components/pages/office-page/OfficePage.tsx +++ b/src/components/pages/office-page/OfficePage.tsx @@ -14,30 +14,18 @@ export const OfficePage = (props: OfficePageProps) => { const isOfficeBranch = officeNorgData.type === 'LOKAL'; const editorialPage = props.editorial; - if (isOfficeBranch && !editorialPage) { - logger.error(`No editorial page found for ${props.displayName}`); - return null; - } - if (!officeNorgData) { logger.error('No office data exists for this office page'); return null; } - if (officeNorgData.type === 'LOKAL') { - return ( -
- - -
- {editorialPage && ( - - )} -
-
- ); + 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 (
{officeNorgData && ( @@ -45,7 +33,7 @@ export const OfficePage = (props: OfficePageProps) => { )} {officeNorgData && }
- +
);