45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import ViewLogin from "@/components/auth/viewLogin";
|
|
import ViewVerification from "@/components/auth/viewVerification";
|
|
import { requestPermission } from "@/lib/useNotification";
|
|
import { useAuthSession } from "@/providers/AuthProvider";
|
|
import { Redirect } from "expo-router";
|
|
import { useEffect, useState } from "react";
|
|
import { View } from "react-native";
|
|
import Text from '@/components/Text';
|
|
|
|
export default function Index() {
|
|
const [isValid, setValid] = useState(false)
|
|
const [phone, setPhone] = useState('')
|
|
const [otp, setOtp] = useState(0)
|
|
|
|
async function registerNotification() {
|
|
const permission = await requestPermission()
|
|
}
|
|
|
|
useEffect(() => {
|
|
registerNotification()
|
|
}, [])
|
|
|
|
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)
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
} |