aboutsummaryrefslogtreecommitdiff
path: root/src/store/actions
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-06-09 15:40:08 -0400
committerIvan Chen <ivan@tagg.id>2021-06-09 15:40:08 -0400
commitcd6e9ba609cfdbcad1365c8589e2c98d755752ad (patch)
tree98b1e947f4ae4e306f8289e26354fb783c5ee5b5 /src/store/actions
parent9d7e900a89f343f7752457956f8e1d205774b910 (diff)
parent946b1be53189487e860f37e1b422c69bb44cf0c8 (diff)
Merge branch 'master' into tma872-purple-indicator
# Conflicts: # src/constants/constants.ts # src/utils/common.ts
Diffstat (limited to 'src/store/actions')
-rw-r--r--src/store/actions/user.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts
index 941101df..b1cb8719 100644
--- a/src/store/actions/user.ts
+++ b/src/store/actions/user.ts
@@ -4,12 +4,14 @@ import {Action, ThunkAction} from '@reduxjs/toolkit';
import {
getProfilePic,
loadProfileInfo,
+ removeBadgesService,
sendSuggestedPeopleLinked,
} from '../../services';
import {UniversityBadge, UserType} from '../../types/types';
import {getTokenOrLogout} from '../../utils';
import {
clearHeaderAndProfileImages,
+ profileBadgeRemoved,
profileBadgesUpdated,
profileCompletionStageUpdated,
setIsOnboardedUser,
@@ -107,6 +109,27 @@ export const updateUserBadges =
}
};
+/**
+ * Removes a single badge from logged-in user by badge name.
+ * @param badgeName name of badge to be removed
+ * @param loggedInUserId userId of loggedInUser
+ */
+export const removeUserBadge =
+ (
+ badgeName: string,
+ loggedInUserId: string,
+ ): ThunkAction<Promise<void>, RootState, unknown, Action<string>> =>
+ async (dispatch) => {
+ try {
+ const success = await removeBadgesService([badgeName], loggedInUserId);
+ if (success) {
+ dispatch({type: profileBadgeRemoved.type, payload: {badge: badgeName}});
+ }
+ } catch (error) {
+ console.log(error);
+ }
+ };
+
export const updateProfileCompletionStage =
(
stage: number,