diff --git a/app/page.js b/app/page.js index 2ae11afe1..309de48bb 100644 --- a/app/page.js +++ b/app/page.js @@ -22,6 +22,36 @@ const formatPriceRange = ({ maxVariantPrice, minVariantPrice }) => { } }; +const PriceRanges = ({ priceRange, compareAtPriceRange, availableForSale }) => { + const onSale = + (compareAtPriceRange?.minVariantPrice?.amount ?? 0) > + (priceRange?.minVariantPrice?.amount ?? 0) || + (compareAtPriceRange?.maxVariantPrice?.amount ?? 0) > + (priceRange?.maxVariantPrice?.amount ?? 0); + const isForSale = (priceRange?.maxVariantPrice?.amount ?? 0) > 0; + + return ( +
+ {availableForSale ? ( + isForSale && ( + <> + <> + {onSale && ( + + {formatPriceRange(compareAtPriceRange)}{' '} + + )} + > + {formatPriceRange(priceRange)} + > + ) + ) : ( + Sold Out + )} +
+ ); +}; + export async function HomeProduct({ product }) { const featuredImage = product?.images?.[0]; const collections = product?.collections?.nodes; @@ -40,13 +70,7 @@ export async function HomeProduct({ product }) { ?.map(collection => collection?.title) .join(', ')})`} )} - {product?.availableForSale ? ( - (product?.priceRange?.maxVariantPrice?.amount ?? 0) > 0 && ( -{formatPriceRange(product.priceRange)}
- ) - ) : ( -Sold Out
- )} +