diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:02:31 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:02:31 -0400 |
| commit | 04bf806285e7626644234b7febee2dad5c912f8d (patch) | |
| tree | 9ed3ec581792d6a0e1135f02a1d4716890ca75fc /src/components/profile | |
| parent | e8324a7278a82d926acceedc10921f0b14e6d403 (diff) | |
| parent | 4de1ebd43437712e28a89bb624c5b12afad45cc6 (diff) | |
Merge branch 'master' into tma-701-private-account-banner
# Conflicts:
# src/constants/strings.ts
Diffstat (limited to 'src/components/profile')
| -rw-r--r-- | src/components/profile/ProfileHeader.tsx | 7 | ||||
| -rw-r--r-- | src/components/profile/ProfileMoreInfoDrawer.tsx | 8 | ||||
| -rw-r--r-- | src/components/profile/UniversityIcon.tsx | 20 |
3 files changed, 12 insertions, 23 deletions
diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx index b5dda399..2c623c2b 100644 --- a/src/components/profile/ProfileHeader.tsx +++ b/src/components/profile/ProfileHeader.tsx @@ -24,7 +24,7 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({ handleBlockUnblock, }) => { const { - profile: {name = '', university_class = 2021} = {}, + profile: {name = '', university_class = 2021, university}, user: {username: userXName = ''}, } = useSelector((state: RootState) => userXId ? state.userX[screenType][userXId] : state.user, @@ -59,10 +59,7 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({ )} <View style={styles.friendsAndUniversity}> <FriendsCount screenType={screenType} userXId={userXId} /> - <UniversityIcon - university="brown" - university_class={university_class} - /> + <UniversityIcon {...{university, university_class}} /> </View> </View> </View> diff --git a/src/components/profile/ProfileMoreInfoDrawer.tsx b/src/components/profile/ProfileMoreInfoDrawer.tsx index 2fec5cca..a77a2e84 100644 --- a/src/components/profile/ProfileMoreInfoDrawer.tsx +++ b/src/components/profile/ProfileMoreInfoDrawer.tsx @@ -24,11 +24,9 @@ const ProfileMoreInfoDrawer: React.FC<ProfileMoreInfoDrawerProps> = (props) => { const {setIsOpen, userXId, isBlocked, handleBlockUnblock, userXName} = props; const { user: {userId, username}, - } = useSelector((state: RootState) => state.user); + profile, + } = useSelector((state: RootState) => state?.user); const isOwnProfile = !userXId || userXName === username; - const {suggested_people_linked} = useSelector( - (state: RootState) => state.user.profile, - ); const goToEditProfile = () => { navigation.push('EditProfile', { @@ -39,7 +37,7 @@ const ProfileMoreInfoDrawer: React.FC<ProfileMoreInfoDrawerProps> = (props) => { }; const goToUpdateSPProfile = () => { - if (suggested_people_linked === 0) { + if (profile.suggested_people_linked === 0) { Alert.alert(ERROR_ATTEMPT_EDIT_SP); } else { // Sending undefined for updatedSelectedBadges to mark that there was no update yet diff --git a/src/components/profile/UniversityIcon.tsx b/src/components/profile/UniversityIcon.tsx index 48cfe3dc..4cb1abe6 100644 --- a/src/components/profile/UniversityIcon.tsx +++ b/src/components/profile/UniversityIcon.tsx @@ -1,10 +1,11 @@ import React from 'react'; import {ImageStyle, StyleProp, StyleSheet, ViewProps} from 'react-native'; import {Image, Text, View} from 'react-native-animatable'; -import {getUniversityClass, normalize} from '../../utils'; +import {getUniversityBadge, getUniversityClass, normalize} from '../../utils'; +import {UniversityType} from '../../types'; export interface UniversityIconProps extends ViewProps { - university: string; + university: UniversityType; university_class?: number; imageStyle?: StyleProp<ImageStyle>; } @@ -18,19 +19,12 @@ const UniversityIcon: React.FC<UniversityIconProps> = ({ university_class, imageStyle, }) => { - var universityIcon; - switch (university) { - case 'brown': - universityIcon = require('../../assets/universities/brown.png'); - break; - default: - universityIcon = require('../../assets/universities/brown.png'); - break; - } - return ( <View style={[styles.container, style]}> - <Image source={universityIcon} style={[styles.icon, imageStyle]} /> + <Image + source={getUniversityBadge(university, 'Crest')} + style={[styles.icon, imageStyle]} + /> {university_class && ( <Text style={styles.univClass}> {getUniversityClass(university_class)} |
