Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cms, jsk, emp global search frontend
- Loading branch information
1 parent
04f8344
commit 9e772a4
Showing
6 changed files
with
785 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
import * as React from "react"; | ||
import { useTheme } from "@mui/material/styles"; | ||
import Box from "@mui/material/Box"; | ||
import Table from "@mui/material/Table"; | ||
import TableBody from "@mui/material/TableBody"; | ||
import TableCell from "@mui/material/TableCell"; | ||
import TableContainer from "@mui/material/TableContainer"; | ||
import TableFooter from "@mui/material/TableFooter"; | ||
import TablePagination from "@mui/material/TablePagination"; | ||
import TableRow from "@mui/material/TableRow"; | ||
import Paper from "@mui/material/Paper"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import FirstPageIcon from "@mui/icons-material/FirstPage"; | ||
import KeyboardArrowLeft from "@mui/icons-material/KeyboardArrowLeft"; | ||
import KeyboardArrowRight from "@mui/icons-material/KeyboardArrowRight"; | ||
import LastPageIcon from "@mui/icons-material/LastPage"; | ||
import Link from "@mui/material/Link"; | ||
|
||
interface TablePaginationActionsProps { | ||
count: number; | ||
page: number; | ||
rowsPerPage: number; | ||
onPageChange: ( | ||
event: React.MouseEvent<HTMLButtonElement>, | ||
newPage: number | ||
) => void; | ||
} | ||
|
||
function TablePaginationActions(props: TablePaginationActionsProps) { | ||
const theme = useTheme(); | ||
const { count, page, rowsPerPage, onPageChange } = props; | ||
|
||
const handleFirstPageButtonClick = ( | ||
event: React.MouseEvent<HTMLButtonElement> | ||
) => { | ||
onPageChange(event, 0); | ||
}; | ||
|
||
const handleBackButtonClick = ( | ||
event: React.MouseEvent<HTMLButtonElement> | ||
) => { | ||
onPageChange(event, page - 1); | ||
}; | ||
|
||
const handleNextButtonClick = ( | ||
event: React.MouseEvent<HTMLButtonElement> | ||
) => { | ||
onPageChange(event, page + 1); | ||
}; | ||
|
||
const handleLastPageButtonClick = ( | ||
event: React.MouseEvent<HTMLButtonElement> | ||
) => { | ||
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1)); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ flexShrink: 0, ml: 2.5 }}> | ||
<IconButton | ||
onClick={handleFirstPageButtonClick} | ||
disabled={page === 0} | ||
aria-label="first page" | ||
> | ||
{theme.direction === "rtl" ? <LastPageIcon /> : <FirstPageIcon />} | ||
</IconButton> | ||
<IconButton | ||
onClick={handleBackButtonClick} | ||
disabled={page === 0} | ||
aria-label="previous page" | ||
> | ||
{theme.direction === "rtl" ? ( | ||
<KeyboardArrowRight /> | ||
) : ( | ||
<KeyboardArrowLeft /> | ||
)} | ||
</IconButton> | ||
<IconButton | ||
onClick={handleNextButtonClick} | ||
disabled={page >= Math.ceil(count / rowsPerPage) - 1} | ||
aria-label="next page" | ||
> | ||
{theme.direction === "rtl" ? ( | ||
<KeyboardArrowLeft /> | ||
) : ( | ||
<KeyboardArrowRight /> | ||
)} | ||
</IconButton> | ||
<IconButton | ||
onClick={handleLastPageButtonClick} | ||
disabled={page >= Math.ceil(count / rowsPerPage) - 1} | ||
aria-label="last page" | ||
> | ||
{theme.direction === "rtl" ? <FirstPageIcon /> : <LastPageIcon />} | ||
</IconButton> | ||
</Box> | ||
); | ||
} | ||
|
||
export default function CustomPaginationActionsTable(props) { | ||
const { | ||
page, | ||
rowsPerPage, | ||
emptyRows, | ||
handleChangePage, | ||
handleChangeRowsPerPage, | ||
rows, | ||
} = props; | ||
console.log(10, props); | ||
return ( | ||
<TableContainer> | ||
<Table | ||
sx={{ minWidth: 500, border: "none" }} | ||
aria-label="custom pagination table" | ||
> | ||
<TableBody> | ||
{rows.map((row) => ( | ||
<TableRow key={row._id}> | ||
<TableCell component="th" scope="row" style={{ width: 160 }}> | ||
{row.text} | ||
</TableCell> | ||
<TableCell style={{ width: 160 }} align="right"> | ||
<Link href={row.link} onClick={props.rowClick}> | ||
{" "} | ||
{row.link} | ||
</Link> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
{emptyRows > 0 && ( | ||
<TableRow style={{ height: 53 * emptyRows }}> | ||
<TableCell colSpan={6} /> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
<TableFooter> | ||
<TableRow> | ||
<TablePagination | ||
style={{ width: 160, borderBottom: "none" }} | ||
rowsPerPageOptions={[5, 10, 25, { label: "All", value: -1 }]} | ||
colSpan={3} | ||
count={props.count} | ||
rowsPerPage={rowsPerPage} | ||
page={page} | ||
SelectProps={{ | ||
inputProps: { | ||
"aria-label": "rows per page", | ||
}, | ||
native: true, | ||
}} | ||
onPageChange={handleChangePage} | ||
onRowsPerPageChange={handleChangeRowsPerPage} | ||
ActionsComponent={TablePaginationActions} | ||
/> | ||
</TableRow> | ||
</TableFooter> | ||
</Table> | ||
</TableContainer> | ||
); | ||
} |
Oops, something went wrong.