diff options
| author | Shravya Ramesh <shravs1208@gmail.com> | 2021-02-11 07:03:02 -0800 |
|---|---|---|
| committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-02-11 07:03:02 -0800 |
| commit | e95ff2d483903b4d390c8dd0edf4ab60561b8334 (patch) | |
| tree | 2a315d8aa817785bc47ad2ef50ee32130f2d0ccb /src/store/actions | |
| parent | 88433cda2938a2fa4f6bf3e4b2282fe0095dfe71 (diff) | |
Create thunk action + reducer to set new variable
Diffstat (limited to 'src/store/actions')
| -rw-r--r-- | src/store/actions/user.ts | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts index 5f49a103..98e1727b 100644 --- a/src/store/actions/user.ts +++ b/src/store/actions/user.ts @@ -1,7 +1,12 @@ -import { CommentThreadType } from './../../types/types'; +import {CommentThreadType} from './../../types/types'; import {RootState} from '../rootReducer'; import {UserType} from '../../types/types'; -import {loadProfileInfo, loadAvatar, loadCover} from '../../services'; +import { + loadProfileInfo, + loadAvatar, + loadCover, + editSPSwipeTutorial, +} from '../../services'; import {Action, ThunkAction} from '@reduxjs/toolkit'; import { userLoggedIn, @@ -13,6 +18,7 @@ import { setReplyPosted, } from '../reducers'; import {getTokenOrLogout} from '../../utils'; +import {spSwipeTutorialUpdated} from '../reducers/userReducer'; /** * Entry point to our store. @@ -140,3 +146,26 @@ export const logout = (): ThunkAction< console.log(error); } }; + +export const updateSPSwipeTutorial = ( + user: UserType, + data: number, +): ThunkAction< + Promise<boolean | undefined>, + RootState, + unknown, + Action<string> +> => async (dispatch) => { + try { + const success = await editSPSwipeTutorial(user); + if (success) { + dispatch({ + type: spSwipeTutorialUpdated.type, + payload: {sp_swipe_tutorial: data}, + }); + } + return success; + } catch (error) { + console.log('Error while updating suggested people linked state: ', error); + } +}; |
