Pagination.js 2.13 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

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
        <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)} />}
kusang96's avatar
kusang96 committed
10
11
12
            {props.index === props.totalPosts-1 ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
            {props.index === props.totalPosts ? <Pagination.Item onClick={()=>props.handlePage(props.index - 4)}>{props.index - 4}</Pagination.Item> : ""}
            {props.index === props.totalPosts ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
kusang96's avatar
kusang96 committed
13
14
15
16
17
            {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>

kusang96's avatar
kusang96 committed
18
19
            {props.index === props.totalPosts ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 1)}>{props.index + 1}</Pagination.Item>}
            {props.index > props.totalPosts-2 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 2)}>{props.index + 2}</Pagination.Item>}
kusang96's avatar
kusang96 committed
20
21
22
            {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> : ""}
kusang96's avatar
kusang96 committed
23
24
            {props.index === props.totalPosts ? "" : <Pagination.Next onClick={()=>props.handlePage(props.index + 1)} />}
            <Pagination.Last onClick={() =>props.handlePage(props.totalPosts)} />
kusang96's avatar
kusang96 committed
25
        </Pagination>
Kim, Subin's avatar
Kim, Subin committed
26
    )
kusang96's avatar
kusang96 committed
27
}
kusang96's avatar
DSAD    
kusang96 committed
28

kusang96's avatar
kusang96 committed
29
export default Paginations