remove authToken reading and passing in UI component and hooks
This commit is contained in:
1 parent
6a1e5532e4
commit
f2ae99768a
41 files changed
+76
-135
No files matched your search
@@ -48,7 +48,7 @@ const getAlertError = (errors) => {
|
||||
|
||||
const CreateInfrastructureMonitor = () => {
|
||||
const theme = useTheme();
|
||||
const { user, authToken } = useSelector((state) => state.auth);
|
||||
const { user } = useSelector((state) => state.auth);
|
||||
const monitorState = useSelector((state) => state.infrastructureMonitor);
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
@@ -148,7 +148,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
};
|
||||
|
||||
const action = await dispatch(
|
||||
createInfrastructureMonitor({ authToken, monitor: form })
|
||||
createInfrastructureMonitor({ monitor: form })
|
||||
);
|
||||
if (action.meta.requestStatus === "fulfilled") {
|
||||
createToast({ body: "Infrastructure monitor created successfully!" });
|
||||
|
||||
@@ -7,13 +7,10 @@ const useHardwareMonitorsFetch = ({ monitorId, dateRange }) => {
|
||||
const [networkError, setNetworkError] = useState(false);
|
||||
const [monitor, setMonitor] = useState(undefined);
|
||||
|
||||
const { authToken } = useSelector((state) => state.auth);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response = await networkService.getHardwareDetailsByMonitorId({
|
||||
authToken: authToken,
|
||||
monitorId: monitorId,
|
||||
dateRange: dateRange,
|
||||
});
|
||||
@@ -26,7 +23,7 @@ const useHardwareMonitorsFetch = ({ monitorId, dateRange }) => {
|
||||
}
|
||||
};
|
||||
fetchData();
|
||||
}, [monitorId, dateRange, authToken]);
|
||||
}, [monitorId, dateRange]);
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
|
||||
@@ -30,8 +30,6 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
const theme = useTheme();
|
||||
const authState = useSelector((state) => state.auth);
|
||||
const authToken = authState.authToken;
|
||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||
|
||||
const openMenu = (e) => {
|
||||
@@ -61,7 +59,6 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
||||
const handleRemove = async () => {
|
||||
try {
|
||||
await networkService.deleteMonitorById({
|
||||
authToken,
|
||||
monitorId: monitor.id,
|
||||
});
|
||||
createToast({ body: "Monitor deleted successfully." });
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createToast } from "../../../../Utils/toastUtils";
|
||||
|
||||
const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
||||
// Redux state
|
||||
const { authToken, user } = useSelector((state) => state.auth);
|
||||
const { user } = useSelector((state) => state.auth);
|
||||
|
||||
// Local state
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
@@ -17,7 +17,6 @@ const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
||||
const fetchMonitors = async () => {
|
||||
try {
|
||||
const response = await networkService.getMonitorsByTeamId({
|
||||
authToken,
|
||||
teamId: user.teamId,
|
||||
limit: 1,
|
||||
types: ["hardware"],
|
||||
@@ -37,7 +36,7 @@ const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
||||
};
|
||||
|
||||
fetchMonitors();
|
||||
}, [page, rowsPerPage, authToken, user.teamId, updateTrigger]);
|
||||
}, [page, rowsPerPage, user.teamId, updateTrigger]);
|
||||
|
||||
return { monitors, summary, isLoading, networkError };
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user