From 3ea488de07376f2a3339d92a9b316acd38446883 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Fri, 22 Jan 2021 15:20:55 -0800 Subject: Done --- src/screens/profile/EditProfile.tsx | 41 +++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 3b3fa36e..3bf5c23c 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -29,9 +29,10 @@ import { websiteRegex, bioRegex, genderRegex, + CLASS_YEAR_LIST, } from '../../constants'; import AsyncStorage from '@react-native-community/async-storage'; -import {ProfileStackParams} from '../../routes'; +import {MainStackParams} from '../../routes'; import Animated from 'react-native-reanimated'; import {HeaderHeight, SCREEN_HEIGHT} from '../../utils'; import {RootState} from '../../store/rootReducer'; @@ -47,12 +48,12 @@ import { import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; type EditProfileNavigationProp = StackNavigationProp< - ProfileStackParams, + MainStackParams, 'EditProfile' >; interface EditProfileProps { - route: RouteProp; + route: RouteProp; navigation: EditProfileNavigationProp; } @@ -65,7 +66,7 @@ const EditProfile: React.FC = ({route, navigation}) => { const y: Animated.Value = Animated.useValue(0); const {userId, username} = route.params; const { - profile: {website, biography, gender, snapchat, tiktok}, + profile: {website, biography, gender, snapchat, tiktok, university_class}, avatar, cover, } = useSelector((state: RootState) => state.user); @@ -99,6 +100,13 @@ const EditProfile: React.FC = ({route, navigation}) => { isValidSnapchat: true, isValidTiktok: true, attemptedSubmit: false, + classYear: university_class, + }); + + var classYearList: Array = []; + + CLASS_YEAR_LIST.map((value) => { + classYearList.push({label: value, value: value}); }); /** @@ -254,6 +262,14 @@ const EditProfile: React.FC = ({route, navigation}) => { }); }; + const handleClassYearUpdate = (value: string) => { + const classYear = Number.parseInt(value); + setForm({ + ...form, + classYear, + }); + }; + const handleSubmit = useCallback(async () => { if (!form.largePic) { Alert.alert(ERROR_UPLOAD_LARGE_PROFILE_PIC); @@ -335,6 +351,10 @@ const EditProfile: React.FC = ({route, navigation}) => { invalidFields = true; } + if (form.classYear !== university_class) { + request.append('university_class', form.classYear); + } + if (invalidFields) { return; } @@ -487,6 +507,19 @@ const EditProfile: React.FC = ({route, navigation}) => { value={form.customGenderText} /> )} + + + handleClassYearUpdate(value) + } + items={classYearList} + placeholder={{ + label: 'Class Year', + value: null, + color: '#ddd', + }} + /> {snapchat !== '' && ( -- cgit v1.2.3-70-g09d2 From 5b6e94378dce751da5be2afa5ab6b2847eb43992 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Fri, 22 Jan 2021 15:37:34 -0800 Subject: Done --- src/screens/profile/EditProfile.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 3bf5c23c..c5cf4a59 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -264,6 +264,7 @@ const EditProfile: React.FC = ({route, navigation}) => { const handleClassYearUpdate = (value: string) => { const classYear = Number.parseInt(value); + console.log(classYear); setForm({ ...form, classYear, @@ -352,7 +353,13 @@ const EditProfile: React.FC = ({route, navigation}) => { } if (form.classYear !== university_class) { - request.append('university_class', form.classYear); + console.log(form.classYear); + if (!form.classYear) { + invalidFields = true; + Alert.alert('Please select a valid class year'); + } else { + request.append('university_class', form.classYear); + } } if (invalidFields) { -- cgit v1.2.3-70-g09d2 From d016131c2d1fd66bf7a91be78901b17dc7634174 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Fri, 22 Jan 2021 15:39:29 -0800 Subject: fix --- src/screens/profile/EditProfile.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index c5cf4a59..809312a9 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -264,7 +264,6 @@ const EditProfile: React.FC = ({route, navigation}) => { const handleClassYearUpdate = (value: string) => { const classYear = Number.parseInt(value); - console.log(classYear); setForm({ ...form, classYear, -- cgit v1.2.3-70-g09d2 From 14f99e8bdd5d911355122615b08bbbcbd2562df9 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Fri, 22 Jan 2021 15:39:52 -0800 Subject: fix --- src/screens/profile/EditProfile.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 809312a9..36de2bfa 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -352,7 +352,6 @@ const EditProfile: React.FC = ({route, navigation}) => { } if (form.classYear !== university_class) { - console.log(form.classYear); if (!form.classYear) { invalidFields = true; Alert.alert('Please select a valid class year'); -- cgit v1.2.3-70-g09d2