import ProductSlider from '@/lib/product/components/ProductSlider'
import useCategoryHome from '../hooks/useCategoryHome'
import PopularProductSkeleton from './Skeleton/PopularProductSkeleton'

const CategoryHome = ({ id }) => {
  const { categoryHome } = useCategoryHome({ id })

  return (
    <div className='p-4 sm:py-8 relative bg-warning-100 border border-warning-300 min-h-[240px]'>
      {categoryHome.data ? (
        <ProductSlider
          products={{
            products: categoryHome.data?.[0].products,
            banner: {
              image: categoryHome.data?.[0].image,
              name: categoryHome.data?.[0].name,
              url: categoryHome.data?.[0].url
            }
          }}
          simpleTitle
          bannerMode
        />
      ) : (
        <PopularProductSkeleton />
      )}
    </div>
  )
}

export default CategoryHome
