Pagination.js 1.8 KB
Newer Older
kusang96's avatar
kusang96 committed
1
import { Pagination } from "react-bootstrap";
2
import React from 'react';
Kim, Subin's avatar
Kim, Subin committed
3

4
function Paginations({ index, endPage, handlePage }) {
Kim, Subin's avatar
Kim, Subin committed
5
6

    return (
kusang96's avatar
kusang96 committed
7
        <Pagination>
kusang96's avatar
kusang96 committed
8
9
10
11
12
13
14
            <Pagination.First onClick={() => handlePage(1)} />
            {index === 1 ? <Pagination.Prev onClick={()=>handlePage(index)} /> : <Pagination.Prev onClick={()=>handlePage(index - 1)} />}
            {index === endPage-1 ? <Pagination.Item onClick={()=>handlePage(index - 3)}>{index - 3}</Pagination.Item> : ""}
            {index === endPage ? <Pagination.Item onClick={()=>handlePage(index - 4)}>{index - 4}</Pagination.Item> : ""}
            {index === endPage ? <Pagination.Item onClick={()=>handlePage(index - 3)}>{index - 3}</Pagination.Item> : ""}
            {index < 3 ? "" : <Pagination.Item onClick={()=>handlePage(index - 2)}>{index - 2}</Pagination.Item>}
            {index === 1 ? "" : <Pagination.Item onClick={()=>handlePage(index - 1)}>{index - 1}</Pagination.Item>}
kusang96's avatar
kusang96 committed
15

kusang96's avatar
kusang96 committed
16
            <Pagination.Item active>{index}</Pagination.Item>
kusang96's avatar
kusang96 committed
17

kusang96's avatar
kusang96 committed
18
19
20
21
22
23
            {index === endPage ? "" : <Pagination.Item onClick={()=>handlePage(index + 1)}>{index + 1}</Pagination.Item>}
            {index > endPage-2 ? "" : <Pagination.Item onClick={()=>handlePage(index + 2)}>{index + 2}</Pagination.Item>}
            {index === 1 ? <Pagination.Item onClick={()=>handlePage(index + 3)}>{index + 3}</Pagination.Item> : ""}
            {index === 1 ? <Pagination.Item onClick={()=>handlePage(index + 4)}>{index + 4}</Pagination.Item> : ""}
            {index === 2 ? <Pagination.Item onClick={()=>handlePage(index + 3)}>{index + 3}</Pagination.Item> : ""}
            {index === endPage ? "" : <Pagination.Next onClick={()=>handlePage(index + 1)} />}
kusang96's avatar
kusang96 committed
24

kusang96's avatar
kusang96 committed
25
            <Pagination.Last onClick={() =>handlePage(endPage)} />
kusang96's avatar
kusang96 committed
26
        </Pagination>
Kim, Subin's avatar
Kim, Subin committed
27
    )
kusang96's avatar
kusang96 committed
28
}
kusang96's avatar
DSAD    
kusang96 committed
29

kusang96's avatar
kusang96 committed
30
export default Paginations