From b8220e12ae17f1e0dd801ebd84c1bcd471257094 Mon Sep 17 00:00:00 2001
From: mpn <123456>
Date: Sat, 6 Apr 2024 23:33:53 +0330
Subject: [PATCH] bug image torob and yektanet , page all product
---
 .../AppsComponent/CategoriesData/page.jsx     |  10 +-
 components/AppsComponent/RootData/page.jsx    |   2 +
 components/Category/FilterCategory/page.jsx   |   6 +-
 components/Category/ListProdocts/page.jsx     |   2 +-
 .../Mobile/FilterCategoryMobile/page.jsx      |   4 +-
 .../Category/PaginationCategoory/page.jsx     | 137 ++++++++++--------
 plugins/Goftino/page.jsx                      |  17 ++-
 plugins/Yektanet/page.jsx                     |  19 +++
 src/app/categories/page.jsx                   |  18 +++
 src/app/products/[...id]/page.jsx             |   5 +-
 10 files changed, 143 insertions(+), 77 deletions(-)
 create mode 100644 plugins/Yektanet/page.jsx
 create mode 100644 src/app/categories/page.jsx
diff --git a/components/AppsComponent/CategoriesData/page.jsx b/components/AppsComponent/CategoriesData/page.jsx
index 9577b61..32fed5a 100644
--- a/components/AppsComponent/CategoriesData/page.jsx
+++ b/components/AppsComponent/CategoriesData/page.jsx
@@ -28,7 +28,9 @@ export default function CategoriesData({ params }) {
 
   const fetchBarnds = async () => {
     const res = await fetch(
-      `${process.env.NEXT_PUBLIC_API_URL}/brand?categoryId=${params.id[0]}`
+      `${process.env.NEXT_PUBLIC_API_URL}/brand${
+        params.id[0] != 0 ? `?categoryId=${params.id[0]}` : ""
+      }`
     );
     const brands = await res.json();
     CTX.setBrands(brands);
@@ -43,12 +45,12 @@ export default function CategoriesData({ params }) {
     // Fetch products for the next page
     CTX.fetchProducts(
       nextPage,
-      params.id[0],
+      params.id[0] != 0 ? params.id[0] : "",
       selectedBrands,
       isChecked,
       rangePrice,
       rangePrice,
-      sortBy,
+      sortBy != -1 ? sortBy : "",
       isRangePrice
     );
 
@@ -60,7 +62,7 @@ export default function CategoriesData({ params }) {
       top: 0,
       behavior: "smooth", // Optional: smooth scrolling behavior
     });
-    CTX.fetchProducts(0, params.id[0]);
+    CTX.fetchProducts(0, params.id[0] != 0 ? params.id[0] : "");
     fetchBarnds();
   }, []);
 
diff --git a/components/AppsComponent/RootData/page.jsx b/components/AppsComponent/RootData/page.jsx
index 89ca48e..76935e9 100644
--- a/components/AppsComponent/RootData/page.jsx
+++ b/components/AppsComponent/RootData/page.jsx
@@ -16,6 +16,7 @@ import "../../../style/globals.css";
 import Goftino from "plugins/Goftino/page";
 import { useRouter } from "next/navigation";
 import NextTopLoader from "nextjs-toploader";
+import Yektanet from "plugins/Goftino/page";
 
 const RootData = ({ children }) => {
   const [cart, setCart] = useState([]);
@@ -494,6 +495,7 @@ const RootData = ({ children }) => {
       />
 
       
 {
-            console.log("ss", i);
-            setCurrentPageIndex(i);
-            CTX.fetchProducts(
-              i,
-              props.id[0],
-              props.selectedBrands,
-              props.isChecked,
-              props.rangePrice,
-              props.rangePrice,
-              props.sortBy,
-              props.isRangePrice,
-              true //pagination say or not
-            );
-          }}
-        >
-          
-            
-        
 handlePageClick(pageIndex)}
+    >
+      
+        
+    
+      ...
+    
+  );
+
+  const handlePageClick = (pageIndex) => {
+    setCurrentPageIndex(pageIndex);
+    // console.log("ss", i);
+    CTX.fetchProducts(
+      pageIndex,
+      props.id[0] != 0 ? props.id[0] : "",
+      props.selectedBrands,
+      props.isChecked,
+      props.rangePrice,
+      props.rangePrice,
+      props.sortBy != -1 ? props.sortBy : "",
+      props.isRangePrice,
+      true //pagination say or not
+    );
+    // Your fetchProducts function call here
+  };
+
   return (
     
       
-        
-           
+        {/* Previous page button */}
       
       {renderPaginationButtons()}
       
-        
-           
+        {/* Next page button */}
       
 
   );
