pagination.js 2.25 KB
Newer Older
baesangjune's avatar
style    
baesangjune committed
1
2
3
4
5
6
import { Pagination } from "react-bootstrap";
import React from 'react';



function Paginations(props) {
baesangjune's avatar
modal    
baesangjune committed
7
    // console.log(props)
baesangjune's avatar
style    
baesangjune committed
8
9
10
11
12
    // const [index, setIndex] = useState(1);

    return (
        <Pagination>
            <Pagination.First onClick={() => props.handlePage(1)} />
baesangjune's avatar
modal    
baesangjune committed
13
            {props.index === 1 ? <Pagination.Prev onClick={()=>props.handlePage(props.index)} /> : <Pagination.Prev onClick={()=>props.handlePage(props.index - 1)} />}
baesangjune's avatar
style    
baesangjune committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
            {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> : ""}
baesangjune's avatar
css    
baesangjune committed
28
            {props.index === props.endPage ? <Pagination.Next onClick={()=>props.handlePage(props.index)} /> : <Pagination.Next onClick={()=>props.handlePage(props.index + 1)} />}
baesangjune's avatar
style    
baesangjune committed
29
30
31
32
33
34
35
36
37

            <Pagination.Last onClick={() =>props.handlePage(props.endPage)} />
        </Pagination>


    )

}
export default Paginations