diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index 09eb629..157b728 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -148,26 +148,28 @@ export const Table = >({ ); }) ) : ( - -
-
- - - - + + +
+
+ + + + +
+

Loading users

-

Loading users

-
- + + )} diff --git a/src/services/users/redux/actions.ts b/src/services/users/redux/actions.ts index 67be7ee..79b409b 100644 --- a/src/services/users/redux/actions.ts +++ b/src/services/users/redux/actions.ts @@ -1,5 +1,6 @@ import { Dispatch } from 'redux'; import { showToast, ToastType } from 'src/common/util/show-toast'; +import { State } from 'src/redux/types'; import { performApiCall } from 'src/services/api'; import { AuthActionTypes } from 'src/services/auth'; import { transformRequestUser, transformUser } from '../transformations'; @@ -68,9 +69,11 @@ export const fetchUserById = (id: string) => async (dispatch: Dispatch) => dispatch(setUserModalLoading(false)); }; -export const updateUserById = (user: any) => async (dispatch: Dispatch) => { +export const updateUserById = (user: any) => async (dispatch: Dispatch, getState: any) => { dispatch(setUserModalLoading(true)); + const state: State = getState(); + try { const { data } = await performApiCall({ path: `/users/${user.id}`, @@ -83,10 +86,12 @@ export const updateUserById = (user: any) => async (dispatch: Dispatch) => payload: transformUser(data), }); - dispatch({ - type: AuthActionTypes.UPDATE_AUTH_USER, - payload: transformUser(data), - }); + if (state.auth.userInfo.id === user.id) { + dispatch({ + type: AuthActionTypes.UPDATE_AUTH_USER, + payload: transformUser(data), + }); + } showToast('User updated successfully.', ToastType.Success);