---
import Layout from '@/layouts/base.astro';
import ContactForm from '@/components/sections/contact';
import ShortHero from '@/components/ui/short-hero';
import { getCollection } from 'astro:content';
import { getLocale } from '@/lib/locale';
import general from '../content/settings/general.json';

const locale = getLocale(Astro);

const [contactEntry] = await getCollection('contact', (e) => e.id === `${locale}/main`);
if (!contactEntry) throw new Error(`Missing contact content for locale: ${locale}`);

const contact = contactEntry.data;
---

<Layout
  title={contact.title}
  description={`Contactez Cachet Peintres Décorateurs — ${general.phone} — ${general.email}. Nous servons la Rive Sud, le Grand Montréal et les environs.`}
  canonical="/contact"
>
  <ShortHero
    client:load
    content={{  
      title: contact.title,
      subtitle: contact.subtitle,
      imageSrc: "/images/short-hero.webp",
      imageAlt: "Peintres décorateurs au travail",
    }}
  />

  <ContactForm
    client:load
    phoneLabel={contact.phone}
    phoneValue={general.phone}
    emailLabel={contact.email}
    emailValue={general.email}
    addressLabel={contact.address}
    addressValue={general.address}
    serviceAreaLabel={contact.serviceAreaLabel}
    serviceArea={general.serviceArea}
  />
</Layout>
