---
import { getCollection } from 'astro:content';
import { getLocale } from '@/lib/locale';
import general from '../content/settings/general.json';
import FooterAnimated from '@/components/ui/footer-animated';

const locale = getLocale(Astro);
const [footerEntry] = await getCollection('footer', (e) => e.id === `${locale}/main`);
const [navEntry] = await getCollection('navigation', (e) => e.id === `${locale}/main`);
if (!footerEntry || !navEntry) throw new Error(`Missing footer or navigation for locale: ${locale}`);

const footer = footerEntry.data;
const navLinks = navEntry.data.links;
const year = new Date().getFullYear();
const legalNotice = footer.legal.replace('{year}', String(year));
---

<FooterAnimated
  client:visible
  siteName={general.siteName}
  serviceArea={general.serviceArea}
  phone={general.phone}
  email={general.email}
  address={general.address}
  facebook={general.facebook}
  instagram={general.instagram}
  linkedin={general.linkedin}
  footer={footer}
  navLinks={navLinks}
  legalNotice={legalNotice}
/>
