mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
✨ feat: featured product sub text
:%s
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
import { ProductCard } from '@commerce/types/product';
|
||||
import { ProductVariables } from '@framework/api/operations/get-all-products';
|
||||
import { FacetValue } from '@framework/schema';
|
||||
import commerce from '@lib/api/commerce';
|
||||
import { GetStaticPropsContext } from 'next';
|
||||
import { Layout } from 'src/components/common';
|
||||
import { FeaturedProductsCarousel, FreshProducts, HomeBanner, HomeCategories, HomeCollection, HomeCTA, HomeFeature, HomeRecipe, HomeSubscribe, HomeVideo } from 'src/components/modules/home';
|
||||
import HomeSpice from 'src/components/modules/home/HomeSpice/HomeSpice';
|
||||
import { getAllFeaturedFacetId, getFreshFacetId } from 'src/utils/funtion.utils';
|
||||
import { getAllFeaturedFacetId, getAllFeaturedFacetValue, getFreshFacetId } from 'src/utils/funtion.utils';
|
||||
|
||||
interface Props {
|
||||
featuredFacetsValue: FacetValue[],
|
||||
freshProducts: ProductCard[],
|
||||
featuredProducts: ProductCard[],
|
||||
|
||||
}
|
||||
export default function Home({ freshProducts, featuredProducts }: Props) {
|
||||
export default function Home({ featuredFacetsValue,
|
||||
freshProducts, featuredProducts }: Props) {
|
||||
return (
|
||||
<>
|
||||
<HomeBanner />
|
||||
@@ -22,7 +25,7 @@ export default function Home({ freshProducts, featuredProducts }: Props) {
|
||||
<HomeCollection />
|
||||
<HomeVideo />
|
||||
<HomeSpice />
|
||||
<FeaturedProductsCarousel data={featuredProducts} />
|
||||
<FeaturedProductsCarousel data={featuredProducts} featuredFacetsValue={featuredFacetsValue} />
|
||||
<HomeCTA />
|
||||
<HomeRecipe />
|
||||
<HomeSubscribe />
|
||||
@@ -45,7 +48,7 @@ export async function getStaticProps({
|
||||
config,
|
||||
preview,
|
||||
})
|
||||
|
||||
const featuredFacetsValue = getAllFeaturedFacetValue(facets)
|
||||
|
||||
const freshProductvariables: ProductVariables = {}
|
||||
const freshFacetId = getFreshFacetId(facets)
|
||||
@@ -60,7 +63,6 @@ export async function getStaticProps({
|
||||
})
|
||||
|
||||
const allFeaturedFacetId = getAllFeaturedFacetId(facets)
|
||||
console.log("featured** ", allFeaturedFacetId)
|
||||
const featuredProductsPromise = commerce.getAllProducts({
|
||||
variables: {
|
||||
facetValueIds: allFeaturedFacetId
|
||||
@@ -78,6 +80,7 @@ export async function getStaticProps({
|
||||
return {
|
||||
props: {
|
||||
facets,
|
||||
featuredFacetsValue,
|
||||
freshProducts: freshFacetId ? rs[0].products : [],
|
||||
featuredProducts: rs[1].products
|
||||
},
|
||||
|
Reference in New Issue
Block a user