import Navbar from '@/components/Navbar';
import Hero from '@/components/Hero';
import About from '@/components/About';
import Accommodation from '@/components/Accommodation';
import Beach from '@/components/Beach';
import Dining from '@/components/Dining';
import Events from '@/components/Events';
import Gallery from '@/components/Gallery';
import Contact from '@/components/Contact';
import Footer from '@/components/Footer';
import WhatsAppButton from '@/components/WhatsAppButton';
import WelcomePopup from '@/components/WelcomePopup';
import { getEvents } from '@/app/actions/events';
import { getGalleryImages } from '@/app/actions/gallery';
import { getContactSettings } from '@/app/actions/contact';
import { getBeachSettings } from '@/app/actions/beach';
import { getAboutSettings } from '@/app/actions/about';
import { getInstagramPosts } from '@/app/actions/instagram';
import InstagramFeed from '@/components/InstagramFeed';

export default async function Page({
  params
}: {
  params: Promise<{ locale: string }>
}) {
  const { locale } = await params;
  const eventsResult = await getEvents();
  const dbEvents = eventsResult.success ? eventsResult.data : [];
  
  const galleryResult = await getGalleryImages();
  const dbGallery = galleryResult.success ? galleryResult.data : [];

  const contactResult = await getContactSettings();
  const dbContact = contactResult.success ? contactResult.data : null;

  const beachResult = await getBeachSettings();
  const dbBeach = beachResult.success ? beachResult.data : null;

  const aboutResult = await getAboutSettings();
  const dbAbout = aboutResult.success ? aboutResult.data : null;

  const instaResult = await getInstagramPosts();
  const instaPosts = instaResult.success ? instaResult.data : [];

  return (
    <main className="min-h-screen bg-cream selection:bg-turquoise selection:text-white">
      <Navbar locale={locale} />
      <Hero />
      <About dbAbout={dbAbout} />

      <Beach dbBeach={dbBeach} />
      <Dining />
      <Events dbEvents={dbEvents} />
      <Gallery dbGallery={dbGallery} />
      <InstagramFeed posts={instaPosts} />
      <Contact dbContact={dbContact} />
      <Footer />
      <WhatsAppButton />
      <WelcomePopup />
    </main>
  );
}
