Add Reaction Commerce provider

Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
Loan Laux
2021-03-30 20:07:48 +04:00
parent 9b71bd77fc
commit 09249045eb
99 changed files with 24980 additions and 25 deletions

View File

@@ -34,7 +34,7 @@ const ProductCard: FC<Props> = ({
{product?.images && (
<Image
quality="85"
src={product.images[0].url || placeholderImg}
src={product.images[0]?.url || placeholderImg}
alt={product.name || 'Product Image'}
height={320}
width={320}
@@ -70,7 +70,7 @@ const ProductCard: FC<Props> = ({
<Image
alt={product.name || 'Product Image'}
className={s.productImage}
src={product.images[0].url || placeholderImg}
src={product.images[0]?.url || placeholderImg}
height={540}
width={540}
quality="85"

View File

@@ -30,7 +30,6 @@ const ProductView: FC<Props> = ({ product }) => {
const { openSidebar } = useUI()
const [loading, setLoading] = useState(false)
const [choices, setChoices] = useState<SelectedOptions>({
size: null,
color: null,
})
@@ -40,9 +39,17 @@ const ProductView: FC<Props> = ({ product }) => {
const addToCart = async () => {
setLoading(true)
try {
const selectedVariant = variant ? variant : product.variants[0]
console.log('selected variant', selectedVariant)
await addItem({
productId: String(product.id),
variantId: String(variant ? variant.id : product.variants[0].id),
variantId: String(selectedVariant.id),
pricing: {
amount: selectedVariant.price,
currencyCode: product.price.currencyCode,
},
})
openSidebar()
setLoading(false)