Skip to content

Commit b89a213

Browse files
committed
refactor: contactpagecontent to contactsection & allowed rendering other
blocks in the contact section
1 parent d768064 commit b89a213

3 files changed

Lines changed: 15 additions & 20 deletions

File tree

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { ContactPageContent } from "@/components/ContactPageContent"
1+
import { PageBlocks } from "@/components/ui/PageBlockRenderer"
22
import { LandingContainer } from "@/components/ui/LandingContainer"
33
import { createLandingMetadata, getPageLocale, type LocalePageParams } from "@/lib/appRoute"
44
import { getLandingPage } from "@/lib/cms"
5-
import { findPageBlock } from "@/lib/pageBlocks"
65
import { notFound } from "next/navigation"
76

87
export const generateMetadata = createLandingMetadata("contact")
@@ -12,13 +11,10 @@ export default async function ContactPage({ params }: { params: LocalePageParams
1211
const page = await getLandingPage("contact", locale)
1312
if (!page) notFound()
1413

15-
const contactBlock = findPageBlock(page, "contact")
16-
1714
return (
18-
<LandingContainer className="pt-32">
19-
<div className="mx-auto w-full max-w-5xl">
20-
<ContactPageContent locale={locale} contactBlock={contactBlock} />
21-
</div>
15+
<LandingContainer>
16+
<div className="h-28" aria-hidden="true" />
17+
<PageBlocks blocks={page.layout} locale={locale} />
2218
</LandingContainer>
2319
)
2420
}

src/components/ContactPageContent.tsx renamed to src/components/sections/ContactSection.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
"use client"
22

33
import { ContactForm } from "@/components/forms/ContactForm"
4+
import { useDesktopPinnedPosition } from "@/hooks/useDesktopPinnedPosition"
45
import type { ContactLayoutBlock } from "@/lib/cms"
56
import type { AppLocale } from "@/lib/i18n"
6-
import { useDesktopPinnedPosition } from "@/hooks/useDesktopPinnedPosition"
77

8-
interface ContactPageContentProps {
8+
interface ContactSectionProps {
99
locale: AppLocale
10-
contactBlock: ContactLayoutBlock | null
10+
content?: ContactLayoutBlock | null
1111
}
1212

13-
export function ContactPageContent({ locale, contactBlock }: ContactPageContentProps) {
13+
export function ContactSection({ locale, content }: ContactSectionProps) {
1414
const desktopTopOffset = 128
15-
const pageHeading = contactBlock?.heading ?? "Contact us"
16-
const pageDescription = contactBlock?.description ?? "Contact us if you want to know more about CodeZero."
15+
const pageHeading = content?.heading ?? "Contact us"
16+
const pageDescription = content?.description ?? "Contact us if you want to know more about CodeZero."
1717

1818
const { wrapperRef: desktopWrapperRef, containerRef: desktopContainerRef } = useDesktopPinnedPosition<HTMLElement, HTMLDivElement>(desktopTopOffset)
1919

2020
return (
21-
<div className="grid gap-8 lg:grid-cols-2">
21+
<div className="mx-auto grid w-full max-w-5xl gap-8 lg:grid-cols-2">
2222
<section className="min-w-0">
2323
<h1 className="text-4xl font-semibold text-white">{pageHeading}</h1>
2424
<p className="mt-4 text-secondary">{pageDescription}</p>
2525
</section>
2626

2727
<section ref={desktopWrapperRef} className="relative min-w-0">
28-
<div
29-
ref={desktopContainerRef}
30-
className="relative z-10"
31-
>
32-
<ContactForm content={contactBlock} locale={locale} />
28+
<div ref={desktopContainerRef} className="relative z-10">
29+
<ContactForm content={content} locale={locale} />
3330
</div>
3431
</section>
3532
</div>

src/components/ui/PageBlockRenderer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { ActionListSection } from "../sections/ActionListSection"
2929
import { SubscriptionConfiguratorSection, type SubscriptionIcons } from "../sections/SubscriptionConfiguratorSection"
3030
import { PricingSection } from "../sections/PricingSection"
3131
import { SmallPricingSection } from "../sections/SmallPricingSection"
32+
import { ContactSection } from "../sections/ContactSection"
3233
import { getIcon } from "@/components/ui/IconRenderer"
3334
import type { ActionItem, SubscriptionConfigData, SubscriptionConfiguratorBlockData } from "@/lib/cms"
3435

@@ -183,6 +184,7 @@ const pageBlockRenderers: Partial<Record<PageBlock["blockType"], BlockRenderer>>
183184

184185
return <SmallPricingSection content={block as Extract<PageBlock, { blockType: "smallPricing" }>} locale={options.locale ?? "en"} packages={config.packages} />
185186
},
187+
contact: (block, options) => <ContactSection content={block as Extract<PageBlock, { blockType: "contact" }>} locale={options.locale ?? "en"} />,
186188
}
187189

188190
function renderPageBlock(block: PageBlock, options: PageBlockRenderOptions) {

0 commit comments

Comments
 (0)