Skip to content

Commit 9ea3a5a

Browse files
authored
Merge pull request #2294 from navikt/div-stories
Div stories, kontorside
2 parents 42e4e9a + 2ec9202 commit 9ea3a5a

File tree

55 files changed

+305
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+305
-15
lines changed

packages/nextjs/src/components/ContentMapper.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React from 'react';
22
import { ContentProps, ContentType } from 'types/content-props/_content-common';
3-
import { ContentTypeNotSupportedPage } from 'components/pages/contenttype-not-supported-page/ContentTypeNotSupportedPage';
3+
import { ContentTypeNotSupportedPage } from 'components/pages/contenttypeNotSupportedPage/ContentTypeNotSupportedPage';
44
import { FormDetailsPreviewPage } from 'components/pages/form-details-preview-page/FormDetailsPreviewPage';
55
import { FormsOverviewPage } from 'components/pages/forms-overview-page/FormsOverviewPage';
66
import { VideoPreviewPage } from 'components/pages/video-preview-page/VideoPreviewPage';
77
import { UserTestsConfigPreviewPage } from 'components/pages/user-tests-config-preview-page/UserTestsConfigPreviewPage';
8-
import { ErrorPage } from './pages/error-page/ErrorPage';
8+
import { ErrorPage } from './pages/errorPage/ErrorPage';
99
import { DynamicPage } from './pages/dynamic-page/DynamicPage';
1010
import { FragmentPage } from './pages/fragment-page/FragmentPage';
1111
import { ContactInformationPage } from './pages/contact-information-page/ContactInformationPage';
1212
import { LargeTablePage } from './pages/large-table-page/LargeTablePage';
1313
import { RedirectPage } from './pages/redirect-page/RedirectPage';
1414
import { TemplatePage } from './pages/template-page/TemplatePage';
15-
import { SituationPage } from './pages/situation-page/SituationPage';
15+
import { SituationPage } from './pages/situationPage/SituationPage';
1616
import { GuidePage } from './pages/guide-page/GuidePage';
1717
import { OverviewPage } from './pages/overview-page/OverviewPage';
1818
import { OfficeEditorialPage } from './pages/office-editorial-page/OfficeEditorialPage';
@@ -30,7 +30,7 @@ import { FormIntermediateStepPage } from './pages/form-intermediate-step-page/Fo
3030
import { CalculatorPage } from './pages/calculator-page/CalculatorPage';
3131
import { AlertInContextPage } from './pages/alert-in-context-page/AlertInContextPage';
3232
import { OfficePage } from './pages/office-page/OfficePage';
33-
import { ContactStepPage } from './pages/contact-step-page/ContactStepPage';
33+
import { ContactStepPage } from './pages/contactStepPage/ContactStepPage';
3434

