import { StyleSheet, Text, View, SafeAreaView, KeyboardAvoidingView, Image, TextInput, Pressable } from 'react-native' import React, { useEffect, useState } from 'react' import { Fontisto } from '@expo/vector-icons'; import { Entypo } from '@expo/vector-icons'; import { useRouter } from 'expo-router'; import axios from "axios"; import AsyncStorage from "@react-native-async-storage/async-storage"; const login = () => { const router = useRouter(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); useEffect(() => { const checkLoginStatus = async() => { try { const token = await AsyncStorage.getItem("authToken"); if(token){ router.replace("/(tabs)/home") } } catch (error) { console.log(error) } }; checkLoginStatus(); }, []) const handleLogin = () => { const user = { email: email, password: password, }; axios.post("http://localhost:3030/login", user).then((res) => { const token = res.data.token; AsyncStorage.setItem("authToken", token); router.replace("/(tabs)/home") }) }; return ( Keep Tracking Welcome back! setEmail(text)} style={{color: "#31363F", width:250, outlineStyle: 'none', marginVertical: 10, fontSize:email ? 14 : 14}} placeholder='Enter your email'/> setPassword(text)} secureTextEntry={true} style={{color: "#31363F", width:250, outlineStyle: 'none', marginVertical: 10, fontSize:email ? 14 : 14}} placeholder='Enter your password'/> Forgot password? Login router.replace("/register")} style={{marginTop: 10}}> Don't have an account? Register ) } export default login const styles = StyleSheet.create({})