import { supabase } from "@/lib/supabase"; import { router } from "expo-router"; import { useState } from "react"; import { Alert, Keyboard, KeyboardAvoidingView, Platform, Pressable, ScrollView, Text, TextInput, TouchableWithoutFeedback, View } from "react-native"; export default function Login() { const [email, SetEmail] = useState(''); const [password, SetPassword] = useState(''); const [isLoading, SetIsLoading] = useState(false); const login = async () => { if(email.trim() === '' || password.trim() === '') { Alert.alert("All fields are required!"); return; } SetIsLoading(true); const { error } = await supabase.auth.signInWithPassword({ email, password }); SetIsLoading(false); if (error) { Alert.alert("Login failed, please check your credentials and try again"); return; } router.replace("/"); } const inputClassName = 'rounded-2xl border border-app-border bg-app-subtle px-4 py-3 text-base text-text-main' return ( Study Sprint Pick up where you left off. Log in Continue your study workflow. Email Password {isLoading ? 'Logging in...' : 'Log in'} router.push('/createUser')} > Don't have an account? Sign up ); }