import React, { useState } from 'react' import { Alert, Text, TextInput, TouchableOpacity, View } from 'react-native' import { supabase } from '../lib/supabase' import { appStyles } from '../styles/styles' export default function Auth() { const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [loading, setLoading] = useState(false) const styles = appStyles async function signInWithEmail() { setLoading(true) const { error } = await supabase.auth.signInWithPassword({ email: email, password: password, }) if (error) Alert.alert(error.message) setLoading(false) } async function signUpWithEmail() { setLoading(true) const { error } = await supabase.auth.signUp({ email: email, password: password, }) if (error) Alert.alert(error.message) setLoading(false) } return ( Email setEmail(text)} value={email} placeholder="email@address.com" autoCapitalize="none" style={styles.input} /> Password setPassword(text)} value={password} secureTextEntry={true} placeholder="Password" autoCapitalize="none" style={styles.input} /> signInWithEmail()} disabled={loading} > Sign in signUpWithEmail()} disabled={loading} > Sign up ) }