aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-26 22:40:00 -0400
committerIvan Chen <ivan@tagg.id>2021-03-26 22:40:00 -0400
commit64785e6527e521ce14e32edcc80adc6253b48657 (patch)
treedf42bdbe6810b589ec52c98fcd622cc7e2864879 /src/components/profile
parented26661062a2e47df2662254eaddfcfa1de62d04 (diff)
renamed to UniversityType, applied to all
Diffstat (limited to 'src/components/profile')
-rw-r--r--src/components/profile/ProfileHeader.tsx16
-rw-r--r--src/components/profile/UniversityIcon.tsx25
2 files changed, 15 insertions, 26 deletions
diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx
index 0b93de98..2c623c2b 100644
--- a/src/components/profile/ProfileHeader.tsx
+++ b/src/components/profile/ProfileHeader.tsx
@@ -1,14 +1,14 @@
import React, {useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {useSelector} from 'react-redux';
-import UniversityIcon from './UniversityIcon';
import {PROFILE_CUTOUT_TOP_Y} from '../../constants';
import {RootState} from '../../store/rootreducer';
-import {ScreenType, Universities} from '../../types';
+import {ScreenType} from '../../types';
import {normalize} from '../../utils';
import Avatar from './Avatar';
import FriendsCount from './FriendsCount';
import ProfileMoreInfoDrawer from './ProfileMoreInfoDrawer';
+import UniversityIcon from './UniversityIcon';
type ProfileHeaderProps = {
userXId: string | undefined;
@@ -24,11 +24,11 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
handleBlockUnblock,
}) => {
const {
- profile: {name = '', university_class = 2021, university = Universities.cornell} = {},
+ profile: {name = '', university_class = 2021, university},
user: {username: userXName = ''},
- } = userXId
- ? useSelector((state: RootState) => state.userX[screenType][userXId])
- : useSelector((state: RootState) => state.user);
+ } = useSelector((state: RootState) =>
+ userXId ? state.userX[screenType][userXId] : state.user,
+ );
const [drawerVisible, setDrawerVisible] = useState(false);
const [firstName, lastName] = [...name.split(' ')];
return (
@@ -59,9 +59,7 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
)}
<View style={styles.friendsAndUniversity}>
<FriendsCount screenType={screenType} userXId={userXId} />
- <UniversityIcon
- {...{university, university_class}}
- />
+ <UniversityIcon {...{university, university_class}} />
</View>
</View>
</View>
diff --git a/src/components/profile/UniversityIcon.tsx b/src/components/profile/UniversityIcon.tsx
index 1642b8f0..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 {Universities} from '../../types';
+import {getUniversityBadge, getUniversityClass, normalize} from '../../utils';
+import {UniversityType} from '../../types';
+
export interface UniversityIconProps extends ViewProps {
- university: Universities;
+ university: UniversityType;
university_class?: number;
imageStyle?: StyleProp<ImageStyle>;
}
@@ -18,22 +19,12 @@ const UniversityIcon: React.FC<UniversityIconProps> = ({
university_class,
imageStyle,
}) => {
- var universityIcon;
- switch (university) {
- case 'Cornell':
- universityIcon = require('../../assets/universities/cornell.png');
- break;
- 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)}