diff options
Diffstat (limited to 'src/store/actions')
| -rw-r--r-- | src/store/actions/user.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts index 09ec8abf..e77b8513 100644 --- a/src/store/actions/user.ts +++ b/src/store/actions/user.ts @@ -2,7 +2,7 @@ import {RootState} from '../rootReducer'; import {UserType} from '../../types/types'; import {loadProfileInfo, loadAvatar, loadCover} from '../../services'; import {Action, ThunkAction} from '@reduxjs/toolkit'; -import {userLoggedIn, userDetailsFetched} from '../reducers'; +import {userLoggedIn, userDetailsFetched, socialEdited} from '../reducers'; import {getTokenOrLogout} from '../../utils'; /** @@ -38,6 +38,28 @@ export const loadUserData = ( } }; +/** + * To update editable socials + * @param social social to be updated + * @param value username of social to be updated + */ +export const updateSocial = ( + social: string, + value: string, +): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async ( + dispatch, +) => { + try { + console.log(social); + dispatch({ + type: socialEdited.type, + payload: {social, value}, + }); + } catch (error) { + console.log(error); + } +}; + export const logout = (): ThunkAction< Promise<void>, RootState, |
