diff options
| author | Ivan Chen <ivan@thetaggid.com> | 2020-10-27 18:34:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-27 18:34:08 -0400 |
| commit | e004fd362583a020b07f87536aac077269eaad27 (patch) | |
| tree | a4b0f6abf71b2e169a5d1fa6873f2327f60b57c1 /src/screens/onboarding/ProfileOnboarding.tsx | |
| parent | 9b9b1b792f914709de01e1d502014b8deb66e291 (diff) | |
date picker done (#80)
Diffstat (limited to 'src/screens/onboarding/ProfileOnboarding.tsx')
| -rw-r--r-- | src/screens/onboarding/ProfileOnboarding.tsx | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/screens/onboarding/ProfileOnboarding.tsx b/src/screens/onboarding/ProfileOnboarding.tsx index e7fcec90..bbabbb56 100644 --- a/src/screens/onboarding/ProfileOnboarding.tsx +++ b/src/screens/onboarding/ProfileOnboarding.tsx @@ -1,5 +1,6 @@ import React from 'react'; import {RouteProp} from '@react-navigation/native'; +import moment from 'moment'; import {StackNavigationProp} from '@react-navigation/stack'; import { Text, @@ -16,6 +17,7 @@ import { TaggInput, TaggDatePicker, TaggDropDown, + BirthDatePicker, } from '../../components'; import {OnboardingStackParams} from '../../routes/onboarding'; import {AuthContext} from '../../routes/authentication'; @@ -26,7 +28,6 @@ import { bioRegex, genderRegex, } from '../../constants'; -import moment from 'moment'; import AsyncStorage from '@react-native-community/async-storage'; type ProfileOnboardingScreenRouteProp = RouteProp< @@ -228,18 +229,13 @@ const ProfileOnboarding: React.FC<ProfileOnboardingProps> = ({ }); }; - const handleBirthdateUpdate = (birthdate: string) => { + const handleBirthdateUpdate = (birthdate: Date) => { setForm({ ...form, - birthdate, + birthdate: moment(birthdate).format('YYYY-MM-DD'), }); }; - const getMaxDate = () => { - const maxDate = moment().subtract(13, 'y').subtract(1, 'd'); - return maxDate.format('YYYY-MM-DD'); - }; - const handleSubmit = async () => { if (!form.largePic) { Alert.alert('Please upload a large profile picture!'); @@ -396,10 +392,10 @@ const ProfileOnboarding: React.FC<ProfileOnboardingProps> = ({ } width={280} /> - <TaggDatePicker - date={form.birthdate} - maxDate={getMaxDate()} - onDateChange={(birthdate) => handleBirthdateUpdate(birthdate)} + <BirthDatePicker + ref={birthdateRef} + handleBDUpdate={handleBirthdateUpdate} + width={280} /> <TaggDropDown onValueChange={(value) => handleGenderUpdate(value)} |
