import Header from "@/components/Header";
import Hero from "@/components/Hero";
import About from "@/components/About";
import Services from "@/components/Services";
import Gallery from "@/components/Gallery";
import InstagramFeed from "@/components/InstagramFeed";
import Contact from "@/components/Contact";
import Footer from "@/components/Footer";
import { getDictionary } from "../dictionaries";
import { prisma } from "@/lib/db";

export default async function Home({ params }: { params: Promise<{ lang: string }> }) {
  const { lang } = await params;
  const dict = await getDictionary(lang);
  
  const [dbPhotos, dbServices, heroMediaList, dbSettings] = await Promise.all([
    prisma.gallery.findMany({ orderBy: { createdAt: 'desc' } }),
    prisma.service.findMany({ orderBy: { createdAt: 'asc' } }),
    prisma.heroMedia.findMany(),
    prisma.siteSettings.findFirst()
  ]);

  const dbHeroMedia = heroMediaList.length > 0 ? heroMediaList[0] : null;

  return (
    <main className="min-h-screen bg-brand-white">
      <Header dict={dict} lang={lang} dbSettings={dbSettings} />
      <Hero dict={dict} dbHeroMedia={dbHeroMedia} />
      <About dict={dict} />
      <Services dict={dict} dbServices={dbServices} />
      <Gallery dict={dict} dbPhotos={dbPhotos} />
      <InstagramFeed dict={dict} />
      <Contact dict={dict} dbSettings={dbSettings} />
      <Footer dict={dict} dbSettings={dbSettings} />
    </main>
  );
}
