add contact pages and blocks
This commit is contained in:
22
web/src/app/kontakt-test/page.tsx
Normal file
22
web/src/app/kontakt-test/page.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
import { graphql } from "@/gql";
|
||||
//import { NewsFragment } from "@/gql/graphql";
|
||||
import { getClient } from "@/app/client";
|
||||
import { NewsList } from "@/components/news/NewsList";
|
||||
import Link from "next/link";
|
||||
import { PageHeader } from "@/components/general/PageHeader";
|
||||
import { PersonSection } from "@/components/people/PersonSection";
|
||||
import { ContactInfo } from "@/components/contact/ContactInfo";
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<main className="site-main" id="main">
|
||||
<PageHeader
|
||||
heading="Kontakt"
|
||||
lead="Her er info om hvordan du kan kontakte oss og sånt."
|
||||
/>
|
||||
<ContactInfo />
|
||||
<PersonSection heading="Styret" />
|
||||
<PersonSection heading="Administrasjonen" />
|
||||
</main>
|
||||
);
|
||||
}
|
@ -1,22 +1,40 @@
|
||||
import { graphql } from "@/gql";
|
||||
//import { NewsFragment } from "@/gql/graphql";
|
||||
import { ContactFragment, ContactIndexFragment } from "@/gql/graphql";
|
||||
import { getClient } from "@/app/client";
|
||||
import { NewsList } from "@/components/news/NewsList";
|
||||
import { ContactList } from "@/components/Contacts/ContactList";
|
||||
import { Blocks } from "@/components/blocks/Blocks";
|
||||
import Link from "next/link";
|
||||
import { PageHeader } from "@/components/general/PageHeader";
|
||||
import { PersonSection } from "@/components/people/PersonSection";
|
||||
import { ContactInfo } from "@/components/contact/ContactInfo";
|
||||
|
||||
const ContactIndexDefinition = graphql(`
|
||||
fragment ContactIndex on ContactIndex {
|
||||
... on ContactIndex {
|
||||
title
|
||||
lead
|
||||
body {
|
||||
...Blocks
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
export default async function Page() {
|
||||
const contactQuery = graphql(`
|
||||
query contacts {
|
||||
contactIndex {
|
||||
... on ContactIndex {
|
||||
...ContactIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
const { data, error } = await getClient().query(contactQuery, {});
|
||||
const index = (data?.contactIndex ?? []) as ContactIndexFragment;
|
||||
|
||||
return (
|
||||
<main className="site-main" id="main">
|
||||
<PageHeader
|
||||
heading="Kontakt"
|
||||
lead="Her er info om hvordan du kan kontakte oss og sånt."
|
||||
/>
|
||||
<ContactInfo />
|
||||
<PersonSection heading="Styret" />
|
||||
<PersonSection heading="Administrasjonen" />
|
||||
<PageHeader heading={index.title} lead={index.lead} />
|
||||
{index.body && <Blocks blocks={index.body} />}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import { ImageSliderBlock } from "./ImageSliderBlock";
|
||||
import { HorizontalRuleBlock } from "./HorizontalRuleBlock";
|
||||
import { FeaturedBlock } from "./FeaturedBlock";
|
||||
import { PageSectionBlock, PageSectionNavigationBlock } from "./PageSection";
|
||||
import { ContactSectionBlock, ContactSubsectionBlock } from "./ContactSection";
|
||||
import { ContactListBlock } from "./ContactListBlock";
|
||||
import { ContactEntityBlock } from "./ContactEntityBlock";
|
||||
|
||||
export const Blocks = ({ blocks }: any) => {
|
||||
const sections = blocks.filter(
|
||||
@ -33,6 +36,18 @@ export const Blocks = ({ blocks }: any) => {
|
||||
case "PageSectionNavigationBlock":
|
||||
return <PageSectionNavigationBlock sections={sections} />;
|
||||
break;
|
||||
case "ContactSectionBlock":
|
||||
return <ContactSectionBlock block={block} />;
|
||||
break;
|
||||
case "ContactSubsectionBlock":
|
||||
return <ContactSubsectionBlock block={block} />;
|
||||
break;
|
||||
case "ContactListBlock":
|
||||
return <ContactListBlock block={block} />;
|
||||
break;
|
||||
case "ContactEntityBlock":
|
||||
return <ContactEntityBlock block={block} />;
|
||||
break;
|
||||
default:
|
||||
return <div>Unsupported block type {block.blockType}</div>;
|
||||
console.log("unsupported block", block);
|
||||
|
50
web/src/components/blocks/ContactEntityBlock.tsx
Normal file
50
web/src/components/blocks/ContactEntityBlock.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import { ContactEntityBlock as ContactEntityBlockType } from "@/gql/graphql";
|
||||
import styles from "./contactEntityBlock.module.scss";
|
||||
import { formatNorwegianPhoneNumber, formatPhoneE164 } from "@/lib/common";
|
||||
|
||||
export const ContactEntityBlock = ({
|
||||
block,
|
||||
}: {
|
||||
block: ContactEntityBlockType;
|
||||
}) => {
|
||||
// TODO: image
|
||||
|
||||
const contact = block?.contactEntity;
|
||||
|
||||
if (!contact) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
const phoneE164 = contact.phoneNumber && formatPhoneE164(contact.phoneNumber);
|
||||
const phoneFormatted = phoneE164 && formatNorwegianPhoneNumber(phoneE164);
|
||||
|
||||
return (
|
||||
<li className={styles.contactItem}>
|
||||
<div className={styles.image}></div>
|
||||
<div className={styles.text}>
|
||||
<h1 className={styles.name}>{contact.name}</h1>
|
||||
{contact.title && <p className={styles.role}>{contact.title}</p>}
|
||||
{(contact.email || phoneE164) && (
|
||||
<ul className={styles.contact}>
|
||||
{contact.email && (
|
||||
<li>
|
||||
<span className={styles.icon}>✉ </span>
|
||||
<a href={`mailto:${contact.email}`} target="_blank">
|
||||
{contact.email}
|
||||
</a>
|
||||
</li>
|
||||
)}
|
||||
{phoneE164 && (
|
||||
<li>
|
||||
<span className={styles.icon}>☎ </span>
|
||||
<a href={`tel:${phoneE164}`} target="_blank">
|
||||
{phoneFormatted}
|
||||
</a>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
};
|
15
web/src/components/blocks/ContactListBlock.tsx
Normal file
15
web/src/components/blocks/ContactListBlock.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import { ContactListBlock as ContactListBlockType } from "@/gql/graphql";
|
||||
import styles from "./contactListBlock.module.scss";
|
||||
import { Blocks } from "./Blocks";
|
||||
|
||||
export const ContactListBlock = ({
|
||||
block,
|
||||
}: {
|
||||
block: ContactListBlockType;
|
||||
}) => {
|
||||
return (
|
||||
<ul className={styles.contactList}>
|
||||
<Blocks blocks={block.items} />
|
||||
</ul>
|
||||
);
|
||||
};
|
41
web/src/components/blocks/ContactSection.tsx
Normal file
41
web/src/components/blocks/ContactSection.tsx
Normal file
@ -0,0 +1,41 @@
|
||||
import { ContactSectionBlock as ContactSectionBlockType } from "@/gql/graphql";
|
||||
import styles from "./contactSection.module.scss";
|
||||
import { Blocks } from "./Blocks";
|
||||
|
||||
export const ContactSectionBlock = ({
|
||||
block,
|
||||
}: {
|
||||
block: ContactSectionBlockType;
|
||||
}) => {
|
||||
return (
|
||||
<section className={styles.contactSection}>
|
||||
<h2 className={styles.heading}>{block.title}</h2>
|
||||
{block.text && (
|
||||
<p
|
||||
className={styles.intro}
|
||||
dangerouslySetInnerHTML={{ __html: block.text }}
|
||||
/>
|
||||
)}
|
||||
<Blocks blocks={block.blocks} />
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export const ContactSubsectionBlock = ({
|
||||
block,
|
||||
}: {
|
||||
block: ContactSectionBlockType;
|
||||
}) => {
|
||||
return (
|
||||
<section className={styles.contactSubsection}>
|
||||
<h3 className={styles.heading}>{block.title}</h3>
|
||||
{block.text && (
|
||||
<p
|
||||
className={styles.intro}
|
||||
dangerouslySetInnerHTML={{ __html: block.text }}
|
||||
/>
|
||||
)}
|
||||
<Blocks blocks={block.blocks} />
|
||||
</section>
|
||||
);
|
||||
};
|
43
web/src/components/blocks/contactEntityBlock.module.scss
Normal file
43
web/src/components/blocks/contactEntityBlock.module.scss
Normal file
@ -0,0 +1,43 @@
|
||||
.contactItem {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-s);
|
||||
}
|
||||
|
||||
.image {
|
||||
flex: none;
|
||||
width: 7rem;
|
||||
height: 7rem;
|
||||
background: var(--color-placeholder);
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
.text {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.name,
|
||||
.role {
|
||||
font-size: var(--spacing-s);
|
||||
}
|
||||
|
||||
.role {
|
||||
font-family: var(--font-serif);
|
||||
}
|
||||
|
||||
.contact {
|
||||
list-style: none;
|
||||
margin: .6rem 0;
|
||||
font-size: var(--font-size-caption);
|
||||
font-weight: 500;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline-block;
|
||||
width: var(--size-icon);
|
||||
text-align: center;
|
||||
margin-right: .4rem;
|
||||
}
|
19
web/src/components/blocks/contactListBlock.module.scss
Normal file
19
web/src/components/blocks/contactListBlock.module.scss
Normal file
@ -0,0 +1,19 @@
|
||||
.contactList {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
column-gap: var(--spacing-gap-column);
|
||||
row-gap: var(--spacing-gap-row);
|
||||
padding-bottom: var(--spacing-section-bottom);
|
||||
}
|
||||
|
||||
@media (min-width: 740px) {
|
||||
.contactList {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1340px) {
|
||||
.contactList {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
26
web/src/components/blocks/contactSection.module.scss
Normal file
26
web/src/components/blocks/contactSection.module.scss
Normal file
@ -0,0 +1,26 @@
|
||||
.contactSection {
|
||||
background: var(--color-background-secondary);
|
||||
margin: calc(var(--spacing-sitepadding-block) * 2)
|
||||
calc(var(--spacing-sitepadding-inline) * -1);
|
||||
padding: var(--spacing-sitepadding-block) var(--spacing-sitepadding-inline);
|
||||
|
||||
+ .contactSection {
|
||||
margin-top: calc(var(--spacing-sitepadding-block) * -2);
|
||||
}
|
||||
|
||||
&:nth-of-type(even) {
|
||||
background: var(--color-background);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.heading {
|
||||
margin: 0 0 1.6rem;
|
||||
}
|
||||
|
||||
.intro {
|
||||
margin-bottom: 3rem;
|
||||
}
|
@ -25,15 +25,18 @@ const documents = {
|
||||
"\n fragment AssociationIndex on AssociationIndex {\n ... on AssociationIndex {\n title\n lead\n body {\n ...Blocks\n }\n }\n }\n": types.AssociationIndexFragmentDoc,
|
||||
"\n fragment Association on AssociationPage {\n __typename\n id\n slug\n title\n excerpt\n body {\n ...Blocks\n }\n logo {\n url\n width\n height\n }\n associationType\n websiteUrl\n }\n": types.AssociationFragmentDoc,
|
||||
"\n query allAssociations {\n index: associationIndex {\n ... on AssociationIndex {\n ...AssociationIndex\n }\n }\n associations: pages(contentType: \"associations.AssociationPage\") {\n ... on AssociationPage {\n ...Association\n }\n }\n }\n ": types.AllAssociationsDocument,
|
||||
"\n fragment ContactIndex on ContactIndex {\n ... on ContactIndex {\n title\n lead\n body {\n ...Blocks\n }\n }\n }\n": types.ContactIndexFragmentDoc,
|
||||
"\n query contacts {\n contactIndex {\n ... on ContactIndex {\n ...ContactIndex\n }\n }\n }\n ": types.ContactsDocument,
|
||||
"\n query allVenueSlugs {\n pages(contentType: \"venues.VenuePage\") {\n id\n slug\n }\n }\n ": types.AllVenueSlugsDocument,
|
||||
"\n query venueBySlug($slug: String!) {\n venue: page(contentType: \"venues.VenuePage\", slug: $slug) {\n ... on VenuePage {\n ...Venue\n }\n }\n }\n ": types.VenueBySlugDocument,
|
||||
"\n fragment Venue on VenuePage {\n __typename\n id\n slug\n title\n body {\n ...Blocks\n }\n featuredImage {\n ...Image\n }\n showAsBookable\n floor\n preposition\n capabilityAudio\n capabilityAudioVideo\n capabilityBar\n capabilityLighting\n capacityLegal\n capacityStanding\n capacitySitting\n }\n": types.VenueFragmentDoc,
|
||||
"\n query allVenues {\n venues: pages(contentType: \"venues.VenuePage\") {\n ... on VenuePage {\n ...Venue\n }\n }\n }\n ": types.AllVenuesDocument,
|
||||
"\n fragment Home on HomePage {\n ... on HomePage {\n featuredEvents {\n id\n }\n }\n }\n": types.HomeFragmentDoc,
|
||||
"\n query home {\n events: eventIndex {\n ... on EventIndex {\n futureEvents {\n ... on EventPage {\n ...Event\n }\n }\n }\n }\n home: page(contentType: \"home.HomePage\", urlPath: \"/home/\") {\n ... on HomePage {\n ...Home\n }\n }\n news: pages(contentType: \"news.newsPage\", limit: 4) {\n ... on NewsPage {\n ...News\n }\n }\n }\n ": types.HomeDocument,
|
||||
"\n fragment OneLevelOfBlocks on StreamFieldInterface {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n ... on ImageWithTextBlock {\n image {\n ...Image\n }\n imageFormat\n text\n }\n ... on ImageSliderBlock {\n images {\n ... on ImageSliderItemBlock {\n image {\n ...Image\n }\n text\n }\n }\n }\n ... on HorizontalRuleBlock {\n color\n }\n ... on FeaturedBlock {\n title\n featuredBlockText: text\n linkText\n imagePosition\n featuredPage {\n contentType\n pageType\n url\n ... on EventPage {\n featuredImage {\n ...Image\n }\n }\n ... on NewsPage {\n featuredImage {\n ...Image\n }\n }\n }\n featuredImageOverride {\n ...Image\n }\n }\n }\n": types.OneLevelOfBlocksFragmentDoc,
|
||||
"\n fragment Blocks on StreamFieldInterface {\n ... on PageSectionBlock {\n title\n backgroundColor\n body {\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n": types.BlocksFragmentDoc,
|
||||
"\n fragment OneLevelOfBlocks on StreamFieldInterface {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n ... on ImageWithTextBlock {\n image {\n ...Image\n }\n imageFormat\n text\n }\n ... on ImageSliderBlock {\n images {\n ... on ImageSliderItemBlock {\n image {\n ...Image\n }\n text\n }\n }\n }\n ... on HorizontalRuleBlock {\n color\n }\n ... on FeaturedBlock {\n title\n featuredBlockText: text\n linkText\n imagePosition\n featuredPage {\n contentType\n pageType\n url\n ... on EventPage {\n featuredImage {\n ...Image\n }\n }\n ... on NewsPage {\n featuredImage {\n ...Image\n }\n }\n }\n featuredImageOverride {\n ...Image\n }\n }\n ... on ContactListBlock {\n items {\n blockType\n ... on ContactEntityBlock {\n contactEntity {\n ...ContactEntity\n }\n }\n }\n }\n }\n": types.OneLevelOfBlocksFragmentDoc,
|
||||
"\n fragment Blocks on StreamFieldInterface {\n ... on PageSectionBlock {\n title\n backgroundColor\n body {\n ...OneLevelOfBlocks\n }\n }\n ... on ContactSectionBlock {\n title\n text\n blocks {\n ... on ContactSubsectionBlock {\n title\n text\n blocks {\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n": types.BlocksFragmentDoc,
|
||||
"\n fragment Image on CustomImage {\n id\n url\n width\n height\n alt\n attribution\n }\n": types.ImageFragmentDoc,
|
||||
"\n fragment ContactEntity on ContactEntity {\n id\n name\n contactType\n title\n email\n phoneNumber\n image {\n ...Image\n }\n }\n": types.ContactEntityFragmentDoc,
|
||||
"\n fragment Event on EventPage {\n __typename\n id\n slug\n title\n body {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n }\n featuredImage {\n ...Image\n }\n pig\n facebookUrl\n ticketUrl\n free\n priceRegular\n priceMember\n priceStudent\n categories {\n ... on EventCategory {\n name\n slug\n pig\n }\n }\n occurrences {\n ... on EventOccurrence {\n __typename\n id\n start\n end\n venue {\n __typename\n id\n slug\n title\n preposition\n url\n }\n }\n }\n organizers {\n ... on EventOrganizer {\n id\n name\n slug\n externalUrl\n association {\n ... on AssociationPage {\n url\n }\n }\n }\n }\n }\n": types.EventFragmentDoc,
|
||||
"\n query futureEvents {\n events: eventIndex {\n ... on EventIndex {\n futureEvents {\n ... on EventPage {\n ...Event\n }\n }\n }\n }\n eventCategories: eventCategories {\n ... on EventCategory {\n name\n slug\n showInFilters\n }\n }\n eventOrganizers: eventOrganizers {\n ... on EventOrganizer {\n id\n name\n slug\n externalUrl\n association {\n ... on AssociationPage {\n url\n }\n }\n }\n }\n }\n": types.FutureEventsDocument,
|
||||
"\n fragment News on NewsPage {\n __typename\n id\n slug\n title\n firstPublishedAt\n excerpt\n featuredImage {\n ...Image\n }\n body {\n ...Blocks\n }\n }\n": types.NewsFragmentDoc,
|
||||
@ -103,6 +106,14 @@ export function graphql(source: "\n fragment Association on AssociationPage {\n
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n query allAssociations {\n index: associationIndex {\n ... on AssociationIndex {\n ...AssociationIndex\n }\n }\n associations: pages(contentType: \"associations.AssociationPage\") {\n ... on AssociationPage {\n ...Association\n }\n }\n }\n "): (typeof documents)["\n query allAssociations {\n index: associationIndex {\n ... on AssociationIndex {\n ...AssociationIndex\n }\n }\n associations: pages(contentType: \"associations.AssociationPage\") {\n ... on AssociationPage {\n ...Association\n }\n }\n }\n "];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment ContactIndex on ContactIndex {\n ... on ContactIndex {\n title\n lead\n body {\n ...Blocks\n }\n }\n }\n"): (typeof documents)["\n fragment ContactIndex on ContactIndex {\n ... on ContactIndex {\n title\n lead\n body {\n ...Blocks\n }\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n query contacts {\n contactIndex {\n ... on ContactIndex {\n ...ContactIndex\n }\n }\n }\n "): (typeof documents)["\n query contacts {\n contactIndex {\n ... on ContactIndex {\n ...ContactIndex\n }\n }\n }\n "];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
@ -130,15 +141,19 @@ export function graphql(source: "\n query home {\n events: eventIndex {\
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment OneLevelOfBlocks on StreamFieldInterface {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n ... on ImageWithTextBlock {\n image {\n ...Image\n }\n imageFormat\n text\n }\n ... on ImageSliderBlock {\n images {\n ... on ImageSliderItemBlock {\n image {\n ...Image\n }\n text\n }\n }\n }\n ... on HorizontalRuleBlock {\n color\n }\n ... on FeaturedBlock {\n title\n featuredBlockText: text\n linkText\n imagePosition\n featuredPage {\n contentType\n pageType\n url\n ... on EventPage {\n featuredImage {\n ...Image\n }\n }\n ... on NewsPage {\n featuredImage {\n ...Image\n }\n }\n }\n featuredImageOverride {\n ...Image\n }\n }\n }\n"): (typeof documents)["\n fragment OneLevelOfBlocks on StreamFieldInterface {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n ... on ImageWithTextBlock {\n image {\n ...Image\n }\n imageFormat\n text\n }\n ... on ImageSliderBlock {\n images {\n ... on ImageSliderItemBlock {\n image {\n ...Image\n }\n text\n }\n }\n }\n ... on HorizontalRuleBlock {\n color\n }\n ... on FeaturedBlock {\n title\n featuredBlockText: text\n linkText\n imagePosition\n featuredPage {\n contentType\n pageType\n url\n ... on EventPage {\n featuredImage {\n ...Image\n }\n }\n ... on NewsPage {\n featuredImage {\n ...Image\n }\n }\n }\n featuredImageOverride {\n ...Image\n }\n }\n }\n"];
|
||||
export function graphql(source: "\n fragment OneLevelOfBlocks on StreamFieldInterface {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n ... on ImageWithTextBlock {\n image {\n ...Image\n }\n imageFormat\n text\n }\n ... on ImageSliderBlock {\n images {\n ... on ImageSliderItemBlock {\n image {\n ...Image\n }\n text\n }\n }\n }\n ... on HorizontalRuleBlock {\n color\n }\n ... on FeaturedBlock {\n title\n featuredBlockText: text\n linkText\n imagePosition\n featuredPage {\n contentType\n pageType\n url\n ... on EventPage {\n featuredImage {\n ...Image\n }\n }\n ... on NewsPage {\n featuredImage {\n ...Image\n }\n }\n }\n featuredImageOverride {\n ...Image\n }\n }\n ... on ContactListBlock {\n items {\n blockType\n ... on ContactEntityBlock {\n contactEntity {\n ...ContactEntity\n }\n }\n }\n }\n }\n"): (typeof documents)["\n fragment OneLevelOfBlocks on StreamFieldInterface {\n id\n blockType\n field\n ... on RichTextBlock {\n rawValue\n value\n }\n ... on ImageWithTextBlock {\n image {\n ...Image\n }\n imageFormat\n text\n }\n ... on ImageSliderBlock {\n images {\n ... on ImageSliderItemBlock {\n image {\n ...Image\n }\n text\n }\n }\n }\n ... on HorizontalRuleBlock {\n color\n }\n ... on FeaturedBlock {\n title\n featuredBlockText: text\n linkText\n imagePosition\n featuredPage {\n contentType\n pageType\n url\n ... on EventPage {\n featuredImage {\n ...Image\n }\n }\n ... on NewsPage {\n featuredImage {\n ...Image\n }\n }\n }\n featuredImageOverride {\n ...Image\n }\n }\n ... on ContactListBlock {\n items {\n blockType\n ... on ContactEntityBlock {\n contactEntity {\n ...ContactEntity\n }\n }\n }\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment Blocks on StreamFieldInterface {\n ... on PageSectionBlock {\n title\n backgroundColor\n body {\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n"): (typeof documents)["\n fragment Blocks on StreamFieldInterface {\n ... on PageSectionBlock {\n title\n backgroundColor\n body {\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n"];
|
||||
export function graphql(source: "\n fragment Blocks on StreamFieldInterface {\n ... on PageSectionBlock {\n title\n backgroundColor\n body {\n ...OneLevelOfBlocks\n }\n }\n ... on ContactSectionBlock {\n title\n text\n blocks {\n ... on ContactSubsectionBlock {\n title\n text\n blocks {\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n"): (typeof documents)["\n fragment Blocks on StreamFieldInterface {\n ... on PageSectionBlock {\n title\n backgroundColor\n body {\n ...OneLevelOfBlocks\n }\n }\n ... on ContactSectionBlock {\n title\n text\n blocks {\n ... on ContactSubsectionBlock {\n title\n text\n blocks {\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n }\n ...OneLevelOfBlocks\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment Image on CustomImage {\n id\n url\n width\n height\n alt\n attribution\n }\n"): (typeof documents)["\n fragment Image on CustomImage {\n id\n url\n width\n height\n alt\n attribution\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment ContactEntity on ContactEntity {\n id\n name\n contactType\n title\n email\n phoneNumber\n image {\n ...Image\n }\n }\n"): (typeof documents)["\n fragment ContactEntity on ContactEntity {\n id\n name\n contactType\n title\n email\n phoneNumber\n image {\n ...Image\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
|
File diff suppressed because one or more lines are too long
@ -37,6 +37,31 @@ export function unique<T>(array: any[]): any[] {
|
||||
return Array.from(array.reduce((set, item) => set.add(item), new Set()));
|
||||
}
|
||||
|
||||
export function stripWhitespace(s: string): string {
|
||||
return s.replace(/\s/g, "");
|
||||
}
|
||||
|
||||
export function formatPhoneE164(phone: string): string {
|
||||
phone = stripWhitespace(phone);
|
||||
if (phone.startsWith("+") || phone.length != 8) {
|
||||
return phone;
|
||||
}
|
||||
return "+47" + phone;
|
||||
}
|
||||
|
||||
export function formatNorwegianPhoneNumber(phone: string): string {
|
||||
if (phone.startsWith("+47")) {
|
||||
const local = phone.substring(3);
|
||||
if (local.length === 8) {
|
||||
return `${local.substring(0, 3)} ${local.substring(
|
||||
3,
|
||||
5
|
||||
)} ${local.substring(5)}`;
|
||||
}
|
||||
}
|
||||
return phone;
|
||||
}
|
||||
|
||||
const OneLevelOfBlocksFragmentDefinition = graphql(`
|
||||
fragment OneLevelOfBlocks on StreamFieldInterface {
|
||||
id
|
||||
@ -90,6 +115,16 @@ const OneLevelOfBlocksFragmentDefinition = graphql(`
|
||||
...Image
|
||||
}
|
||||
}
|
||||
... on ContactListBlock {
|
||||
items {
|
||||
blockType
|
||||
... on ContactEntityBlock {
|
||||
contactEntity {
|
||||
...ContactEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
@ -102,6 +137,20 @@ const BlockFragmentDefinition = graphql(`
|
||||
...OneLevelOfBlocks
|
||||
}
|
||||
}
|
||||
... on ContactSectionBlock {
|
||||
title
|
||||
text
|
||||
blocks {
|
||||
... on ContactSubsectionBlock {
|
||||
title
|
||||
text
|
||||
blocks {
|
||||
...OneLevelOfBlocks
|
||||
}
|
||||
}
|
||||
...OneLevelOfBlocks
|
||||
}
|
||||
}
|
||||
...OneLevelOfBlocks
|
||||
}
|
||||
`);
|
||||
@ -116,3 +165,17 @@ const ImageFragmentDefinition = graphql(`
|
||||
attribution
|
||||
}
|
||||
`);
|
||||
|
||||
const ContactEntityFragmentDefinition = graphql(`
|
||||
fragment ContactEntity on ContactEntity {
|
||||
id
|
||||
name
|
||||
contactType
|
||||
title
|
||||
email
|
||||
phoneNumber
|
||||
image {
|
||||
...Image
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
Reference in New Issue
Block a user