import cn from 'classnames' import Image from 'next/image' import { NextSeo } from 'next-seo' import s from './ProductView.module.css' import { FC, useEffect, useState } from 'react' import type { Product } from '@commerce/types/product' import usePrice from '@framework/product/use-price' import { getProductVariant, selectDefaultOptionFromProduct, SelectedOptions, } from '../helpers' import { useAddItem } from '@framework/cart' import { WishlistButton } from '@components/wishlist' import { ProductSlider, ProductCard, ProductOptions } from '@components/product' import { Button, Container, Text, useUI, Rating, Collapse, } from '@components/ui' interface ProductViewProps { product: Product className?: string relatedProducts: Product[] children?: React.ReactNode } const ProductView: FC = ({ product, relatedProducts }) => { const { openSidebar } = useUI() const [loading, setLoading] = useState(false) const [selectedOptions, setSelectedOptions] = useState({}) const addItem = useAddItem() const { price } = usePrice({ amount: product.price.value, baseAmount: product.price.retailPrice, currencyCode: product.price.currencyCode!, }) useEffect(() => { selectDefaultOptionFromProduct(product, setSelectedOptions) }, []) const variant = getProductVariant(product, selectedOptions) const addToCart = async () => { setLoading(true) try { await addItem({ productId: String(product.id), variantId: String(variant ? variant.id : product.variants[0].id), }) openSidebar() setLoading(false) } catch (err) { setLoading(false) } } return (

{product.name}

{`${price} ${product.price?.currencyCode}`}
{product.images.map((image, i) => (
{image.alt
))}
{process.env.COMMERCE_WISHLIST_ENABLED && ( )}
36 reviews
This is a limited edition production run. Printing starts when the drop ends. 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.

Related Products
{relatedProducts.map((p) => (
))}
) } export default ProductView