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

kusang96's avatar
kusang96 committed
4
function Paginations(props) {
Kim, Subin's avatar
Kim, Subin committed
5
6

    return (
kusang96's avatar
kusang96 committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        <Pagination>
            <Pagination.First onClick={() => props.handlePage(1)} />
            {props.index === 1 ? <Pagination.Prev onClick={()=>props.handlePage(props.index)} /> : <Pagination.Prev onClick={()=>props.handlePage(props.index - 1)} />}
            {props.index === props.endPage-1 ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
            {props.index === props.endPage ? <Pagination.Item onClick={()=>props.handlePage(props.index - 4)}>{props.index - 4}</Pagination.Item> : ""}
            {props.index === props.endPage ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
            {props.index < 3 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index - 2)}>{props.index - 2}</Pagination.Item>}
            {props.index === 1 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index - 1)}>{props.index - 1}</Pagination.Item>}

            <Pagination.Item active>{props.index}</Pagination.Item>


            {props.index === props.endPage ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 1)}>{props.index + 1}</Pagination.Item>}
            {props.index > props.endPage-2 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 2)}>{props.index + 2}</Pagination.Item>}
            {props.index === 1 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 3)}>{props.index + 3}</Pagination.Item> : ""}
            {props.index === 1 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 4)}>{props.index + 4}</Pagination.Item> : ""}
            {props.index === 2 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 3)}>{props.index + 3}</Pagination.Item> : ""}
            {props.index === props.endPage ? "" : <Pagination.Next onClick={()=>props.handlePage(props.index + 1)} />}

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

kusang96's avatar
kusang96 committed
30
}
kusang96's avatar
DSAD    
kusang96 committed
31

kusang96's avatar
kusang96 committed
32
export default Paginations