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 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();
|
||||
}, []);
|
||||
|
||||
|
|
|
@ -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 }) => {
|
|||
/>
|
||||
|
||||
<Goftino />
|
||||
<Yektanet />
|
||||
</AppContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ const FilterCategory = ({
|
|||
isChecked,
|
||||
rangePrice[0],
|
||||
rangePrice[1],
|
||||
sortBy,
|
||||
sortBy != -1 ? sortBy : "",
|
||||
isRangePrice
|
||||
);
|
||||
};
|
||||
|
@ -68,12 +68,12 @@ const FilterCategory = ({
|
|||
|
||||
CTX.fetchProducts(
|
||||
0,
|
||||
id[0],
|
||||
id[0] != 0 ? id[0] : "",
|
||||
selectedBrands,
|
||||
isChecked,
|
||||
rangePrice[0],
|
||||
rangePrice[1],
|
||||
sortBy,
|
||||
sortBy != -1 ? sortBy : "",
|
||||
isRangePrice
|
||||
);
|
||||
}, [CTX.state.selectedBrands, CTX.state.isChecked]);
|
||||
|
|
|
@ -34,7 +34,7 @@ const ListProdocts = ({
|
|||
isChecked,
|
||||
rangePrice,
|
||||
rangePrice,
|
||||
sortBy,
|
||||
sortBy != -1 ? sortBy : "",
|
||||
isRangePrice
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,12 +13,12 @@ const FilterCategoryMobile = (props) => {
|
|||
if (props.sortBy != -1) {
|
||||
CTX.fetchProducts(
|
||||
0,
|
||||
props.id[0],
|
||||
props.id[0] != 0 ? props.id[0] : "",
|
||||
props.selectedBrands,
|
||||
props.isChecked,
|
||||
props.rangePrice,
|
||||
props.rangePrice,
|
||||
props.sortBy,
|
||||
props.sortBy != -1 ? props.sortBy : "",
|
||||
props.isRangePrice
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,78 +10,95 @@ const PaginationCategoory = (props) => {
|
|||
const pageGetProducts = CTX.state.pageGetProducts;
|
||||
|
||||
const [currentPageIndex, setCurrentPageIndex] = useState(pageGetProducts);
|
||||
|
||||
const renderPaginationButtons = () => {
|
||||
const buttons = [];
|
||||
for (let i = 0; i < pager?.totalPage; i++) {
|
||||
buttons.push(
|
||||
const totalPages = pager?.totalPage;
|
||||
const maxButtonsToShow = 7; // Maximum buttons to show
|
||||
|
||||
// If total pages are greater than maxButtonsToShow
|
||||
if (totalPages > maxButtonsToShow) {
|
||||
// Show buttons for the first page
|
||||
buttons.push(renderPageButton(0));
|
||||
|
||||
// If current page is not too close to the start, show ellipsis
|
||||
if (currentPageIndex > 2) {
|
||||
buttons.push(renderEllipsis());
|
||||
}
|
||||
|
||||
// Calculate the start index for buttons
|
||||
const start = Math.max(1, currentPageIndex - 2);
|
||||
|
||||
// Calculate the end index for buttons
|
||||
const end = Math.min(currentPageIndex + 3, totalPages - 1);
|
||||
|
||||
// Show buttons for pages within range
|
||||
for (let i = start; i <= end; i++) {
|
||||
buttons.push(renderPageButton(i));
|
||||
}
|
||||
|
||||
// If current page is not too close to the end, show ellipsis
|
||||
if (currentPageIndex < totalPages - 4) {
|
||||
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;
|
||||
};
|
||||
|
||||
const renderPageButton = (pageIndex) => (
|
||||
<div
|
||||
key={i}
|
||||
key={pageIndex}
|
||||
className={`w-[25px] h-[25px] rounded-full tr03 bg-${
|
||||
currentPageIndex === i ? "secondary-500" : "primary-200"
|
||||
currentPageIndex === pageIndex ? "secondary-500" : "primary-200"
|
||||
} mx-1 cursor-pointer`}
|
||||
onClick={() => {
|
||||
console.log("ss", i);
|
||||
setCurrentPageIndex(i);
|
||||
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(
|
||||
i,
|
||||
props.id[0],
|
||||
pageIndex,
|
||||
props.id[0] != 0 ? props.id[0] : "",
|
||||
props.selectedBrands,
|
||||
props.isChecked,
|
||||
props.rangePrice,
|
||||
props.rangePrice,
|
||||
props.sortBy,
|
||||
props.sortBy != -1 ? props.sortBy : "",
|
||||
props.isRangePrice,
|
||||
true //pagination say or not
|
||||
);
|
||||
}}
|
||||
>
|
||||
<p className="mb-0 text-center pt-[2px] text-white">
|
||||
<PersianNumber number={i + 1} style=" !text-[14px] " />
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return buttons;
|
||||
// Your fetchProducts function call here
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex justify-center rtl mb-10">
|
||||
<div className="w-[25px] h-[25px] rounded-full bg-primary-300 mx-2">
|
||||
<svg
|
||||
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>
|
||||
{/* Previous page button */}
|
||||
</div>
|
||||
{renderPaginationButtons()}
|
||||
<div className="w-[25px] h-[25px] rounded-full bg-primary-300 mx-2">
|
||||
<svg
|
||||
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>
|
||||
{/* Next page button */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -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() {
|
|||
<>
|
||||
<Script
|
||||
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: [
|
||||
{
|
||||
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,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue