import Hero from "@/components/website/hero";
import OurClients from "@/components/website/home/our-clients";
import OurServices from "@/components/website/home/our-services";
import OurWorks from "@/components/website/home/our-works";
import Testimonials from "@/components/website/home/testimonials";
import WhoWeAre from "@/components/website/home/who-we-are";
import type { Metadata } from "next";
import { getTranslations } from "next-intl/server";
import { getWebsiteHomePageData } from "@/lib/api/website/home-api";

export async function generateMetadata({
  params,
}: {
  params: Promise<{ locale: string }>;
}): Promise<Metadata> {
  const { locale } = await params;
  const t = await getTranslations({ locale, namespace: "metadata" });

  return {
    title: t("title"),
    description: t("description"),
  };
}

export default async function Home({
  params,
}: {
  params: Promise<{ locale: string }>;
}): Promise<React.ReactNode> {
  const { locale } = await params;
  const t = await getTranslations();
  const homeData = await getWebsiteHomePageData(locale);

  console.log("homeData:", homeData);

  return (
    <>
      <Hero
        welcomeText={homeData.hero?.welcomeText ?? t("hero.welcomeText")}
        title={homeData.hero?.title ?? t("hero.mainTitle")}
        description={homeData.hero?.description ?? t("hero.mainDescription")}
        ctaText={homeData.hero?.ctaText ?? t("hero.ctaText")}
        ctaHref={homeData.hero?.ctaHref ?? "/about-us"}
        videoText={homeData.hero?.videoText ?? t("hero.videoText")}
        videoHref={homeData.hero?.videoHref}
        backgroundSrc={homeData.hero?.background?.src ?? "/images/hero/hero-bg.jpg"}
        backgroundAlt={homeData.hero?.background?.alt ?? t("hero.backgroundAlt")}
      />
      <OurClients title={homeData.sections.partners?.title} partners={homeData.partners} />
      <WhoWeAre section={homeData.sections.whoWeAre} />
      <OurServices section={homeData.sections.services} items={homeData.services} />
      <OurWorks section={homeData.sections.works} items={homeData.works} />
      <Testimonials section={homeData.sections.testimonials} items={homeData.testimonials} />
    </>
  );
}
