import s from './ProductSidebar.module.css' import { useAddItem } from '@framework/cart' import { FC, useState } from 'react' import { ProductOptions } from '@components/product' import { Button, Text, Rating, Collapse, useUI } from '@components/ui' import { useProduct } from '../context' interface ProductSidebarProps { className?: string } const ProductSidebar: FC = ({ className }) => { const addItem = useAddItem() const { product, variant, price } = useProduct() const { openSidebar, setSidebarView } = useUI() const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const addToCart = async () => { setLoading(true) setError(null) try { if (variant) { await addItem({ productId: String(product.id), variantId: String(variant.id), }) setSidebarView('CART_VIEW') openSidebar() } else { throw new Error('The variant selected is not available') } setLoading(false) } catch (err) { console.error(err) setLoading(false) if (err instanceof Error) { setError(err.message) } } } return (
36 reviews
{process.env.COMMERCE_CART_ENABLED && ( )} {error && (
{error}
)}
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.
) } export default ProductSidebar