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 = await prisma.gallery.findMany({
    orderBy: { createdAt: 'desc' }
  });

  const dbServices = await prisma.service.findMany({
    orderBy: { createdAt: 'asc' }
  });

  const heroMediaList = await prisma.heroMedia.findMany();
  const dbHeroMedia = heroMediaList.length > 0 ? heroMediaList[0] : null;

  const dbSettings = await prisma.siteSettings.findFirst();

  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>
  );
}
