diff --git a/client/App.tsx b/client/App.tsx index 8176493..947b824 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -3,11 +3,12 @@ import { Text } from 'react-native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { NavigationContainer, NavigationProp } from '@react-navigation/native'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; +import LoginPage from './screens/Login'; import MedList from './screens/Medication'; import Home from './assets/home.svg'; import DocPickerButton from './components/DocPickerButton'; -export type ScreenNames = ['BottomNav', 'Landing', 'TEMP-FileUpload']; +export type ScreenNames = ['BottomNav', 'Landing', 'TEMP-FileUpload', 'Login']; export type RootStackParamList = Record; export type StackNavigation = NavigationProp; @@ -19,6 +20,11 @@ export default function App() { return ( + { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + + const navigation = useNavigation(); + const route = useRoute(); + + const handleLogin = async () => { + if (!email || !password) { + Alert.alert('Error', 'Email and password are required'); + return; + } + const result = await logIn(email, password); + if (typeof result === 'string') { + Alert.alert('Login Failed', result.substring(5).replaceAll('-', ' ')); + } else { + Alert.alert('Login Success', 'Welcome back!'); + // console.log('result: ', result); + navigation.navigate('BottomNav'); + } + }; + + const handleSignUp = async () => { + if (!email || !password) { + Alert.alert('Error', 'Email and password are required'); + return; + } + const result = await signUp(email, password); + if (typeof result === 'string') { + Alert.alert('Signup Failed', result.substring(5).replaceAll('-', ' ')); + } else { + Alert.alert('Signup Success', 'Welcome to the app!'); + // console.log('result: ', result); + navigation.navigate('BottomNav'); + } + }; + + return ( + + + +