From 1536b6d05fdb92849d9a41fcecc0f86a31176a30 Mon Sep 17 00:00:00 2001 From: Aditya Pawar Date: Sat, 14 Oct 2023 12:12:34 -0700 Subject: [PATCH 1/7] Refactor components to be screens --- src/app/auth/_layout.tsx | 1 + .../Login.tsx => app/auth/login.tsx} | 34 ++-- src/app/auth/onboarding.tsx | 174 +++++++++++++++++- src/app/auth/signup.tsx | 72 +++++++- src/app/index.tsx | 6 +- src/app/settings.tsx | 11 +- src/components/Account.tsx | 169 ----------------- 7 files changed, 263 insertions(+), 204 deletions(-) rename src/{components/Login.tsx => app/auth/login.tsx} (73%) delete mode 100644 src/components/Account.tsx diff --git a/src/app/auth/_layout.tsx b/src/app/auth/_layout.tsx index 0578a39c..cf7d8349 100644 --- a/src/app/auth/_layout.tsx +++ b/src/app/auth/_layout.tsx @@ -5,6 +5,7 @@ function StackLayout() { + ); diff --git a/src/components/Login.tsx b/src/app/auth/login.tsx similarity index 73% rename from src/components/Login.tsx rename to src/app/auth/login.tsx index 4868fe27..aa1cb78b 100644 --- a/src/components/Login.tsx +++ b/src/app/auth/login.tsx @@ -1,7 +1,9 @@ import React, { useState } from 'react'; +import { Redirect } from 'expo-router'; import { Alert, StyleSheet, View } from 'react-native'; +import { useSession } from '../../utils/AuthContext'; import { Button, Input } from 'react-native-elements'; -import { useSession } from '../utils/AuthContext'; +import { Link } from 'expo-router'; const styles = StyleSheet.create({ container: { @@ -18,8 +20,13 @@ const styles = StyleSheet.create({ }, }); -export default function Login() { +function LoginScreen() { const sessionHandler = useSession(); + + if (sessionHandler.session) { + return ; + } + const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); @@ -32,21 +39,6 @@ export default function Login() { setLoading(false); }; - const signUpWithEmail = async () => { - setLoading(true); - const { error } = await sessionHandler.signUp(email, password); - - if (error) { - Alert.alert(error.message); - console.error(error); - } else { - Alert.alert( - 'Please follow the directions in the confirmation email to activate your account.', - ); - } - setLoading(false); - }; - return ( @@ -70,12 +62,14 @@ export default function Login() { autoCapitalize="none" /> + + Don't have an account? Sign up +