3535
const contentToReactComponent: {
3636
[key in ContentType]?: React.FunctionComponent<ContentProps<key>>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { ContentType } from 'types/content-props/_content-common';
3+
import { ContentTypeNotSupportedPage } from './ContentTypeNotSupportedPage';
4+
5+
const meta = {
6+
component: ContentTypeNotSupportedPage,
7+
} satisfies Meta<typeof ContentTypeNotSupportedPage>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Default: Story = {
14+
args: {
15+
type: ContentType.Error,
16+
},
17+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DocumentParameter } from 'components/_common/metatags/DocumentParameter
66

77
import style from './ContentTypeNotSupportedPage.module.scss';
88

9-
export const ContentTypeNotSupportedPage = (props: ContentProps) => {
9+
export const ContentTypeNotSupportedPage = (props: Pick<ContentProps, 'type'>) => {
1010
return (
1111
<div className={style.notSupported}>
1212
<Head>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { ContentType } from 'types/content-props/_content-common';
3+
import { Language } from 'translations';
4+
import { ErrorPage } from './ErrorPage';
5+
6+
const meta = {
7+
component: ErrorPage,
8+
} satisfies Meta<typeof ErrorPage>;
9+
10+
export default meta;
11+
12+
type Story = StoryObj<typeof meta>;
13+
14+
const commonArgs = {
15+
_id: '123',
16+
_path: '/test',
17+
createdTime: '2021-01-01',
18+
modifiedTime: '2021-01-01',
19+
displayName: 'Test',
20+
language: 'no' as Language,
21+
type: ContentType.Error as const,
22+
};
23+
24+
export const Error400: Story = {
25+
args: {
26+
...commonArgs,
27+
data: {
28+
errorMessage: 'Feilmelding',
29+
errorCode: 400,
30+
},
31+
},
32+
};
33+
34+
export const Error404: Story = {
35+
args: {
36+
...commonArgs,
37+
data: {
38+
errorMessage: 'Feilmelding',
39+
errorCode: 404,
40+
},
41+
},
42+
};
43+
44+
export const Error408: Story = {
45+
args: {
46+
...commonArgs,
47+
data: {
48+
errorMessage: 'Feilmelding',
49+
errorCode: 408,
50+
},
51+
},
52+
};
53+
54+
export const RandomErrorCode: Story = {
55+
args: {
56+
...commonArgs,
57+
data: {
58+
errorMessage: 'Feilmelding',
59+
errorCode: 123,
60+
},
61+
},
62+
};

packages/nextjs/src/components/pages/office-page/OfficePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { OfficePageProps } from 'types/content-props/dynamic-page-props';
55
import { classNames } from 'utils/classnames';
66

77
import { OfficePageHeader } from 'components/pages/office-page/office-page-header/OfficePageHeader';
8-
import { OfficeDetails } from 'components/pages/office-page/office-details/OfficeDetails';
8+
import { OfficeDetails } from 'components/pages/office-page/officeDetails/OfficeDetails';
99

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { OfficeDetails } from './OfficeDetails';
3+
import { mockOfficeData, mockReception1, mockReception2 } from './mockData';
4+
5+
const meta = {
6+
component: OfficeDetails,
7+
} satisfies Meta<typeof OfficeDetails>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const WithReception: Story = {
14+
args: {
15+
officeData: {
16+
...mockOfficeData,
17+
brukerkontakt: {
18+
...mockOfficeData.brukerkontakt,
19+
publikumsmottak: [mockReception1],
20+
},
21+
},
22+
},
23+
};
24+
25+
export const WithSpecialOpeningHours: Story = {
26+
args: {
27+
officeData: {
28+
...mockOfficeData,
29+
brukerkontakt: {
30+
...mockOfficeData.brukerkontakt,
31+
publikumsmottak: [mockReception2],
32+
},
33+
},
34+
},
35+
};
36+
37+
export const WithMultipleReceptions: Story = {
38+
args: {
39+
officeData: {
40+
...mockOfficeData,
41+
brukerkontakt: {
42+
...mockOfficeData.brukerkontakt,
43+
publikumsmottak: [mockReception1, mockReception2],
44+
},
45+
},
46+
},
47+
};
48+
49+
export const WithoutReception: Story = {
50+
args: {
51+
officeData: {
52+
...mockOfficeData,
53+
brukerkontakt: {
54+
...mockOfficeData.brukerkontakt,
55+
publikumsmottak: [],
56+
},
57+
},
58+
},
59+
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { AudienceReception } from '@navikt/nav-office-reception-info';
2+
import { OpeningHours } from '@navikt/nav-office-reception-info/dist/utils/types';
3+
import { AudienceContact, OfficeDetailsData } from 'types/content-props/office-details-props';
4+
5+
export const mockAudienceContact: AudienceContact = {
6+
beskrivelse:
7+
'Hvis du i en nødssituasjon og trenger rask kontakt med Nav-kontoret ditt kan du ringe vakttelefon',
8+
telefon: '99527885',
9+
sortOrder: 1,
10+
};
11+
12+
export const mockOfficeData: OfficeDetailsData = {
13+
enhetNr: '1234',
14+
type: 'NAV_KONTOR',
15+
telefonnummer: '12345678',
16+
navn: 'NAV Oslo',
17+
organisasjonsnummer: '987654321',
18+
status: 'AKTIV',
19+
beliggenhet: {
20+
type: 'stedsadresse' as const,
21+
gatenavn: 'Karl Johans gate',
22+
husnummer: '1',
23+
postnummer: '0154',
24+
poststed: 'OSLO',
25+
},
26+
postadresse: {
27+
type: 'stedsadresse' as const,
28+
gatenavn: 'Postboks',
29+
husnummer: '1234',
30+
postnummer: '0103',
31+
poststed: 'OSLO',
32+
},
33+
brukerkontakt: {
34+
spraakdrakt: 'NB' as const,
35+
publikumsmottak: [],
36+
publikumskanaler: [mockAudienceContact],
37+
},
38+
};
39+
40+
const openingHours: OpeningHours[] = [
41+
{
42+
dag: 'Mandag',
43+
fra: '09:00',
44+
til: '15:00',
45+
},
46+
{
47+
dag: 'Tirsdag',
48+
fra: '09:00',
49+
til: '15:00',
50+
},
51+
{
52+
dag: 'Onsdag',
53+
stengt: 'true',
54+
},
55+
{
56+
dag: 'Torsdag',
57+
kunTimeavtale: 'true',
58+
},
59+
{ dag: 'Fredag', fra: '12:00', til: '15:00' },
60+
];
61+
62+
const specialOpeningHours: OpeningHours[] = [
63+
{ dato: '1999-12-24', stengt: 'true' },
64+
{ dato: '2042-12-24', stengt: 'true' },
65+
{ dato: '2042-12-31', fra: '09:00', til: '12:00' },
66+
];
67+
68+
export const mockReception1: AudienceReception = {
69+
officeType: 'NAV_KONTOR',
70+
besoeksadresse: {
71+
type: 'stedsadresse' as const,
72+
gatenavn: 'Testgate',
73+
husnummer: '1',
74+
postnummer: '1234',
75+
poststed: 'Herøy',
76+
},
77+
aapningstider: [...openingHours],
78+
};
79+
80+
export const mockReception2: AudienceReception = {
81+
officeType: 'NAV_KONTOR',
82+
besoeksadresse: {
83+
type: 'stedsadresse' as const,
84+
gatenavn: 'Storgata',
85+
husnummer: '2',
86+
postnummer: '0155',
87+
poststed: 'Dønna',
88+
},
89+
aapningstider: [...openingHours, ...specialOpeningHours],
90+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { mockOfficeData } from 'components/pages/office-page/officeDetails/mockData';
3+
import { OfficeInformation } from './OfficeInformation';
4+
5+
const meta = {
6+
component: OfficeInformation,
7+
} satisfies Meta<typeof OfficeInformation>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Open: Story = {
14+
args: {
15+
officeData: mockOfficeData,
16+
initialOpen: true,
17+
},
18+
};
19+
20+
export const Closed: Story = {
21+
args: {
22+
officeData: mockOfficeData,
23+
initialOpen: false,
24+
},
25+
};
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import { usePageContentProps } from 'store/pageContext';
66
import { getDecoratorParams } from 'utils/decorator-utils';
77
import { innholdsTypeMap } from 'types/content-props/_content-common';
88
import { OfficeDetailsData } from 'types/content-props/office-details-props';
9-
import { officeDetailsFormatAddress } from 'components/pages/office-page/office-details/utils';
9+
import { officeDetailsFormatAddress } from 'components/pages/office-page/officeDetails/utils';
1010

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

1313
export interface OfficeInformationProps {
1414
officeData: OfficeDetailsData;
15+
initialOpen?: boolean;
1516
}
1617

17-
export const OfficeInformation = ({ officeData }: OfficeInformationProps) => {
18-
const [isOpen, setIsOpen] = useState(false);
18+
export const OfficeInformation = ({ officeData, initialOpen = false }: OfficeInformationProps) => {
19+
const [isOpen, setIsOpen] = useState(initialOpen);
1920
const contentProps = usePageContentProps();
2021
const { context } = getDecoratorParams(contentProps);
2122
const getOfficeTranslations = translator('office', contentProps.language);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { AudienceChannels } from 'components/pages/office-page/officeDetails/phonePoster/AudienceChannels';
3+
import { mockAudienceContact } from 'components/pages/office-page/officeDetails/mockData';
4+
5+
const meta = {
6+
component: AudienceChannels,
7+
} satisfies Meta<typeof AudienceChannels>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Default: Story = {
14+
args: {
15+
publikumskanaler: [mockAudienceContact],
16+
},
17+
};

packages/nextjs/src/components/pages/office-page/office-details/phonePoster/AudienceChannels.tsx renamed to packages/nextjs/src/components/pages/office-page/officeDetails/phonePoster/AudienceChannels.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BodyShort } from '@navikt/ds-react';
22
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase';
33
import { AudienceContact } from 'types/content-props/office-details-props';
4-
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-page/office-details/utils';
4+
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-page/officeDetails/utils';
55

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { mockOfficeData } from 'components/pages/office-page/officeDetails/mockData';
3+
import { PhonePoster } from './PhonePoster';
4+
5+
const meta = {
6+
component: PhonePoster,
7+
} satisfies Meta<typeof PhonePoster>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Default: Story = {
14+
args: {
15+
officeData: {
16+
...mockOfficeData,
17+
},
18+
},
19+
};

packages/nextjs/src/components/pages/office-page/office-details/phonePoster/PhonePoster.tsx renamed to packages/nextjs/src/components/pages/office-page/officeDetails/phonePoster/PhonePoster.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import { BodyLong, BodyShort, Heading } from '@navikt/ds-react';
33
import { PhoneFillIcon } from '@navikt/aksel-icons';
4-
import { OfficeDetailsProps } from 'components/pages/office-page/office-details/OfficeDetails';
4+
import { OfficeDetailsProps } from 'components/pages/office-page/officeDetails/OfficeDetails';
55
import { translator } from 'translations';
6-
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-page/office-details/utils';
6+
import { officeDetailsFormatPhoneNumber } from 'components/pages/office-page/officeDetails/utils';
77
import { usePageContentProps } from 'store/pageContext';
88
import { forceArray } from 'utils/arrays';
99
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase';

packages/nextjs/src/components/parts/_legacy/office-information/OfficeInformationLegacyPart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BodyLong, BodyShort, Heading } from '@navikt/ds-react';
33
import {
44
officeDetailsFormatAddress,
55
officeDetailsFormatPhoneNumber,
6-
} from 'components/pages/office-page/office-details/utils';
6+
} from 'components/pages/office-page/officeDetails/utils';
77
import { OfficeInfoEmail } from 'components/parts/_legacy/office-information/OfficeInfoEmail';
88
import ArtikkelDato from 'components/parts/_legacy/main-article/komponenter/ArtikkelDato';
99
import { LenkeInline } from 'components/_common/lenke/lenkeInline/LenkeInline';

0 commit comments

Comments
 (0)