push code to check

This commit is contained in:
Tan Le
2021-10-07 10:46:20 +07:00
parent 46e834bf0d
commit 8b5637a247
4 changed files with 81 additions and 16 deletions

View File

@@ -1,17 +1,17 @@
import commerce from '@lib/api/commerce';
import { GetStaticPropsContext } from 'next';
import { Layout } from 'src/components/common';
import { ProductCard } from '@commerce/types/product';
interface Props {
products: any
productDetail: ProductCard[],
}
export default function Home({ products }: Props) {
export default function Home({ productDetail }: Props) {
return (
<>
<p>
TOTAL: {products?.length}
TOTAL: {productDetail}
</p>
{JSON.stringify(products[0])}
{/* {JSON.stringify(productDetail)} */}
</>
)
}
@@ -23,10 +23,11 @@ export async function getServerSideProps({
locales,
}: GetStaticPropsContext) {
const config = { locale, locales }
const productsPromise = commerce.getAllProducts({
const productsPromise = commerce.getProduct({
// const productsPromise = commerce.getAllFacets({
variables: {
first: 70,
slug: "hand-trowel"
// filter: {
// name: {
// contains: 'ca'
@@ -34,16 +35,15 @@ export async function getServerSideProps({
// }
},
config,
preview,
// preview,
// Saleor provider only
...({ featured: true } as any),
})
const { products } = await productsPromise
const { product } = await productsPromise
const productDetail = JSON.stringify(product)
return {
props: { products },
props: { productDetail },
}
}