diff --git a/pages/index.tsx b/pages/index.tsx index 55988ada1..d06f29013 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,5 @@ +import { ProductCard } from '@commerce/types/product'; import { ProductVariables } from '@framework/api/operations/get-all-products'; -import { Product } from '@framework/schema'; import commerce from '@lib/api/commerce'; import { GetStaticPropsContext } from 'next'; import { Layout } from 'src/components/common'; @@ -8,8 +8,8 @@ import HomeSpice from 'src/components/modules/home/HomeSpice/HomeSpice'; import { getAllFeaturedFacetId, getFreshProductFacetId } from 'src/utils/funtion.utils'; interface Props { - freshProducts: Product[], - featuredProducts: Product[], + freshProducts: ProductCard[], + featuredProducts: ProductCard[], } export default function Home({ freshProducts, featuredProducts }: Props) { @@ -74,7 +74,7 @@ export async function getStaticProps({ return { props: { - freshProducts: rs[0].products, + freshProducts: freshFacetId ? rs[0].products : [], featuredProducts: rs[1].products }, revalidate: 60, diff --git a/src/components/modules/home/FreshProducts/FreshProducts.tsx b/src/components/modules/home/FreshProducts/FreshProducts.tsx index 586a572dd..33b872032 100644 --- a/src/components/modules/home/FreshProducts/FreshProducts.tsx +++ b/src/components/modules/home/FreshProducts/FreshProducts.tsx @@ -1,11 +1,15 @@ +import { ProductCard } from '@commerce/types/product' import { Product } from '@framework/schema' import React from 'react' import { CollectionCarcousel } from '..' interface FreshProductsProps { - data: Product[] + data: ProductCard[] } -const FreshProducts = ({data}: FreshProductsProps) => { +const FreshProducts = ({ data }: FreshProductsProps) => { + if (data.length === 0) { + return null + } return (