From 81fd4b9be2703202e7fc44c934465690d6d883a5 Mon Sep 17 00:00:00 2001 From: mahdi Date: Tue, 5 Jul 2022 09:51:16 +0430 Subject: [PATCH] fix pagination ui | 24 --- src/views/Products/layouts/Desktop/Main.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/views/Products/layouts/Desktop/Main.js b/src/views/Products/layouts/Desktop/Main.js index 3ae9a3a..2fc794d 100644 --- a/src/views/Products/layouts/Desktop/Main.js +++ b/src/views/Products/layouts/Desktop/Main.js @@ -15,6 +15,7 @@ import dropdownIcon from "../../../../assets/icons/dropdown-blue.svg"; import Posts from "./Posts"; import Pagination from "./Pagination"; const num = 6; + export const Main = ({ books, grades, @@ -38,6 +39,7 @@ export const Main = ({ useEffect(() => { window.scrollTo(0, 0); }, []); + useEffect(() => { setTotal(books.length); }, [books]); @@ -95,23 +97,17 @@ export const Main = ({ const elements = Items(1); const vods = Items(2); + console.log(elements.length); + const lastPage = Math.floor((elements.length - 1) / num) + 1; const pages = lastPage > 1 ? [...Array(lastPage)].map((e, i) => i + 1) : []; + return (
- {/*
-

My Blog

- - -
*/}
)} + {books.length > 0 && (
)} +
{elements ?.slice((page - 1) * num, page * num) @@ -263,10 +261,12 @@ export const Main = ({ type={0} /> ))} -
+ +
{pages.map((e) => (
setPage(e)} > {e}