Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/GenerateNU/legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Dec 9, 2023
2 parents b5ecd73 + dab3c07 commit cef8a2e
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 1 deletion.
209 changes: 209 additions & 0 deletions client-new/src/screens/auth/MoreInfoSignupScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import Footer from '@/components/reusable/Footer';
import ScreenWideButton from '@/components/reusable/HalfScreenWideButton';
import LegacyWordmark from '@/components/reusable/LegacyWordmark';
import LetsGo from '@/components/reusable/LetsGo';
import ScreenWideInput from '@/components/reusable/ScreenWideInput';
import SmallRoundedButton from '@/components/reusable/SmallRoundedButton';
import { useUser } from '@/contexts/UserContext';
import { View } from 'native-base';

import { useEffect, useState } from 'react';
import React from 'react';
import { Alert, StyleSheet } from 'react-native';
import {
heightPercentageToDP as h,
widthPercentageToDP as w
} from 'react-native-responsive-screen';
import { z } from 'zod';

type SignupData = {
firstName: string;
lastName: string;
phone: string;
date: Date;
};

// TODO: signup is still not fully reistant
export default function SignUpScreen({ route, navigation }) {
const { createAccount } = useUser();

const [signupData, setSignupData] = useState<SignupData>({
firstName: '',
lastName: '',
phone: '',
date: new Date()
});

const signUp = () => {
const signup = async () => {
const { firstName, lastName, phone, date } = signupData;

if (!firstName || !lastName || !phone || !date) {
Alert.alert('Error', 'Please fill in all required fields');
return;
}


// TODO: Date doesnt actually get passed through
const response = await createAccount(firstName, lastName, phone)
if (response instanceof Error) {
Alert.alert('Error', response.message)
setSignupData({
firstName: '',
lastName: '',
phone: '',
date: new Date()
});
return;
}
navigation.setOptions();
navigation.navigate('Onboarding Stack');
}

signup();
};

// for debugging
useEffect(() => {
console.log('firstName: ', signupData.firstName)
console.log('lastName: ', signupData.lastName)
console.log('password: ', signupData.phone)
console.log('date: ', signupData.date)
}, [signupData]);

const switchToLogin = () => {
navigation.navigate('Login Screen');
};

return (
<>
<View bg={'creamyCanvas'} alignItems="center" h={h('100%')} w={w('100%')}>
<View
alignItems="center"
width={w('80%')}
flexDirection="row"
justifyContent="space-between"
justifyItems={'center'}
paddingTop={h('8%')}
>
<LegacyWordmark />
<SmallRoundedButton title="Login" onClick={switchToLogin} />
</View>
<View paddingTop={h('7%')}>
<LetsGo />
</View>
<View alignItems={'center'} paddingTop={h('6.5%')}>
<ScreenWideInput
placeholderText="Example"
title="First Name"
iconName="user-o"
onChangeText={(value) => setSignupData({ ...signupData, firstName: value })}
value={signupData.firstName}
/>
<View paddingTop={h('3%')}>
<ScreenWideInput
placeholderText="Example"
title="Last Name"
iconName="user-o"
onChangeText={(value) => setSignupData({ ...signupData, lastName: value })}
value={signupData.lastName}
/>
</View>
<View paddingTop={h('3%')} paddingBottom={h('4%')}>
<ScreenWideInput
placeholderText="In the format of 1234567890"
title="Phone"
iconName="lock"
password={true}
onChangeText={(value) => setSignupData({ ...signupData, phone: value })}
value={signupData.phone}
/>
</View>
{/* TODO: move this to a valid section for user data collection*/}
<View paddingTop={h('3%')} paddingBottom={h('3%')}>
<ScreenWideInput
title="Date of Birth"
onChangeText={(value) => setSignupData({ ...signupData, date: value })}
placeholderText="Select your date of birth"
iconName="calendar"
disabled={false}
password={false}
isDatePicker={true}
/>
</View>
<View
width={w('80%')}
alignItems={'center'}
flexDirection={'row'}
justifyContent={'space-between'}
>
<ScreenWideButton
text="Sign up with SSO"
textColor={'#000000'}
backgroundColor={'transparent'}
borderColor={'lightGreen'}
onClick={() => Alert.alert('Not implemented yet')}
/>
<ScreenWideButton
text="Sign up to Legacy"
textColor={'#FFFFFF'}
backgroundColor={'lightGreen'}
borderColor={'lightGreen'}
onClick={signUp}
/>
</View>
<View paddingTop={h('20%')}>
<Footer />
</View>
</View>
</View>
</>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
inputContainer: {
width: '80%'
},
input: {
backgroundColor: 'white',
paddingHorizontal: 15,
paddingVertical: 10,
borderRadius: 10,
marginTop: 5
},
buttonContainer: {
width: '60%',
justifyContent: 'center',
alignItems: 'center',
marginTop: 40
},
button: {
backgroundColor: '#0782F9',
width: '100%',
padding: 15,
borderRadius: 10,
alignItems: 'center'
},
buttonOutline: {
backgroundColor: 'white',
marginTop: 5,
borderColor: '#0782F9',
borderWidth: 2
},
buttonText: {
color: 'white',
fontWeight: '700',
fontSize: 16
},
buttonOutlineText: {
color: '#0782F9',
fontWeight: '700',
fontSize: 16
}
});
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"expo-document-picker": "^11.7.0",
"react-native-file-viewer": "^2.1.5"
}
}
3 changes: 2 additions & 1 deletion server/src/migrations/data.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Active: 1702078735201@@127.0.0.1@5432@legacy
-- Creating test personas
INSERT INTO personas (persona_title, persona_description) VALUES
('Procrastinating Rookie', 'Enjoys a challenge, scarcity mindset, the ultimate planner, a perfectionist, selfish, always on the edge, half-empty glass thinker, externally motivated, all-at-once worker, quick-start guide enthusiast, uncomfortable discussing death, less nurturing, inexperienced with EOLP, racing against time, tight finances, dipping toes in the water.'),
Expand Down Expand Up @@ -329,7 +330,7 @@ INSERT INTO sub_tasks (task_id, sub_task_name, sub_task_description, actions) VA
'{
"actions": [
{
"action_type": "input"
"action_type": "input",
"label": "Legacy Statement",
"placeholder": "Title",
"name": "legacy_statement_title",
Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


expo-document-picker@^11.7.0:
version "11.7.0"
resolved "https://registry.yarnpkg.com/expo-document-picker/-/expo-document-picker-11.7.0.tgz#05a4f8681262692bca20264fa66f84433292d8f4"
integrity sha512-y5OgUuJlip/Vj3CXi6Rfx6PqMkoYwytKmgN6x8afRPehVcYVk3j/EZxvz1MLgUhCmjyFnIpfgG5WTf8uSNbIiA==

react-native-file-viewer@^2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/react-native-file-viewer/-/react-native-file-viewer-2.1.5.tgz#cd4544f573108e79002b5c7e1ebfce4371885250"
integrity sha512-MGC6sx9jsqHdefhVQ6o0akdsPGpkXgiIbpygb2Sg4g4bh7v6K1cardLV1NwGB9A6u1yICOSDT/MOC//9Ez6EUg==

0 comments on commit cef8a2e

Please sign in to comment.