import xss from 'xss'; import { getProducts, getProduct } from 'lib/shopify'; export async function generateStaticParams() { const products = await getProducts({ sortKey: 'UPDATED_AT', reverse: false, query: '', }); return products.map(product => ({ product: product.handle })); } export async function Option({ value, children, selected }) { return ; } export async function Select({ id, label, children }) { return (
{/* TODO: parentheses around label w/ css */}
); } //TODO: NumberInput export default async function ProductPage({ params: { handle } }) { const product = await getProduct(handle); const hasOptions = product?.options?.[0]?.values.length > 1 ?? false; //TODO: turn these checks into shared functions // const onSale = // (compareAtPriceRange?.minVariantPrice?.amount ?? 0) > // (priceRange?.minVariantPrice?.amount ?? 0) || // (compareAtPriceRange?.maxVariantPrice?.amount ?? 0) > // (priceRange?.maxVariantPrice?.amount ?? 0); const isForSale = (product?.priceRange?.maxVariantPrice?.amount ?? 0) > 0; return ( <> {product?.handle ? ( <>

{product?.title}

{product?.availableForSale && isForSale && ( <>
<> {hasOptions && product?.options?.map(option => ( ))} )} ) : (

Product not found

)} ); }