aboutsummaryrefslogtreecommitdiff
path: root/src/store/actions
diff options
context:
space:
mode:
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,