forked from dmm-com/pagoda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaginationFooter.tsx
45 lines (41 loc) · 1.04 KB
/
PaginationFooter.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Pagination, Stack, Typography } from "@mui/material";
import { styled } from "@mui/material/styles";
import React, { FC } from "react";
import { CenterAlignedBox } from "components/common/FlexBox";
const StyledBox = styled(CenterAlignedBox)(({}) => ({
alignItems: "center",
margin: "30px 0",
}));
interface Props {
count: number;
maxRowCount: number;
page: number;
changePage: (page: number) => void;
}
export const PaginationFooter: FC<Props> = ({
count,
maxRowCount,
page,
changePage,
}) => {
return (
<StyledBox id="pagination">
<Typography>
{`${Math.min(maxRowCount * (page - 1) + 1, count)} - ${Math.min(
maxRowCount * page,
count,
)} / ${count} 件`}
</Typography>
<Stack spacing={2}>
<Pagination
count={Math.ceil(count / maxRowCount)}
page={page}
onChange={(_, newPage) => changePage(newPage)}
siblingCount={0}
boundaryCount={1}
color="primary"
/>
</Stack>
</StyledBox>
);
};