navigate on click
This commit is contained in:
1 parent
66c406151a
commit
7681edbf49
2 files changed
+12
-15
No files matched your search
@@ -23,22 +23,14 @@ const ChecksPage = () => {
|
||||
const [page, setPage] = useState(0);
|
||||
const [rowsPerPage, setRowsPerPage] = useState(10);
|
||||
|
||||
const {
|
||||
response: monitorResponse,
|
||||
loading: monitorsLoading,
|
||||
isValidating: monitorsValidating,
|
||||
} = useGet<ApiResponse<IMonitor[]>>(
|
||||
`/monitors`,
|
||||
{},
|
||||
{ keepPreviousData: true }
|
||||
);
|
||||
const { response: monitorResponse, loading: monitorsLoading } = useGet<
|
||||
ApiResponse<IMonitor[]>
|
||||
>(`/monitors`, {}, { keepPreviousData: true });
|
||||
const monitors: IMonitor[] = monitorResponse?.data || [];
|
||||
|
||||
const {
|
||||
response: checksResponse,
|
||||
loading: checksLoading,
|
||||
isValidating: checksValidating,
|
||||
} = useGet<ApiResponse<{ count: number; checks: ICheck[] }>>(
|
||||
const { response: checksResponse, loading: checksLoading } = useGet<
|
||||
ApiResponse<{ count: number; checks: ICheck[] }>
|
||||
>(
|
||||
`/checks?page=${page}&rowsPerPage=${rowsPerPage}&range=${range}&status=${status}${
|
||||
selectedMonitorId !== "all" ? `&monitorId=${selectedMonitorId}` : ""
|
||||
}`,
|
||||
@@ -93,7 +85,7 @@ const ChecksPage = () => {
|
||||
<MenuItem value="down">Down</MenuItem>
|
||||
</Select>
|
||||
<LoadingSpinner
|
||||
show={monitorsValidating || checksValidating}
|
||||
show={monitorsLoading || checksLoading}
|
||||
sx={{ alignSelf: "center" }}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
@@ -12,6 +12,7 @@ import { formatDateWithTz } from "@/utils/TimeUtils";
|
||||
import { useAppSelector } from "@/hooks/AppHooks";
|
||||
import type { ICheck } from "@/types/check";
|
||||
import type { MonitorStatus } from "@/types/monitor";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
type CheckWithMonitor = ICheck & {
|
||||
metadata?: { monitorId?: { name?: string } };
|
||||
@@ -34,6 +35,7 @@ export const ChecksTable = ({
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const uiTimezone = useAppSelector((state: any) => state.ui.timezone);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const getHeaders = (t: Function, uiTimezone: string) => {
|
||||
const headers: Header<CheckWithMonitor>[] = [
|
||||
@@ -105,6 +107,9 @@ export const ChecksTable = ({
|
||||
<Table
|
||||
headers={headers}
|
||||
data={checks}
|
||||
onRowClick={(row) => {
|
||||
navigate(`/checks/${row._id}`);
|
||||
}}
|
||||
emptyViewText={t("checks.table.empty")}
|
||||
/>
|
||||
<Pagination
|
||||
|
||||
Reference in new issue
Block a user