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