Fetch monitor from params
This commit is contained in:
1 parent
219dd5cca7
commit
076c98f69a
2 files changed
+23
-3
No files matched your search
@@ -1,17 +1,36 @@
|
|||||||
import { useNavigate } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import axiosInstance from "../../../Utils/axiosConfig";
|
||||||
import Button from "../../../Components/Button";
|
import Button from "../../../Components/Button";
|
||||||
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { useTheme } from "@emotion/react";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure component displays monitor configurations and allows for editing actions.
|
* Configure page displays monitor configurations and allows for editing actions.
|
||||||
* @component
|
* @component
|
||||||
*/
|
*/
|
||||||
const Configure = () => {
|
const Configure = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
const [monitor, setMonitor] = useState();
|
||||||
|
const { monitorId } = useParams();
|
||||||
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchMonitor = async () => {
|
||||||
|
const res = await axiosInstance.get(`/monitors/${monitorId}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setMonitor(res.data.data);
|
||||||
|
};
|
||||||
|
fetchMonitor();
|
||||||
|
}, [monitorId, authToken]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ const DetailsPage = () => {
|
|||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Configure"
|
label="Configure"
|
||||||
img={<SettingsIcon />}
|
img={<SettingsIcon />}
|
||||||
|
onClick={() => navigate(`/monitors/configure/${monitorId}`)}
|
||||||
sx={{
|
sx={{
|
||||||
ml: "auto",
|
ml: "auto",
|
||||||
alignSelf: "flex-end",
|
alignSelf: "flex-end",
|
||||||
|
|||||||
Reference in new issue
Block a user