From 716b33823b11a4528008fd4f7269ad8366408128 Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Tue, 16 May 2023 16:00:34 +0200 Subject: [PATCH] Product view updates --- components/product/gallery.tsx | 99 ----------------------------- components/product/product-view.tsx | 17 +++-- 2 files changed, 13 insertions(+), 103 deletions(-) delete mode 100644 components/product/gallery.tsx diff --git a/components/product/gallery.tsx b/components/product/gallery.tsx deleted file mode 100644 index 12690d11e..000000000 --- a/components/product/gallery.tsx +++ /dev/null @@ -1,99 +0,0 @@ -'use client'; - -import { useState } from 'react'; - -import clsx from 'clsx'; -import { GridTileImage } from 'components/grid/tile'; -import ArrowLeftIcon from 'components/icons/arrow-left'; - -export function Gallery({ - title, - amount, - currencyCode, - images -}: { - title: string; - amount: string; - currencyCode: string; - images: { src: string; altText: string }[]; -}) { - const [currentImage, setCurrentImage] = useState(0); - - function handleNavigate(direction: 'next' | 'previous') { - if (direction === 'next') { - setCurrentImage(currentImage + 1 < images.length ? currentImage + 1 : 0); - } else { - setCurrentImage(currentImage === 0 ? images.length - 1 : currentImage - 1); - } - } - - const buttonClassName = - 'px-9 cursor-pointer ease-in-and-out duration-200 transition-bg bg-[#7928ca] hover:bg-violetDark'; - - return ( -
-
- {images[currentImage] && ( - - )} - - {images.length > 1 ? ( -
- - -
- ) : null} -
- - {images.length > 1 ? ( -
- {images.map((image, index) => { - const isActive = index === currentImage; - return ( - - ); - })} -
- ) : null} -
- ); -} diff --git a/components/product/product-view.tsx b/components/product/product-view.tsx index d9f1fc817..b094f9625 100644 --- a/components/product/product-view.tsx +++ b/components/product/product-view.tsx @@ -1,11 +1,13 @@ 'use client' import { Carousel, CarouselItem } from 'components/modules/carousel/carousel' +import Price from 'components/product/price' import SanityImage from 'components/ui/sanity-image' import { Product } from "lib/storm/types/product" import { cn } from 'lib/utils' import { useTranslations } from 'next-intl' import dynamic from "next/dynamic" +import { AddToCart } from './add-to-cart' const ProductCard = dynamic(() => import('components/ui/product-card')) const Text = dynamic(() => import('components/ui/text')) interface ProductViewProps { @@ -15,14 +17,13 @@ interface ProductViewProps { export default function ProductView({product, relatedProducts }: ProductViewProps) { const images = product.images - const productImage: object | any = product.images[0] const t = useTranslations('product') return (
-
+
{images && (
-
+
{product.name} + + + +
@@ -95,7 +104,7 @@ export default function ProductView({product, relatedProducts }: ProductViewProp }, }} > - {relatedProducts.map((p, index) => ( + {relatedProducts.map((p) => (