Add table prop to BasicTable to specify table name
This commit is contained in:
1 parent
d5daa14a98
commit
710fad0ec8
4 files changed
+9
-8
No files matched your search
@@ -15,7 +15,6 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { useLocation } from "react-router-dom";
|
|
||||||
import { setRowsPerPage } from "../../Features/UI/uiSlice";
|
import { setRowsPerPage } from "../../Features/UI/uiSlice";
|
||||||
import LeftArrowDouble from "../../assets/icons/left-arrow-double.svg?react";
|
import LeftArrowDouble from "../../assets/icons/left-arrow-double.svg?react";
|
||||||
import RightArrowDouble from "../../assets/icons/right-arrow-double.svg?react";
|
import RightArrowDouble from "../../assets/icons/right-arrow-double.svg?react";
|
||||||
@@ -150,13 +149,11 @@ TablePaginationActions.propTypes = {
|
|||||||
* <BasicTable data={data} rows={rows} paginated={true} />
|
* <BasicTable data={data} rows={rows} paginated={true} />
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const BasicTable = ({ data, paginated, reversed }) => {
|
const BasicTable = ({ data, paginated, reversed, table }) => {
|
||||||
const DEFAULT_ROWS_PER_PAGE = 5;
|
const DEFAULT_ROWS_PER_PAGE = 5;
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const location = useLocation();
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const uiState = useSelector((state) => state.ui);
|
const uiState = useSelector((state) => state.ui);
|
||||||
let table = location.pathname.split("/").pop();
|
|
||||||
let rowsPerPage = uiState?.[table]?.rowsPerPage ?? DEFAULT_ROWS_PER_PAGE;
|
let rowsPerPage = uiState?.[table]?.rowsPerPage ?? DEFAULT_ROWS_PER_PAGE;
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
|
|
||||||
@@ -293,6 +290,7 @@ BasicTable.propTypes = {
|
|||||||
paginated: PropTypes.bool,
|
paginated: PropTypes.bool,
|
||||||
reversed: PropTypes.bool,
|
reversed: PropTypes.bool,
|
||||||
rowPerPage: PropTypes.number,
|
rowPerPage: PropTypes.number,
|
||||||
|
table: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BasicTable;
|
export default BasicTable;
|
||||||
@@ -294,7 +294,12 @@ const TeamPanel = () => {
|
|||||||
onClick={() => setIsOpen(true)}
|
onClick={() => setIsOpen(true)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<BasicTable data={tableData} paginated={false} reversed={true} />
|
<BasicTable
|
||||||
|
data={tableData}
|
||||||
|
paginated={false}
|
||||||
|
reversed={true}
|
||||||
|
table={"team"}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Modal
|
<Modal
|
||||||
aria-labelledby="modal-invite-member"
|
aria-labelledby="modal-invite-member"
|
||||||
|
|||||||
@@ -330,9 +330,7 @@ const DetailsPage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.gap.ml}>
|
<Stack gap={theme.gap.ml}>
|
||||||
<Typography component="h2">History</Typography>
|
<Typography component="h2">History</Typography>
|
||||||
{/* TODO New Table */}
|
|
||||||
<PaginationTable monitorId={monitorId} dateRange={dateRange} />
|
<PaginationTable monitorId={monitorId} dateRange={dateRange} />
|
||||||
{/* <BasicTable data={data} paginated={true} /> */}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ const Monitors = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
{/* TODO - add search bar */}
|
{/* TODO - add search bar */}
|
||||||
</Stack>
|
</Stack>
|
||||||
<BasicTable data={data} paginated={true} />
|
<BasicTable data={data} paginated={true} table={"monitors"} />
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in new issue
Block a user