aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/ProfileHeader.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/profile/ProfileHeader.tsx')
-rw-r--r--src/components/profile/ProfileHeader.tsx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx
index 89d41d57..90206f8d 100644
--- a/src/components/profile/ProfileHeader.tsx
+++ b/src/components/profile/ProfileHeader.tsx
@@ -1,7 +1,7 @@
import React, {useLayoutEffect, useRef, useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
-import {useSelector} from 'react-redux';
+import {useSelector, useStore} from 'react-redux';
import {PROFILE_CUTOUT_TOP_Y} from '../../constants';
import {RootState} from '../../store/rootreducer';
import {ScreenType} from '../../types';
@@ -28,11 +28,14 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
}) => {
const {
profile: {name = '', university_class = 2021, university},
- user: {username: userXName = ''},
+ user: {username: userXName = '', userId},
} = useSelector((state: RootState) =>
userXId ? state.userX[screenType][userXId] : state.user,
);
+ const state: RootState = useStore().getState();
+ const loggedInUserId = state.user.user.userId;
+
const {
user: {username = ''},
} = useSelector((state: RootState) => state.user);
@@ -78,7 +81,7 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
userXName={userXName}
setIsOpen={setDrawerVisible}
/>
- {measure && (
+ {userId === loggedInUserId && measure && (
<BadgeTutorialScreen
uniIconProps={{
university: university,
@@ -107,9 +110,15 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
<View style={styles.friendsAndUniversity}>
<FriendsCount screenType={screenType} userXId={userXId} />
- <TouchableOpacity onPress={() => setBadgeViewVisible(true)}>
+ <TouchableOpacity
+ disabled={userId === loggedInUserId ? false : true}
+ onPress={() => {
+ if (userId === loggedInUserId) {
+ setBadgeViewVisible(true);
+ }
+ }}>
<View ref={childRef}>
- {showBadgeTutorial === true ? (
+ {userId === loggedInUserId && showBadgeTutorial === true ? (
<View style={styles.emptyContainer} />
) : (
<UniversityIcon