remove authToken reading and passing in UI component and hooks

This commit is contained in:
dongfang committed 2025-02-18 04:56:26 +00:00
1 parent 6a1e5532e4
commit f2ae99768a
41 files changed
+76 -135

No files matched your search

+2 -4
View File
@@ -25,8 +25,6 @@ const ActionsMenu = ({
const [isOpen, setIsOpen] = useState(false);
const dispatch = useDispatch();
const theme = useTheme();
const authState = useSelector((state) => state.auth);
const authToken = authState.authToken;
const { isLoading } = useSelector((state) => state.uptimeMonitors);
const handleRemove = async (event) => {
@@ -34,7 +32,7 @@ const ActionsMenu = ({
event.stopPropagation();
let monitor = { _id: actions.id };
const action = await dispatch(
deleteUptimeMonitor({ authToken: authState.authToken, monitor })
deleteUptimeMonitor({ monitor })
);
if (action.meta.requestStatus === "fulfilled") {
setIsOpen(false); // close modal
@@ -49,7 +47,7 @@ const ActionsMenu = ({
try {
setIsLoading(true);
const action = await dispatch(
pauseUptimeMonitor({ authToken, monitorId: monitor._id })
pauseUptimeMonitor({ monitorId: monitor._id })
);
if (pauseUptimeMonitor.fulfilled.match(action)) {
const state = action?.payload?.data.isActive === false ? "paused" : "resumed";
@@ -30,7 +30,7 @@ const PasswordPanel = () => {
const SPACING_GAP = theme.spacing(12);
//redux state
const { authToken, isLoading } = useSelector((state) => state.auth);
const { isLoading } = useSelector((state) => state.auth);
const idToName = {
"edit-current-password": "password",
@@ -89,7 +89,7 @@ const PasswordPanel = () => {
});
setErrors(newErrors);
} else {
const action = await dispatch(update({ authToken, localData }));
const action = await dispatch(update({ localData }));
if (action.payload.success) {
createToast({
body: "Your password was changed successfully.",
@@ -32,7 +32,7 @@ const ProfilePanel = () => {
const SPACING_GAP = theme.spacing(12);
//redux state
const { user, authToken, isLoading } = useSelector((state) => state.auth);
const { user, isLoading } = useSelector((state) => state.auth);
const idToName = {
"edit-first-name": "firstName",
@@ -164,7 +164,7 @@ const ProfilePanel = () => {
return;
}
const action = await dispatch(update({ authToken, localData }));
const action = await dispatch(update({ localData }));
if (action.payload.success) {
createToast({
body: "Your profile data was changed successfully.",
@@ -187,7 +187,7 @@ const ProfilePanel = () => {
// Initiates the account deletion process
const handleDeleteAccount = async () => {
const action = await dispatch(deleteUser(authToken));
const action = await dispatch(deleteUser());
if (action.payload.success) {
dispatch(clearAuthState());
dispatch(clearUptimeMonitorState());
@@ -23,7 +23,6 @@ const TeamPanel = () => {
const SPACING_GAP = theme.spacing(12);
const { authToken } = useSelector((state) => state.auth);
const [toInvite, setToInvite] = useState({
email: "",
role: ["0"],
@@ -63,9 +62,7 @@ const TeamPanel = () => {
useEffect(() => {
const fetchTeam = async () => {
try {
const response = await networkService.getAllUsers({
authToken: authToken,
});
const response = await networkService.getAllUsers();
setMembers(response.data.data);
} catch (error) {
createToast({
@@ -75,7 +72,7 @@ const TeamPanel = () => {
};
fetchTeam();
}, [authToken]);
}, []);
useEffect(() => {
const ROLE_MAP = {
@@ -150,7 +147,6 @@ const TeamPanel = () => {
try {
await networkService.requestInvitationToken({
authToken: authToken,
email: toInvite.email,
role: toInvite.role,
});