2020-10-01 14:53:29 -05:00
|
|
|
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import getProduct from 'lib/bigcommerce/api/operations/get-product';
|
|
|
|
import { Layout } from '@components/core';
|
|
|
|
import { ProductView } from '@components/product';
|
|
|
|
|
|
|
|
export async function getStaticProps({
|
|
|
|
params,
|
|
|
|
}: GetStaticPropsContext<{ slug: string }>) {
|
|
|
|
const { product } = await getProduct({ variables: { slug: params!.slug } });
|
|
|
|
|
|
|
|
console.log('PRODUCT', product);
|
2020-09-29 16:02:09 -03:00
|
|
|
|
|
|
|
const productData = {
|
2020-10-01 14:53:29 -05:00
|
|
|
title: 'T-Shirt',
|
2020-09-29 16:02:09 -03:00
|
|
|
description: `
|
|
|
|
Nothing undercover about this tee. Nope. This is the official Bad
|
|
|
|
Boys tee. Printed in white or black ink on Black, Brown, or Oatmeal.
|
|
|
|
Like everything in this collection, it is extremely limited edition
|
|
|
|
and available for 10 days only. This is a limited edition production
|
|
|
|
run. Printing starts when the drop ends. Reminder: Bad Boys For
|
|
|
|
Life. Shipping may take 10+ days due to COVID-19.
|
|
|
|
`,
|
2020-10-01 14:53:29 -05:00
|
|
|
price: '$50',
|
|
|
|
colors: ['black', 'white', 'pink'],
|
|
|
|
sizes: ['s', 'm', 'l', 'xl', 'xxl'],
|
2020-09-29 16:02:09 -03:00
|
|
|
};
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
productData,
|
|
|
|
},
|
2020-09-29 19:13:06 -03:00
|
|
|
revalidate: 200,
|
2020-09-29 16:02:09 -03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getStaticPaths() {
|
|
|
|
return {
|
|
|
|
paths: [],
|
2020-10-01 14:53:29 -05:00
|
|
|
fallback: 'unstable_blocking',
|
2020-09-29 16:02:09 -03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-01 14:53:29 -05:00
|
|
|
export default function Home({
|
|
|
|
productData,
|
|
|
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
2020-09-29 16:02:09 -03:00
|
|
|
const router = useRouter();
|
|
|
|
return (
|
2020-09-29 19:13:06 -03:00
|
|
|
<Layout>
|
|
|
|
{router.isFallback ? (
|
|
|
|
<h1>Loading...</h1>
|
|
|
|
) : (
|
|
|
|
<ProductView productData={productData} />
|
|
|
|
)}
|
|
|
|
</Layout>
|
2020-09-29 16:02:09 -03:00
|
|
|
);
|
|
|
|
}
|