From c43281c29c8454c0e7f43e5a19434a2d9f01ea8b Mon Sep 17 00:00:00 2001
From: Shravya Ramesh <shravs1208@gmail.com>
Date: Fri, 23 Apr 2021 16:07:17 -0700
Subject: incorrect data issue fixed

---
 src/components/common/BadgeDetailView.tsx | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

(limited to 'src/components/common/BadgeDetailView.tsx')

diff --git a/src/components/common/BadgeDetailView.tsx b/src/components/common/BadgeDetailView.tsx
index 13613287..9dd64bfa 100644
--- a/src/components/common/BadgeDetailView.tsx
+++ b/src/components/common/BadgeDetailView.tsx
@@ -17,23 +17,27 @@ import {BADGE_GRADIENT_FIRST} from '../../constants';
 import {BADGE_DATA} from '../../constants/badges';
 import {getSuggestedPeopleProfile, removeBadgesService} from '../../services';
 import {RootState} from '../../store/rootreducer';
-import {UniversityBadge, UniversityType} from '../../types';
+import {ScreenType, UniversityBadge, UniversityType} from '../../types';
 import {getUniversityBadge, normalize} from '../../utils';
 
 interface BadgeDetailModalProps {
+  userXId: string | undefined;
+  screenType: ScreenType;
   isEditable: boolean;
   setBadgeViewVisible: Function;
   userFullName?: string;
 }
 
 const BadgeDetailView: React.FC<BadgeDetailModalProps> = ({
+  userXId,
+  screenType,
   userFullName,
   isEditable = true,
   setBadgeViewVisible,
 }) => {
-  const {
-    user: {userId = ''},
-  } = useSelector((state: RootState) => state.user);
+  const {user} = useSelector((state: RootState) =>
+    userXId ? state.userX[screenType][userXId] : state.user,
+  );
   const navigation = useNavigation();
   const [selectedBadges, setSelectedBadges] = useState<UniversityBadge[]>([]);
   const [isLoading, setIsLoading] = useState(true);
@@ -42,8 +46,8 @@ const BadgeDetailView: React.FC<BadgeDetailModalProps> = ({
   );
 
   const fetchBadges = async () => {
-    if (userId) {
-      const response = await getSuggestedPeopleProfile(userId);
+    if (user.userId) {
+      const response = await getSuggestedPeopleProfile(user.userId);
       if (response) {
         const data = response.badges;
         let extractedBadgeNames: UniversityBadge[] = [];
@@ -83,7 +87,7 @@ const BadgeDetailView: React.FC<BadgeDetailModalProps> = ({
 
   const removeBadgeCell = async (badge: string) => {
     setIsLoading(true);
-    await removeBadgesService([badge], userId);
+    await removeBadgesService([badge], user.userId);
     fetchBadges();
   };
 
-- 
cgit v1.2.3-70-g09d2