diff --git a/plugins/Goftino/page.jsx b/plugins/Goftino/page.jsx
index 317ea72..8e780b7 100644
--- a/plugins/Goftino/page.jsx
+++ b/plugins/Goftino/page.jsx
@@ -1,9 +1,18 @@
 import Script from "next/script";
 
-export default function Goftino() {
-  const getGoftiono = () => {
+export default function Yektanet() {
+  const getYektanet = () => {
     return {
-      __html: `     !function(){var i="Gk1Yld",a=window,d=document;function g(){var g=d.createElement("script"),s="https://www.goftino.com/widget/"+i,l=localStorage.getItem("goftino_"+i);g.async=!0,g.src=l?s+"?o="+l:s;d.getElementsByTagName("head")[0].appendChild(g);}"complete"===d.readyState?g():a.attachEvent?a.attachEvent("onload",g):a.addEventListener("load",g,!1);}();
+      __html: `   !function (t, e, n) {
+        t.yektanetAnalyticsObject = n, t[n] = t[n] || function () {
+            t[n].q.push(arguments)
+        }, t[n].q = t[n].q || [];
+        var a = new Date, r = a.getFullYear().toString() + "0" + a.getMonth() + "0" + a.getDate() + "0" + a.getHours(),
+            c = e.getElementsByTagName("script")[0], s = e.createElement("script");
+        s.id = "ua-script-rqSC1axy"; s.dataset.analyticsobject = n;
+        s.async = 1; s.type = "text/javascript";
+        s.src = "https://cdn.yektanet.com/rg_woebegone/scripts_v3/rqSC1axy/rg.complete.js?v=" + r, c.parentNode.insertBefore(s, c)
+    }(window, document, "yektanet");
       `,
     };
   };
@@ -12,7 +21,7 @@ export default function Goftino() {
     <>
       
     >
   );
diff --git a/plugins/Yektanet/page.jsx b/plugins/Yektanet/page.jsx
new file mode 100644
index 0000000..317ea72
--- /dev/null
+++ b/plugins/Yektanet/page.jsx
@@ -0,0 +1,19 @@
+import Script from "next/script";
+
+export default function Goftino() {
+  const getGoftiono = () => {
+    return {
+      __html: `     !function(){var i="Gk1Yld",a=window,d=document;function g(){var g=d.createElement("script"),s="https://www.goftino.com/widget/"+i,l=localStorage.getItem("goftino_"+i);g.async=!0,g.src=l?s+"?o="+l:s;d.getElementsByTagName("head")[0].appendChild(g);}"complete"===d.readyState?g():a.attachEvent?a.attachEvent("onload",g):a.addEventListener("load",g,!1);}();
+      `,
+    };
+  };
+
+  return (
+    <>
+      
+    >
+  );
+}
diff --git a/src/app/categories/page.jsx b/src/app/categories/page.jsx
new file mode 100644
index 0000000..3169aa1
--- /dev/null
+++ b/src/app/categories/page.jsx
@@ -0,0 +1,18 @@
+"use client";
+import { useRouter } from "next/navigation";
+import React, { useEffect } from "react";
+
+const page = (props) => {
+  const router = useRouter();
+  useEffect(() => {
+    // Redirect to the category page with any query parameters
+    router.push(
+      "/categories/0/همه محصولات"
+      // Add your query parameters here
+    );
+  }, []);
+
+  return;
+};
+
+export default page;
diff --git a/src/app/products/[...id]/page.jsx b/src/app/products/[...id]/page.jsx
index cb82758..08cd505 100644
--- a/src/app/products/[...id]/page.jsx
+++ b/src/app/products/[...id]/page.jsx
@@ -35,10 +35,9 @@ export async function generateMetadata({ params }) {
 
       images: [
         {
-          url: JSON.stringify(
+          url:
             process.env.NEXT_PUBLIC_STORAGE_URL + "/" + data?.product?.files &&
-              data?.product?.files[0].fileLocation
-          ), // Dynamic og route
+            data?.product?.files[0].fileLocation, // Dynamic og route
           width: 800,
           height: 600,
         },