diff --git a/src/Features/Auth/authSlice.js b/src/Features/Auth/authSlice.js index 7a414516b..b7f0daef1 100644 --- a/src/Features/Auth/authSlice.js +++ b/src/Features/Auth/authSlice.js @@ -1,6 +1,5 @@ import { networkService } from "../../main"; import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; -import { jwtDecode } from "jwt-decode"; import axios from "axios"; const initialState = { @@ -45,7 +44,7 @@ export const login = createAsyncThunk("auth/login", async (form, thunkApi) => { export const update = createAsyncThunk("auth/update", async (data, thunkApi) => { const { localData: form } = data; - const user = jwtDecode(token); + const user = thunkApi.getState().auth.user; try { const fd = new FormData(); form.firstName && fd.append("firstName", form.firstName); @@ -77,8 +76,8 @@ export const update = createAsyncThunk("auth/update", async (data, thunkApi) => } }); -export const deleteUser = createAsyncThunk("auth/delete", async (data, thunkApi) => { - const user = jwtDecode(data); +export const deleteUser = createAsyncThunk("auth/delete", async (_, thunkApi) => { + const user = thunkApi.getState().auth.user; try { const res = await networkService.deleteUser({ userId: user._id, }); diff --git a/src/Features/InfrastructureMonitors/infrastructureMonitorsSlice.js b/src/Features/InfrastructureMonitors/infrastructureMonitorsSlice.js index 695e0c96c..bb783504c 100644 --- a/src/Features/InfrastructureMonitors/infrastructureMonitorsSlice.js +++ b/src/Features/InfrastructureMonitors/infrastructureMonitorsSlice.js @@ -1,5 +1,4 @@ import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; -import { jwtDecode } from "jwt-decode"; import { networkService } from "../../main"; const initialState = { isLoading: false, @@ -70,8 +69,8 @@ export const getInfrastructureMonitorById = createAsyncThunk( export const getInfrastructureMonitorsByTeamId = createAsyncThunk( "infrastructureMonitors/getMonitorsByTeamId", - async (token, thunkApi) => { - const user = jwtDecode(token); + async (_, thunkApi) => { + const user = thunkApi.getState().auth.user; try { const res = await networkService.getMonitorsAndSummaryByTeamId({ teamId: user.teamId, diff --git a/src/Features/PageSpeedMonitor/pageSpeedMonitorSlice.js b/src/Features/PageSpeedMonitor/pageSpeedMonitorSlice.js index 9d5d42831..f7a78c5fd 100644 --- a/src/Features/PageSpeedMonitor/pageSpeedMonitorSlice.js +++ b/src/Features/PageSpeedMonitor/pageSpeedMonitorSlice.js @@ -1,5 +1,4 @@ import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; -import { jwtDecode } from "jwt-decode"; import { networkService } from "../../main"; const initialState = { isLoading: false, @@ -70,8 +69,8 @@ export const getPagespeedMonitorById = createAsyncThunk( export const getPageSpeedByTeamId = createAsyncThunk( "pageSpeedMonitors/getPageSpeedByTeamId", - async (token, thunkApi) => { - const user = jwtDecode(token); + async (_, thunkApi) => { + const user = thunkApi.getState().auth.user; try { const res = await networkService.getMonitorsAndSummaryByTeamId({ teamId: user.teamId, diff --git a/src/Features/UptimeMonitors/uptimeMonitorsSlice.js b/src/Features/UptimeMonitors/uptimeMonitorsSlice.js index cb6812b67..84aac87a6 100644 --- a/src/Features/UptimeMonitors/uptimeMonitorsSlice.js +++ b/src/Features/UptimeMonitors/uptimeMonitorsSlice.js @@ -1,5 +1,4 @@ import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; -import { jwtDecode } from "jwt-decode"; import { networkService } from "../../main"; const initialState = { isLoading: false,