diff --git a/src/auth/firebase-auth.tsx b/src/auth/firebase-auth.tsx index ea49c31..e394843 100644 --- a/src/auth/firebase-auth.tsx +++ b/src/auth/firebase-auth.tsx @@ -30,6 +30,20 @@ export const confirmCode = async ( } }; + +export const createOrSignInUser = (email: string, password: string, isSignUp: boolean) => { + console.log('isSignUp', isSignUp); + try { + if (isSignUp) { + auth().createUserWithEmailAndPassword(email, password) + } else { + auth().signInWithEmailAndPassword(email, password) + } + } catch (err) { + + } +} + export const onAuthStateChanged = ( // TODO: eslint not detecting ts? // eslint-disable-next-line no-unused-vars diff --git a/src/screens/login.tsx b/src/screens/login.tsx index fa37c4b..7c9d961 100644 --- a/src/screens/login.tsx +++ b/src/screens/login.tsx @@ -7,25 +7,28 @@ import { Switch, Text, TextInput, + TouchableOpacity, TouchableWithoutFeedback, View, } from "react-native"; import { confirmCode, handleSignInWithPhoneNumber } from "../auth"; +import { createOrSignInUser } from "../auth/firebase-auth"; export default function Login() { const [isEmailLogin, setIsEmailLogin] = useState(false); - const [phoneNumber, setPhoneNumber] = useState(""); - const [code, setCode] = useState(""); - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); - const [confirm, setConfirm] = - useState(null); - const toggleSwitch = () => setIsEmailLogin((previousState) => !previousState); - // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars - const handleSignInWithEmail = (email: string, password: string) => - console.log("signingInWithEmail"); + // Phone number + const [phoneNumber, setPhoneNumber] = useState(""); + const [code, setCode] = useState(""); + const [confirm, setConfirm] = + useState(null); + + // Email + const [isSignUp, setIsSignUp] = useState(false) + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const toggleSignUp = () => setIsSignUp(!isSignUp); return ( Keyboard.dismiss()}> @@ -94,11 +97,16 @@ export default function Login() { value={password} onChangeText={setPassword} /> + + + {isSignUp ? 'Already have an account? Sign In' : "Don't have an account? Sign Up"} + +