Redirect to notfound if monitor does not exist
This commit is contained in:
1 parent
9da7c00bd3
commit
5880ddbb14
2 files changed
+13
-1
No files matched your search
@@ -62,6 +62,10 @@ const Configure = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const data = monitors.find((monitor) => monitor._id === monitorId);
|
||||
if (!data) {
|
||||
console.error("Error fetching monitor of id: " + monitorId);
|
||||
navigate("/not-found");
|
||||
}
|
||||
setMonitor({
|
||||
...data,
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ const DetailsPage = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const fetchMonitor = async () => {
|
||||
try {
|
||||
const res = await axiosInstance.get(
|
||||
`/monitors/${monitorId}?sortOrder=asc`,
|
||||
{
|
||||
@@ -74,7 +75,10 @@ const DetailsPage = () => {
|
||||
/>
|
||||
),
|
||||
},
|
||||
{ id: idx + 1, data: new Date(check.createdAt).toLocaleString() },
|
||||
{
|
||||
id: idx + 1,
|
||||
data: new Date(check.createdAt).toLocaleString(),
|
||||
},
|
||||
{ id: idx + 2, data: check.statusCode },
|
||||
],
|
||||
};
|
||||
@@ -82,6 +86,10 @@ const DetailsPage = () => {
|
||||
};
|
||||
|
||||
setData(data);
|
||||
} catch (error) {
|
||||
console.error("Error fetching monitor of id: " + monitorId);
|
||||
navigate("/not-found");
|
||||
}
|
||||
};
|
||||
fetchMonitor();
|
||||
}, [monitorId, authToken]);
|
||||
|
||||
Reference in new issue
Block a user