diff --git a/src/app/globals.css b/src/app/globals.css index 59eea06..206609a 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -168,6 +168,9 @@ body {} opacity: 1; } +.mySwiper4 .swiper-slide-thumb-active { + opacity: 1; +} .swiper-slide img { display: block; width: 100%; diff --git a/src/app/products/[id]/page.tsx b/src/app/products/[id]/page.tsx index 97cfa6a..1c2a2d6 100644 --- a/src/app/products/[id]/page.tsx +++ b/src/app/products/[id]/page.tsx @@ -1,28 +1,22 @@ -// BuyerProductView 'use client'; import React, { useState } from 'react'; import { Swiper, SwiperSlide } from 'swiper/react'; import 'swiper/css'; import 'swiper/css/free-mode'; +import 'swiper/css/zoom'; import 'swiper/css/navigation'; import 'swiper/css/thumbs'; import { FreeMode, Navigation, Thumbs } from 'swiper/modules'; -import Image from 'next/image'; //@ts-ignore +// @ts-ignore import ReactStars from 'react-rating-stars-component'; import { MdOutlineShoppingCart } from 'react-icons/md'; import { FaRegHeart } from 'react-icons/fa6'; import { useParams } from 'next/navigation'; import { Product } from '@/utils/requests'; -import { - ProductObj, - ProductType, - ReviewType, - imageType, -} from '@/types/Product'; +import { ProductType, ReviewType, imageType } from '@/types/Product'; import Card from '@/components/Card'; import Header from '@/components/Header'; import Footer from '@/components/Footer'; -import image from '../../../../public/product.png'; import { useQuery } from '@tanstack/react-query'; import ReviewCard from '@/components/ReviewCard'; import Button from '@/components/Button'; @@ -33,7 +27,7 @@ import { handleUserAddCart } from '@/redux/slices/userCartSlice'; function Page() { const [thumbsSwiper, setThumbsSwiper] = useState(null); - const { id } :any= useParams(); + const { id } = useParams(); const handleSwiper = (swiper: any) => { setThumbsSwiper(swiper); }; @@ -45,176 +39,195 @@ function Page() { const response: ProductType = (await Product.single( _id, )) as ProductType; - return response; } catch (error) { throw new Error('Error fetching product data'); } }, }); - if (isLoading) return Loading...; - if (error) return Error: {error.message}; - const { productPictures, productName, productPrice, productDescription, reviews, - } = data.product; - console.log('this is reviews >>>>>>>>>', reviews); - console.log(' this is average reviews', productPictures); - const { relatedProducts } = data; + } = data?.product || {}; + const { relatedProducts } = data || {}; const dispatch = useAppDispatch(); const handleNewItem = () => { const productId = data.product.id; dispatch(handleUserAddCart({ productPrice, productId })); }; - return (
no image found!
- )} -no image found!
+ )} +{productDescription}
+{productDescription}
++ No related products available. +
+ )} +- No related products available. -
- )} +No ratings yet.
+ )} +No ratings yet.
- )} -