Merge branch 'master' of https://git.vnfco.ir/NetinaShop/web
commit
6c6c48f5cb
|
@ -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 (
|
||||
<>
|
||||
<Navbar theme={1} />
|
||||
|
@ -380,7 +403,58 @@ const ProductData = ({ params, data }) => {
|
|||
</h3>
|
||||
</div>
|
||||
<div className="p-5 border rounded-lg">
|
||||
<div className="">
|
||||
{review?.length > 0 ? (
|
||||
<>
|
||||
{review?.map((e) => (
|
||||
<div className="mt-10">
|
||||
<div className="relative flex">
|
||||
<div className="xs:w-[40px] lg:w-[60px] xs:h-[40px] lg:h-[60px] relative bg-white rounded-2xl text-center">
|
||||
<svg
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 168 183"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="mx-auto opacity-30"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M83.9994 0.666992C130.024 0.666992 167.333 37.9753 167.333 84.0003C167.361 103.233 160.71 121.878 148.516 136.75L148.683 136.934L147.583 137.867C139.767 147.11 130.028 154.535 119.046 159.624C108.064 164.714 96.1035 167.345 83.9994 167.334C59.4161 167.334 37.3328 156.692 22.0828 139.775L20.4161 137.859L19.3161 136.942L19.4828 136.742C7.2903 121.872 0.63933 103.23 0.666096 84.0003C0.666096 37.9753 37.9744 0.666992 83.9994 0.666992ZM83.9994 125.667C68.4994 125.667 54.4911 130.6 44.0578 137.384C55.5793 146.025 69.5975 150.687 83.9994 150.667C98.4014 150.687 112.42 146.025 123.941 137.384C112.019 129.745 98.1588 125.68 83.9994 125.667ZM83.9994 17.3337C71.4538 17.3333 59.1627 20.8729 48.5388 27.5457C37.9149 34.2185 29.3895 43.7536 23.9424 55.0551C18.4954 66.3565 16.3478 78.9656 17.7465 91.433C19.1452 103.9 24.0335 115.72 31.8494 125.534C45.3578 115.842 63.7911 109 83.9994 109C104.208 109 122.641 115.842 136.149 125.534C143.965 115.72 148.854 103.9 150.252 91.433C151.651 78.9656 149.503 66.3565 144.056 55.0551C138.609 43.7536 130.084 34.2185 119.46 27.5457C108.836 20.8729 96.5451 17.3333 83.9994 17.3337ZM83.9994 34.0003C92.84 34.0003 101.318 37.5122 107.57 43.7634C113.821 50.0146 117.333 58.4931 117.333 67.3337C117.333 76.1742 113.821 84.6527 107.57 90.9039C101.318 97.1551 92.84 100.667 83.9994 100.667C75.1589 100.667 66.6804 97.1551 60.4292 90.9039C54.178 84.6527 50.6661 76.1742 50.6661 67.3337C50.6661 58.4931 54.178 50.0146 60.4292 43.7634C66.6804 37.5122 75.1589 34.0003 83.9994 34.0003ZM83.9994 50.667C79.5791 50.667 75.3399 52.4229 72.2143 55.5485C69.0887 58.6742 67.3328 62.9134 67.3328 67.3337C67.3328 71.7539 69.0887 75.9932 72.2143 79.1188C75.3399 82.2444 79.5791 84.0003 83.9994 84.0003C88.4197 84.0003 92.6589 82.2444 95.7845 79.1188C98.9101 75.9932 100.666 71.7539 100.666 67.3337C100.666 62.9134 98.9101 58.6742 95.7845 55.5485C92.6589 52.4229 88.4197 50.667 83.9994 50.667Z"
|
||||
fill="black"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div className="w-full mt-1 mr-2">
|
||||
<h3 className="font-bold">{e?.userFullName} </h3>
|
||||
<p className="mt-1 mb-0 text-sm text-gray-400">
|
||||
<PersianNumber
|
||||
number={moment(e?.createdAt).format(
|
||||
"jYYYY/jMM/jDD"
|
||||
)}
|
||||
style={"text-sm"}
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p className="mb-0 text-sm text-gray-600">
|
||||
{e?.comment}{" "}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<hr className="my-10" />
|
||||
</>
|
||||
) : (
|
||||
<div className="flex justify-center py-5">
|
||||
<div className="p-4 text-sm bg-white rounded-full shadow w-fit">
|
||||
چیزی یافت نشد
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* <div className="">
|
||||
<div className="relative flex">
|
||||
<div className="xs:w-[40px] lg:w-[60px] xs:h-[40px] lg:h-[60px] relative bg-white rounded-2xl text-center">
|
||||
<svg
|
||||
|
@ -445,122 +519,7 @@ const ProductData = ({ params, data }) => {
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-10">
|
||||
<div className="relative flex">
|
||||
<div className="xs:w-[40px] lg:w-[60px] xs:h-[40px] lg:h-[60px] relative bg-white rounded-2xl text-center">
|
||||
<svg
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 168 183"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="mx-auto opacity-30"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M83.9994 0.666992C130.024 0.666992 167.333 37.9753 167.333 84.0003C167.361 103.233 160.71 121.878 148.516 136.75L148.683 136.934L147.583 137.867C139.767 147.11 130.028 154.535 119.046 159.624C108.064 164.714 96.1035 167.345 83.9994 167.334C59.4161 167.334 37.3328 156.692 22.0828 139.775L20.4161 137.859L19.3161 136.942L19.4828 136.742C7.2903 121.872 0.63933 103.23 0.666096 84.0003C0.666096 37.9753 37.9744 0.666992 83.9994 0.666992ZM83.9994 125.667C68.4994 125.667 54.4911 130.6 44.0578 137.384C55.5793 146.025 69.5975 150.687 83.9994 150.667C98.4014 150.687 112.42 146.025 123.941 137.384C112.019 129.745 98.1588 125.68 83.9994 125.667ZM83.9994 17.3337C71.4538 17.3333 59.1627 20.8729 48.5388 27.5457C37.9149 34.2185 29.3895 43.7536 23.9424 55.0551C18.4954 66.3565 16.3478 78.9656 17.7465 91.433C19.1452 103.9 24.0335 115.72 31.8494 125.534C45.3578 115.842 63.7911 109 83.9994 109C104.208 109 122.641 115.842 136.149 125.534C143.965 115.72 148.854 103.9 150.252 91.433C151.651 78.9656 149.503 66.3565 144.056 55.0551C138.609 43.7536 130.084 34.2185 119.46 27.5457C108.836 20.8729 96.5451 17.3333 83.9994 17.3337ZM83.9994 34.0003C92.84 34.0003 101.318 37.5122 107.57 43.7634C113.821 50.0146 117.333 58.4931 117.333 67.3337C117.333 76.1742 113.821 84.6527 107.57 90.9039C101.318 97.1551 92.84 100.667 83.9994 100.667C75.1589 100.667 66.6804 97.1551 60.4292 90.9039C54.178 84.6527 50.6661 76.1742 50.6661 67.3337C50.6661 58.4931 54.178 50.0146 60.4292 43.7634C66.6804 37.5122 75.1589 34.0003 83.9994 34.0003ZM83.9994 50.667C79.5791 50.667 75.3399 52.4229 72.2143 55.5485C69.0887 58.6742 67.3328 62.9134 67.3328 67.3337C67.3328 71.7539 69.0887 75.9932 72.2143 79.1188C75.3399 82.2444 79.5791 84.0003 83.9994 84.0003C88.4197 84.0003 92.6589 82.2444 95.7845 79.1188C98.9101 75.9932 100.666 71.7539 100.666 67.3337C100.666 62.9134 98.9101 58.6742 95.7845 55.5485C92.6589 52.4229 88.4197 50.667 83.9994 50.667Z"
|
||||
fill="black"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div className="w-full mt-1 mr-2">
|
||||
<h3 className="font-bold">حسین معصومی </h3>
|
||||
<p className="mt-1 mb-0 text-sm text-gray-400">
|
||||
<PersianNumber
|
||||
number={moment(Date()).format("jYYYY/jMM/jDD")}
|
||||
style={"text-sm"}
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p className="mb-0 text-sm text-gray-600">
|
||||
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم{" "}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-10">
|
||||
<div className="relative flex">
|
||||
<div className="xs:w-[40px] lg:w-[60px] xs:h-[40px] lg:h-[60px] relative bg-white rounded-2xl text-center">
|
||||
<svg
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 168 183"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className="mx-auto opacity-30"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M83.9994 0.666992C130.024 0.666992 167.333 37.9753 167.333 84.0003C167.361 103.233 160.71 121.878 148.516 136.75L148.683 136.934L147.583 137.867C139.767 147.11 130.028 154.535 119.046 159.624C108.064 164.714 96.1035 167.345 83.9994 167.334C59.4161 167.334 37.3328 156.692 22.0828 139.775L20.4161 137.859L19.3161 136.942L19.4828 136.742C7.2903 121.872 0.63933 103.23 0.666096 84.0003C0.666096 37.9753 37.9744 0.666992 83.9994 0.666992ZM83.9994 125.667C68.4994 125.667 54.4911 130.6 44.0578 137.384C55.5793 146.025 69.5975 150.687 83.9994 150.667C98.4014 150.687 112.42 146.025 123.941 137.384C112.019 129.745 98.1588 125.68 83.9994 125.667ZM83.9994 17.3337C71.4538 17.3333 59.1627 20.8729 48.5388 27.5457C37.9149 34.2185 29.3895 43.7536 23.9424 55.0551C18.4954 66.3565 16.3478 78.9656 17.7465 91.433C19.1452 103.9 24.0335 115.72 31.8494 125.534C45.3578 115.842 63.7911 109 83.9994 109C104.208 109 122.641 115.842 136.149 125.534C143.965 115.72 148.854 103.9 150.252 91.433C151.651 78.9656 149.503 66.3565 144.056 55.0551C138.609 43.7536 130.084 34.2185 119.46 27.5457C108.836 20.8729 96.5451 17.3333 83.9994 17.3337ZM83.9994 34.0003C92.84 34.0003 101.318 37.5122 107.57 43.7634C113.821 50.0146 117.333 58.4931 117.333 67.3337C117.333 76.1742 113.821 84.6527 107.57 90.9039C101.318 97.1551 92.84 100.667 83.9994 100.667C75.1589 100.667 66.6804 97.1551 60.4292 90.9039C54.178 84.6527 50.6661 76.1742 50.6661 67.3337C50.6661 58.4931 54.178 50.0146 60.4292 43.7634C66.6804 37.5122 75.1589 34.0003 83.9994 34.0003ZM83.9994 50.667C79.5791 50.667 75.3399 52.4229 72.2143 55.5485C69.0887 58.6742 67.3328 62.9134 67.3328 67.3337C67.3328 71.7539 69.0887 75.9932 72.2143 79.1188C75.3399 82.2444 79.5791 84.0003 83.9994 84.0003C88.4197 84.0003 92.6589 82.2444 95.7845 79.1188C98.9101 75.9932 100.666 71.7539 100.666 67.3337C100.666 62.9134 98.9101 58.6742 95.7845 55.5485C92.6589 52.4229 88.4197 50.667 83.9994 50.667Z"
|
||||
fill="black"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div className="w-full mt-1 mr-2">
|
||||
<h3 className="font-bold">ماهان قیصرزاده </h3>
|
||||
<p className="mt-1 mb-0 text-sm text-gray-400">
|
||||
<PersianNumber
|
||||
number={moment(Date()).format("jYYYY/jMM/jDD")}
|
||||
style={"text-sm"}
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p className="mb-0 text-sm text-gray-600">
|
||||
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت
|
||||
چاپ و با استفاده از طراحان گرافیک است چاپگرها و متون
|
||||
بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و
|
||||
برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع
|
||||
با هدف بهبود ابزارهای کاربردی می باشد کتابهای زیادی در
|
||||
شصت و سه درصد گذشته حال و آینده شناخت فراوان جامعه و
|
||||
متخصصان را می طلبد تا با نرم افزارها شناخت بیشتری را
|
||||
برای طراحان رایانه ای علی الخصوص طراحان خلاقی و فرهنگ
|
||||
پیشرو در زبان فارسی ایجاد کرد در این صورت می توان امید
|
||||
داشت که تمام و دشواری موجود در ارائه راهکارها و شرایط
|
||||
سخت تایپ به پایان رسد و زمان مورد نیاز شامل حروفچینی
|
||||
دستاوردهای اصلی
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-5 lg:mr-10">
|
||||
<div className="relative flex">
|
||||
<div className="xs:w-[40px] lg:w-[60px] xs:h-[40px] lg:h-[60px] relative bg-primary-300 rounded-2xl text-center">
|
||||
<div className=" xs:w-[10px] lg:w-[45px] mx-auto xs:mt-3 lg:mt-6">
|
||||
<Image src={logo} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="w-full mt-1 mr-2">
|
||||
<h3 className="font-bold xs:text-sm lg:text-base">
|
||||
پشتیبانی فروشگاه وسمه - آقای حیدریان
|
||||
</h3>
|
||||
<p className="mb-0 text-sm text-gray-400">
|
||||
<PersianNumber
|
||||
number={moment(Date()).format("jYYYY/jMM/jDD")}
|
||||
style={"!text-[12px]"}
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p className="mb-0 text-sm text-gray-600">
|
||||
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت
|
||||
چاپ و با استفاده از طراحان گرافیک است چاپگرها و متون
|
||||
بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و
|
||||
برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع
|
||||
با هدف بهبود ابزارهای کاربردی می باشد
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr className="my-10" />
|
||||
</div> */}
|
||||
|
||||
<div>
|
||||
<h3 className="font-bold">دیدگاه خود را وارد کنید </h3>{" "}
|
||||
|
@ -571,13 +530,14 @@ const ProductData = ({ params, data }) => {
|
|||
cols="30"
|
||||
rows="8"
|
||||
onChange={(e) => setComment(e.target.value)}
|
||||
value={comment}
|
||||
/>
|
||||
<div
|
||||
className="flex justify-end"
|
||||
onClick={() => handleCreateReview()}
|
||||
>
|
||||
<button className="py-3 text-sm btn btn-primary rounded-3xl">
|
||||
ارسال دیدگاه ( برای ارسال دیدگاه باید ابتدا ورود کنید){" "}
|
||||
ارسال دیدگاه ( برای ارسال دیدگاه ابتدا باید ورود کنید){" "}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 110 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
|
@ -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",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue