fix pagination ui | 24

temp
mahdi 2 years ago
parent 0fdbb61e6d
commit 81fd4b9be2
  1. 22
      src/views/Products/layouts/Desktop/Main.js

@ -15,6 +15,7 @@ import dropdownIcon from "../../../../assets/icons/dropdown-blue.svg";
import Posts from "./Posts"; import Posts from "./Posts";
import Pagination from "./Pagination"; import Pagination from "./Pagination";
const num = 6; const num = 6;
export const Main = ({ export const Main = ({
books, books,
grades, grades,
@ -38,6 +39,7 @@ export const Main = ({
useEffect(() => { useEffect(() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);
}, []); }, []);
useEffect(() => { useEffect(() => {
setTotal(books.length); setTotal(books.length);
}, [books]); }, [books]);
@ -95,23 +97,17 @@ export const Main = ({
const elements = Items(1); const elements = Items(1);
const vods = Items(2); const vods = Items(2);
console.log(elements.length); console.log(elements.length);
const lastPage = Math.floor((elements.length - 1) / num) + 1; const lastPage = Math.floor((elements.length - 1) / num) + 1;
const pages = lastPage > 1 ? [...Array(lastPage)].map((e, i) => i + 1) : []; const pages = lastPage > 1 ? [...Array(lastPage)].map((e, i) => i + 1) : [];
return ( return (
<div <div
className="flex flex-col w-3/4 pb-20 min-h-screen" className="flex flex-col w-3/4 pb-20 min-h-screen"
style={{ minWidth: "calc(100% * 3 / 4)" }} style={{ minWidth: "calc(100% * 3 / 4)" }}
> >
{/* <div className="bg-red-400 ">
<h1 className="mb-5">My Blog</h1>
<Posts posts={currentPosts} loading={loading} />
<Pagination
postsPerPage={postsPerPage}
totalPosts={posts.length}
paginate={paginate}
/>
</div> */}
<div className="flex w-full bg-blue rounded-lg border border-solid border-gray-200 p-2 items-center my-1.5 justify-center text-blue52"> <div className="flex w-full bg-blue rounded-lg border border-solid border-gray-200 p-2 items-center my-1.5 justify-center text-blue52">
<div className="flex text-sm items-center mr-2 ml-4"> <div className="flex text-sm items-center mr-2 ml-4">
<svg <svg
@ -203,6 +199,7 @@ export const Main = ({
<Loading size={4} color="bg-green-400" /> <Loading size={4} color="bg-green-400" />
</div> </div>
)} )}
{books.length > 0 && ( {books.length > 0 && (
<div className="relative w-full mt-7 " style={{ direction: "ltr" }}> <div className="relative w-full mt-7 " style={{ direction: "ltr" }}>
<Carousel <Carousel
@ -250,6 +247,7 @@ export const Main = ({
</Carousel> </Carousel>
</div> </div>
)} )}
<div className="w-full flex flex-row flex-wrap mt-0 border-t-2 border-solid border-gray-100 overflow-y-hidden gap-4 justify-evenly pt-3"> <div className="w-full flex flex-row flex-wrap mt-0 border-t-2 border-solid border-gray-100 overflow-y-hidden gap-4 justify-evenly pt-3">
{elements {elements
?.slice((page - 1) * num, page * num) ?.slice((page - 1) * num, page * num)
@ -263,10 +261,12 @@ export const Main = ({
type={0} type={0}
/> />
))} ))}
<div className="flex w-full justify-center">
<div className="w-full flex justify-center gap-x-2">
{pages.map((e) => ( {pages.map((e) => (
<div <div
className="m-1 p-1 rounded bg-gray-200 " style={{ backgroundColor: "#DEFFF188" }}
className="w-8 p-2 text-sm text-center rounded-md text-green7B cursor-pointer transform translate"
onClick={() => setPage(e)} onClick={() => setPage(e)}
> >
{e} {e}

Loading…
Cancel
Save