bug image torob and yektanet , page all product
parent
b5ca4fab63
commit
b8220e12ae
|
@ -28,7 +28,9 @@ export default function CategoriesData({ params }) {
|
||||||
|
|
||||||
const fetchBarnds = async () => {
|
const fetchBarnds = async () => {
|
||||||
const res = await fetch(
|
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();
|
const brands = await res.json();
|
||||||
CTX.setBrands(brands);
|
CTX.setBrands(brands);
|
||||||
|
@ -43,12 +45,12 @@ export default function CategoriesData({ params }) {
|
||||||
// Fetch products for the next page
|
// Fetch products for the next page
|
||||||
CTX.fetchProducts(
|
CTX.fetchProducts(
|
||||||
nextPage,
|
nextPage,
|
||||||
params.id[0],
|
params.id[0] != 0 ? params.id[0] : "",
|
||||||
selectedBrands,
|
selectedBrands,
|
||||||
isChecked,
|
isChecked,
|
||||||
rangePrice,
|
rangePrice,
|
||||||
rangePrice,
|
rangePrice,
|
||||||
sortBy,
|
sortBy != -1 ? sortBy : "",
|
||||||
isRangePrice
|
isRangePrice
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ export default function CategoriesData({ params }) {
|
||||||
top: 0,
|
top: 0,
|
||||||
behavior: "smooth", // Optional: smooth scrolling behavior
|
behavior: "smooth", // Optional: smooth scrolling behavior
|
||||||
});
|
});
|
||||||
CTX.fetchProducts(0, params.id[0]);
|
CTX.fetchProducts(0, params.id[0] != 0 ? params.id[0] : "");
|
||||||
fetchBarnds();
|
fetchBarnds();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import "../../../style/globals.css";
|
||||||
import Goftino from "plugins/Goftino/page";
|
import Goftino from "plugins/Goftino/page";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import NextTopLoader from "nextjs-toploader";
|
import NextTopLoader from "nextjs-toploader";
|
||||||
|
import Yektanet from "plugins/Goftino/page";
|
||||||
|
|
||||||
const RootData = ({ children }) => {
|
const RootData = ({ children }) => {
|
||||||
const [cart, setCart] = useState([]);
|
const [cart, setCart] = useState([]);
|
||||||
|
@ -494,6 +495,7 @@ const RootData = ({ children }) => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Goftino />
|
<Goftino />
|
||||||
|
<Yektanet />
|
||||||
</AppContext.Provider>
|
</AppContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ const FilterCategory = ({
|
||||||
isChecked,
|
isChecked,
|
||||||
rangePrice[0],
|
rangePrice[0],
|
||||||
rangePrice[1],
|
rangePrice[1],
|
||||||
sortBy,
|
sortBy != -1 ? sortBy : "",
|
||||||
isRangePrice
|
isRangePrice
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -68,12 +68,12 @@ const FilterCategory = ({
|
||||||
|
|
||||||
CTX.fetchProducts(
|
CTX.fetchProducts(
|
||||||
0,
|
0,
|
||||||
id[0],
|
id[0] != 0 ? id[0] : "",
|
||||||
selectedBrands,
|
selectedBrands,
|
||||||
isChecked,
|
isChecked,
|
||||||
rangePrice[0],
|
rangePrice[0],
|
||||||
rangePrice[1],
|
rangePrice[1],
|
||||||
sortBy,
|
sortBy != -1 ? sortBy : "",
|
||||||
isRangePrice
|
isRangePrice
|
||||||
);
|
);
|
||||||
}, [CTX.state.selectedBrands, CTX.state.isChecked]);
|
}, [CTX.state.selectedBrands, CTX.state.isChecked]);
|
||||||
|
|
|
@ -34,7 +34,7 @@ const ListProdocts = ({
|
||||||
isChecked,
|
isChecked,
|
||||||
rangePrice,
|
rangePrice,
|
||||||
rangePrice,
|
rangePrice,
|
||||||
sortBy,
|
sortBy != -1 ? sortBy : "",
|
||||||
isRangePrice
|
isRangePrice
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ const FilterCategoryMobile = (props) => {
|
||||||
if (props.sortBy != -1) {
|
if (props.sortBy != -1) {
|
||||||
CTX.fetchProducts(
|
CTX.fetchProducts(
|
||||||
0,
|
0,
|
||||||
props.id[0],
|
props.id[0] != 0 ? props.id[0] : "",
|
||||||
props.selectedBrands,
|
props.selectedBrands,
|
||||||
props.isChecked,
|
props.isChecked,
|
||||||
props.rangePrice,
|
props.rangePrice,
|
||||||
props.rangePrice,
|
props.rangePrice,
|
||||||
props.sortBy,
|
props.sortBy != -1 ? props.sortBy : "",
|
||||||
props.isRangePrice
|
props.isRangePrice
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,78 +10,95 @@ const PaginationCategoory = (props) => {
|
||||||
const pageGetProducts = CTX.state.pageGetProducts;
|
const pageGetProducts = CTX.state.pageGetProducts;
|
||||||
|
|
||||||
const [currentPageIndex, setCurrentPageIndex] = useState(pageGetProducts);
|
const [currentPageIndex, setCurrentPageIndex] = useState(pageGetProducts);
|
||||||
|
|
||||||
const renderPaginationButtons = () => {
|
const renderPaginationButtons = () => {
|
||||||
const buttons = [];
|
const buttons = [];
|
||||||
for (let i = 0; i < pager?.totalPage; i++) {
|
const totalPages = pager?.totalPage;
|
||||||
buttons.push(
|
const maxButtonsToShow = 7; // Maximum buttons to show
|
||||||
<div
|
|
||||||
key={i}
|
// If total pages are greater than maxButtonsToShow
|
||||||
className={`w-[25px] h-[25px] rounded-full tr03 bg-${
|
if (totalPages > maxButtonsToShow) {
|
||||||
currentPageIndex === i ? "secondary-500" : "primary-200"
|
// Show buttons for the first page
|
||||||
} mx-1 cursor-pointer`}
|
buttons.push(renderPageButton(0));
|
||||||
onClick={() => {
|
|
||||||
console.log("ss", i);
|
// If current page is not too close to the start, show ellipsis
|
||||||
setCurrentPageIndex(i);
|
if (currentPageIndex > 2) {
|
||||||
CTX.fetchProducts(
|
buttons.push(renderEllipsis());
|
||||||
i,
|
}
|
||||||
props.id[0],
|
|
||||||
props.selectedBrands,
|
// Calculate the start index for buttons
|
||||||
props.isChecked,
|
const start = Math.max(1, currentPageIndex - 2);
|
||||||
props.rangePrice,
|
|
||||||
props.rangePrice,
|
// Calculate the end index for buttons
|
||||||
props.sortBy,
|
const end = Math.min(currentPageIndex + 3, totalPages - 1);
|
||||||
props.isRangePrice,
|
|
||||||
true //pagination say or not
|
// Show buttons for pages within range
|
||||||
);
|
for (let i = start; i <= end; i++) {
|
||||||
}}
|
buttons.push(renderPageButton(i));
|
||||||
>
|
}
|
||||||
<p className="mb-0 text-center pt-[2px] text-white">
|
|
||||||
<PersianNumber number={i + 1} style=" !text-[14px] " />
|
// If current page is not too close to the end, show ellipsis
|
||||||
</p>
|
if (currentPageIndex < totalPages - 4) {
|
||||||
</div>
|
buttons.push(renderEllipsis());
|
||||||
);
|
}
|
||||||
|
|
||||||
|
// Show button for the last page
|
||||||
|
buttons.push(renderPageButton(totalPages - 1));
|
||||||
|
} else {
|
||||||
|
// Show buttons for all pages
|
||||||
|
for (let i = 0; i < totalPages; i++) {
|
||||||
|
buttons.push(renderPageButton(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderPageButton = (pageIndex) => (
|
||||||
|
<div
|
||||||
|
key={pageIndex}
|
||||||
|
className={`w-[25px] h-[25px] rounded-full tr03 bg-${
|
||||||
|
currentPageIndex === pageIndex ? "secondary-500" : "primary-200"
|
||||||
|
} mx-1 cursor-pointer`}
|
||||||
|
onClick={() => handlePageClick(pageIndex)}
|
||||||
|
>
|
||||||
|
<p className="mb-0 text-center pt-[2px] text-white">
|
||||||
|
<PersianNumber number={pageIndex + 1} style=" !text-[14px] " />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const renderEllipsis = () => (
|
||||||
|
<div key="ellipsis" className="mx-1">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
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 (
|
return (
|
||||||
<div className="flex justify-center rtl mb-10">
|
<div className="flex justify-center rtl mb-10">
|
||||||
<div className="w-[25px] h-[25px] rounded-full bg-primary-300 mx-2">
|
<div className="w-[25px] h-[25px] rounded-full bg-primary-300 mx-2">
|
||||||
<svg
|
{/* Previous page button */}
|
||||||
width="13"
|
|
||||||
height="13"
|
|
||||||
viewBox="0 0 88 151"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
className="mx-auto mt-[6px] "
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M12.9525 138.35L75.249 75.6471L12.5462 13.3506"
|
|
||||||
stroke="white"
|
|
||||||
stroke-width="25"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
{renderPaginationButtons()}
|
{renderPaginationButtons()}
|
||||||
<div className="w-[25px] h-[25px] rounded-full bg-primary-300 mx-2">
|
<div className="w-[25px] h-[25px] rounded-full bg-primary-300 mx-2">
|
||||||
<svg
|
{/* Next page button */}
|
||||||
width="13"
|
|
||||||
height="13"
|
|
||||||
viewBox="0 0 88 151"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
className="mx-auto mt-[6px] rotate-180 "
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M12.9525 138.35L75.249 75.6471L12.5462 13.3506"
|
|
||||||
stroke="white"
|
|
||||||
stroke-width="25"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
import Script from "next/script";
|
import Script from "next/script";
|
||||||
|
|
||||||
export default function Goftino() {
|
export default function Yektanet() {
|
||||||
const getGoftiono = () => {
|
const getYektanet = () => {
|
||||||
return {
|
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() {
|
||||||
<>
|
<>
|
||||||
<Script
|
<Script
|
||||||
strategy="afterInteractive"
|
strategy="afterInteractive"
|
||||||
dangerouslySetInnerHTML={getGoftiono()}
|
dangerouslySetInnerHTML={getYektanet()}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -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 (
|
||||||
|
<>
|
||||||
|
<Script
|
||||||
|
strategy="afterInteractive"
|
||||||
|
dangerouslySetInnerHTML={getGoftiono()}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -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;
|
|
@ -35,10 +35,9 @@ export async function generateMetadata({ params }) {
|
||||||
|
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
url: JSON.stringify(
|
url:
|
||||||
process.env.NEXT_PUBLIC_STORAGE_URL + "/" + data?.product?.files &&
|
process.env.NEXT_PUBLIC_STORAGE_URL + "/" + data?.product?.files &&
|
||||||
data?.product?.files[0].fileLocation
|
data?.product?.files[0].fileLocation, // Dynamic og route
|
||||||
), // Dynamic og route
|
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue