import { Suspense } from 'react'
import Container from '@/components/frontend/Container'
import HeroSection from '@/components/frontend/home/HeroSection'
import FeaturesSection from '@/components/frontend/home/FeaturesSection'
import CategoryCarousel from '@/components/frontend/home/CategoryCarousel'
import FlashSale from '@/components/frontend/home/FlashSale'
import CategoryProducts from '@/components/frontend/home/CategoryProducts'
import TestimonialsSection from '@/components/frontend/home/TestimonialsSection'
import { PromoRow, PromoPair, WideBanner } from '@/components/frontend/home/blocks/BannerSections'
import { SectionSkeleton } from '@/components/frontend/skeletons/Skeletons'
import type { HomeBanners } from '@/lib/db/queries/getHeroBanners'

// Design 1 — "Classic": the original homepage, plus the admin's promo banner
// slots. The hero and category row are deliberately NOT suspended: above the
// fold, cached and fast, and a skeleton swap there is a large layout shift
// (Lighthouse measured CLS 0.83 when they were). Below-the-fold DB sections
// stream in their own <Suspense> boundaries.
export default function HomeClassic({ banners }: { banners: HomeBanners }) {
  return (
    <Container>
      <HeroSection slides={banners.hero} />
      <CategoryCarousel />
      <div className="my-12 empty:hidden">
        <PromoRow banners={banners.top} variant="classic" />
      </div>
      <FeaturesSection />
      <Suspense fallback={<SectionSkeleton />}>
        <FlashSale />
      </Suspense>
      <div className="my-16 empty:hidden">
        <PromoPair banners={banners.middle} variant="classic" />
      </div>
      <Suspense fallback={<SectionSkeleton />}>
        <CategoryProducts />
      </Suspense>
      <Suspense fallback={<SectionSkeleton count={3} />}>
        <TestimonialsSection />
      </Suspense>
      <div className="my-16 empty:hidden">
        <WideBanner banners={banners.bottom} variant="classic" />
      </div>
    </Container>
  )
}
