diff --git a/components/AppsComponent/ProductData/page.jsx b/components/AppsComponent/ProductData/page.jsx index c5f7359..86d28ee 100644 --- a/components/AppsComponent/ProductData/page.jsx +++ b/components/AppsComponent/ProductData/page.jsx @@ -16,9 +16,10 @@ import { useRouter } from "next/navigation"; const ProductData = ({ params, data }) => { console.log("data", data); const [product, setProduct] = useState([]); + const [review, setReview] = useState([]); const [specificationsHeader, setSpecificationsHeader] = useState([]); const [productBarDetail, setProductBarDetail] = useState(0); - const [comment, setComment] = useState("0"); + const [comment, setComment] = useState(""); const router = useRouter(); @@ -27,12 +28,25 @@ const ProductData = ({ params, data }) => { const post = await res.json(); setProduct(post.product); }; + const fetchReview = async (id) => { - const res = await fetch( - `${process.env.NEXT_PUBLIC_API_URL}/product/${id}/review?page=0` - ); - const post = await res.json(); - setProduct(post.product); + try { + const res = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/product/${id}/review?page=0` + ); + + // Check if the response is OK and has JSON content + if (!res.ok) { + throw new Error(`HTTP error! status: ${res.status}`); + } + + const post = await res.json(); + + console.log("post test comment", post); + setReview(post); + } catch (error) { + console.error("Error fetching review:", error); + } }; const displaySpecifications = (specs) => { @@ -66,14 +80,21 @@ const ProductData = ({ params, data }) => { }; const createProductReview = async () => { - const body = { title: "", comment, rate: 1, productId: params.id[0] }; + const body = { + title: `${data.product?.persianName}نظر کاربر برای محصول`, + comment, + rate: 1, + productId: params.id[0], + }; try { const data = await Chapar.post( `${process.env.NEXT_PUBLIC_API_URL}/product/review`, body ); - // fetchReview(); + setComment(""); + + fetchReview(params.id[0]); } catch ({ error, status }) { toast.error(`${error?.response?.data?.message}`, { position: "bottom-right", @@ -101,6 +122,8 @@ const ProductData = ({ params, data }) => { displaySpecifications(product?.specifications); }, [product]); + console.log("review", review); + return ( <> @@ -380,7 +403,58 @@ const ProductData = ({ params, data }) => {
-
+ {review?.length > 0 ? ( + <> + {review?.map((e) => ( +
+
+
+ + + +
+ +
+

{e?.userFullName}

+

+ +

+ +

+ {e?.comment}{" "} +

+
+
+
+ ))} +
+ + ) : ( +
+
+ چیزی یافت نشد +
+
+ )} + + {/*
{

-
- -
-
-
- - - -
- -
-

حسین معصومی

-

- -

- -

- لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم{" "} -

-
-
-
- -
-
-
- - - -
- -
-

ماهان قیصرزاده

-

- -

- -

- لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت - چاپ و با استفاده از طراحان گرافیک است چاپگرها و متون - بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و - برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع - با هدف بهبود ابزارهای کاربردی می باشد کتابهای زیادی در - شصت و سه درصد گذشته حال و آینده شناخت فراوان جامعه و - متخصصان را می طلبد تا با نرم افزارها شناخت بیشتری را - برای طراحان رایانه ای علی الخصوص طراحان خلاقی و فرهنگ - پیشرو در زبان فارسی ایجاد کرد در این صورت می توان امید - داشت که تمام و دشواری موجود در ارائه راهکارها و شرایط - سخت تایپ به پایان رسد و زمان مورد نیاز شامل حروفچینی - دستاوردهای اصلی -

-
-
-
- -
-
-
-
- -
-
- -
-

- پشتیبانی فروشگاه وسمه - آقای حیدریان -

-

- -

- -

- لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت - چاپ و با استفاده از طراحان گرافیک است چاپگرها و متون - بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و - برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع - با هدف بهبود ابزارهای کاربردی می باشد -

-
-
-
- -
+
*/}

دیدگاه خود را وارد کنید

{" "} @@ -571,13 +530,14 @@ const ProductData = ({ params, data }) => { cols="30" rows="8" onChange={(e) => setComment(e.target.value)} + value={comment} />
handleCreateReview()} >
diff --git a/components/LandingPage/HeroSection/page.jsx b/components/LandingPage/HeroSection/page.jsx index b0da266..72157b2 100644 --- a/components/LandingPage/HeroSection/page.jsx +++ b/components/LandingPage/HeroSection/page.jsx @@ -3,9 +3,11 @@ import Image from "next/image"; import ban1 from "@img/ban1.jpg"; import ban2 from "@img/ban2.jpg"; import ban3 from "@img/ban3.jpg"; +import ban4 from "@img/ban4.jpg"; import ban1res from "@img/ban1res.jpg"; import ban2res from "@img/ban2res.jpg"; import ban3res from "@img/ban3res.jpg"; +import ban4res from "@img/ban4res.jpg"; import Link from "next/link"; const slides = [ @@ -33,7 +35,14 @@ const slides = [ description: "Slide 3 Description", url: "/categories/0/%D9%87%D9%85%D9%87%20%D9%85%D8%AD%D8%B5%D9%88%D9%84%D8%A7%D8%AA?page=0&brandIds=93a2a376-5a18-49f3-b29c-a3c8ef2ff133", }, - // Add more slides as needed + { + id: 4, + image: ban4, + imageResponsive: ban4res, + title: "ارسال رایگان", + description: "Slide 4 Description", + url: "/categories/0/%D9%87%D9%85%D9%87%20%D9%85%D8%AD%D8%B5%D9%88%D9%84%D8%A7%D8%AA?page=0&brandIds=93a2a376-5a18-49f3-b29c-a3c8ef2ff133", + }, ]; const HeroSection = () => { diff --git a/public/images/ban4.jpg b/public/images/ban4.jpg new file mode 100644 index 0000000..12fc018 Binary files /dev/null and b/public/images/ban4.jpg differ diff --git a/public/images/ban4res.jpg b/public/images/ban4res.jpg new file mode 100644 index 0000000..6965aa5 Binary files /dev/null and b/public/images/ban4res.jpg differ diff --git a/src/app/products/[...id]/page.jsx b/src/app/products/[...id]/page.jsx index 3d5455b..75c3719 100644 --- a/src/app/products/[...id]/page.jsx +++ b/src/app/products/[...id]/page.jsx @@ -126,7 +126,6 @@ export async function generateMetadata({ params }) { ) / data?.product?.reviews.length ).toFixed(1) : "4.5", // Default rating if no reviews - reviewCount: data?.product?.reviews.length.toString() || "0", }, }; }