From 5f2159489e75a05dbe6bede792cb8a97971b824a Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 22 Jan 2021 16:31:35 -0500 Subject: finished styling the input box --- src/screens/profile/MomentCommentsScreen.tsx | 46 +++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/screens/profile') diff --git a/src/screens/profile/MomentCommentsScreen.tsx b/src/screens/profile/MomentCommentsScreen.tsx index b2611b62..6434477e 100644 --- a/src/screens/profile/MomentCommentsScreen.tsx +++ b/src/screens/profile/MomentCommentsScreen.tsx @@ -1,19 +1,21 @@ -import * as React from 'react'; import {RouteProp, useNavigation} from '@react-navigation/native'; -import {ProfileStackParams} from '../../routes/main'; +import React, {useEffect, useRef} from 'react'; +import { + ScrollView, + StyleSheet, + Text, + TouchableOpacity, + View, +} from 'react-native'; +import {SafeAreaView} from 'react-native-safe-area-context'; +import {useDispatch} from 'react-redux'; +import {getMomentComments} from '../..//services'; +import BackIcon from '../../assets/icons/back-arrow.svg'; import {CommentTile, TabsGradient} from '../../components'; +import {AddComment} from '../../components/'; +import {ProfileStackParams} from '../../routes/main'; import {CommentType} from '../../types'; -import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'; import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils/screenDimensions'; -import {AddComment} from '../../components/'; -import {useEffect} from 'react'; -import AsyncStorage from '@react-native-community/async-storage'; -import {getMomentComments} from '../..//services'; -import {useDispatch} from 'react-redux'; -import {logout} from '../../store/actions'; -import {SafeAreaView} from 'react-native-safe-area-context'; -import Animated from 'react-native-reanimated'; -import BackIcon from '../../assets/icons/back-arrow.svg'; /** * Comments Screen for an image uploaded @@ -36,19 +38,20 @@ const MomentCommentsScreen: React.FC = ({route}) => { const [commentsList, setCommentsList] = React.useState([]); const [newCommentsAvailable, setNewCommentsAvailable] = React.useState(true); const dispatch = useDispatch(); + const ref = useRef(null); useEffect(() => { const loadComments = async () => { - const token = await AsyncStorage.getItem('token'); - if (!token) { - dispatch(logout()); - return; - } - getMomentComments(moment_id, setCommentsList, token); + getMomentComments(moment_id, setCommentsList); setNewCommentsAvailable(false); }; if (newCommentsAvailable) { loadComments(); + setTimeout(() => { + ref.current?.scrollToEnd({ + animated: true, + }); + }, 500); } }, [dispatch, moment_id, newCommentsAvailable]); @@ -68,7 +71,8 @@ const MomentCommentsScreen: React.FC = ({route}) => { - {commentsList && @@ -79,7 +83,7 @@ const MomentCommentsScreen: React.FC = ({route}) => { screenType={screenType} /> ))} - + 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/screens/profile') 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/screens/profile') 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/screens/profile') 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/screens/profile') 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