import { useEffect } from 'react'; import { useMediaQuery } from '@chakra-ui/react'; import { useNavigate } from '@tanstack/react-router'; import ContactPanel from '@/components/ContactPanel/ContactPanel'; import PageSection from '@/components/PageSection/PageSection'; import Reveal from '@/components/Reveal/Reveal'; import SectionHeading from '@/components/SectionHeading/SectionHeading'; import type { EmailAddress, HomeContent, PricingPackage, } from '@/content/types'; const TITLE_ID = 'contact-title'; type ContactSectionProps = { content: HomeContent['contact']; packages: PricingPackage[]; enabled: boolean; email: EmailAddress; replyTime: string; // ?pakket= from a "Boek ..." link on a price card pakket?: string; }; // "Contact" on the homepage (design #contact): heading and lead, and the // contact form, which sits far below the hero and so loads lazily. After a // "Boek ..." click it tidies the URL and moves focus here (BR-PARAM-02, // BR-FOCUS-01); the panel takes over the package itself. export default function ContactSection({ content, packages, enabled, email, replyTime, pakket, }: ContactSectionProps) { const navigate = useNavigate(); // Remove ?pakket= from the address bar (no extra history entry) and // continue keyboard and screen reader users here. This navigation // replaces the "Boek" click's before the router has scrolled for it, so // it must ask the router to scroll to #contact itself. const [reducedMotion] = useMediaQuery( ['(prefers-reduced-motion: reduce)'], { ssr: false }, ); useEffect(() => { if (pakket === undefined) return; void navigate({ to: '/', search: {}, hash: 'contact', replace: true, resetScroll: false, hashScrollIntoView: { behavior: reducedMotion ? 'auto' : 'smooth', block: 'start', }, }); document.getElementById(TITLE_ID)?.focus({ preventScroll: true }); // Only when a new ?pakket= arrives, not when the motion setting changes // eslint-disable-next-line react-hooks/exhaustive-deps }, [pakket, navigate]); return ( ); }