Paginations.js 3.59 KB
Newer Older
1
2
3
4
5
6
7
8
import { Pagination } from "react-bootstrap";
import React from 'react';



function Paginations(props) {

    return (
baesangjune's avatar
baesangjune committed
9
10
        <>
            {(props.endPage > 5) ?
Lee SeoYeon's avatar
0127    
Lee SeoYeon committed
11
                <Pagination >
baesangjune's avatar
baesangjune committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
                    <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>
                :
                <Pagination>
34
35
                    {props.index === 1 ? "" : <Pagination.First onClick={() => props.handlePage(1)} />}
                    {props.index === 1 ? "" : <Pagination.Prev onClick={() => props.handlePage(props.index - 1)} />}
baesangjune's avatar
baesangjune committed
36
37
38
39
40
                    <Pagination.Item onClick={() => props.handlePage(1)} active={props.index === 1}>1</Pagination.Item>
                    {props.endPage > 1 ? <Pagination.Item onClick={() => props.handlePage(2)} active={props.index === 2}>2</Pagination.Item> : ""}
                    {props.endPage > 2 ? <Pagination.Item onClick={() => props.handlePage(3)} active={props.index === 3}>3</Pagination.Item> : ""}
                    {props.endPage > 3 ? <Pagination.Item onClick={() => props.handlePage(4)} active={props.index === 4}>4</Pagination.Item> : ""}
                    {props.endPage > 4 ? <Pagination.Item onClick={() => props.handlePage(5)} active={props.index === 5}>5</Pagination.Item> : ""}
41
42
                    {props.index === props.endPage ? "" : <Pagination.Next onClick={() => props.handlePage(props.index + 1)} />}
                    {props.index === props.endPage ? "" : <Pagination.Last onClick={() => props.handlePage(props.endPage)} />}
baesangjune's avatar
baesangjune committed
43
44
45
46
47
48
49




                </Pagination>
            }
        </>
50
51
52
53
    )

}
export default Paginations