36 lines
926 B
TypeScript
36 lines
926 B
TypeScript
import ViewLogin from "@/components/auth/viewLogin";
|
|
import ViewVerification from "@/components/auth/viewVerification";
|
|
import { useAuthSession } from "@/providers/AuthProvider";
|
|
import { Redirect } from "expo-router";
|
|
import { useState } from "react";
|
|
import { Text } from "react-native";
|
|
|
|
|
|
export default function Index() {
|
|
const [isValid, setValid] = useState(false)
|
|
const [phone, setPhone] = useState('')
|
|
const [otp, setOtp] = useState(0)
|
|
|
|
const { token, isLoading } = useAuthSession()
|
|
if (isLoading) {
|
|
return <Text>Loading...</Text>;
|
|
}
|
|
|
|
if (token?.current) {
|
|
return <Redirect href="/home" />;
|
|
}
|
|
|
|
if (isValid) { return <ViewVerification phone={phone} otp={otp} /> }
|
|
|
|
return (
|
|
<>
|
|
<ViewLogin
|
|
onValidate={(val) => {
|
|
setPhone(val.phone)
|
|
setOtp(val.otp)
|
|
setValid(true)
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
} |