Skip to content

Commit 658c7c0

Browse files
committed
error fixes
1 parent 4667c59 commit 658c7c0

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

client/src/components/design-elements/Table.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ function HasMoreTablePaginationActions(
346346
) {
347347
const theme = useTheme();
348348
const { hasMore, page, onPageChange } = props;
349-
console.log(JSON.stringify(props, null, 2));
350349

351350
const handleFirstPageButtonClick = (
352351
event: React.MouseEvent<HTMLButtonElement>
@@ -420,7 +419,7 @@ interface PaginationProps extends TablePaginationProps {
420419
}
421420

422421
export const Pagination = ({ ...props }: PaginationProps) => {
423-
const hasMore = props.hasMore;
422+
const { hasMore, ...rest } = props;
424423
const isSmall = useMediaQuery((theme: any) => theme.breakpoints.down("sm"));
425424
const theme = useTheme();
426425
const labelDisplayedRows = ({
@@ -440,12 +439,16 @@ export const Pagination = ({ ...props }: PaginationProps) => {
440439

441440
return (
442441
<TablePagination
443-
ActionsComponent={
444-
hasMore ? HasMoreTablePaginationActions : TablePaginationActions
442+
ActionsComponent={(props) =>
443+
typeof hasMore === "boolean" ? (
444+
<HasMoreTablePaginationActions {...props} hasMore={hasMore} />
445+
) : (
446+
<TablePaginationActions {...props} />
447+
)
445448
}
446449
rowsPerPageOptions={[5, 10, 25]}
447450
labelDisplayedRows={labelDisplayedRows}
448-
{...props}
451+
{...rest}
449452
sx={{
450453
"& .MuiTablePagination-toolbar": isSmall
451454
? {

client/src/pages/checks/ChecksPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ChecksTable } from "@/pages/checks/ChecksTable";
77
import { LoadingSpinner } from "@/components/design-elements";
88

99
import { useTheme } from "@mui/material/styles";
10-
import { useState } from "react";
10+
import { useEffect, useState } from "react";
1111
import type { SelectChangeEvent } from "@mui/material/Select";
1212
import { useGet } from "@/hooks/UseApi";
1313
import type { ApiResponse } from "@/types/api";
@@ -46,6 +46,10 @@ const ChecksPage = () => {
4646
const checks = checksResponse?.data?.checks || [];
4747
const hasMore = checksResponse?.data?.hasMore;
4848

49+
useEffect(() => {
50+
setPage(0);
51+
}, [range, status, selectedMonitorId]);
52+
4953
return (
5054
<BasePage>
5155
<InfoBox

client/src/pages/checks/ChecksTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const ChecksTable = ({
114114
/>
115115
<Pagination
116116
component="div"
117-
count={0}
117+
count={(page + 1) * rowsPerPage + 1}
118118
hasMore={hasMore}
119119
page={page}
120120
rowsPerPage={rowsPerPage}

0 commit comments

Comments
 (0)