import React, { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, Image } from 'react-native'; import { useNavigation, NavigationProp, Link } from '@react-navigation/native'; import { RootStackParamList } from '@/types'; import AsyncStorage from '@react-native-async-storage/async-storage'; import { DB } from '@/components/lib/db'; import { GestureHandlerRootView, ScrollView } from 'react-native-gesture-handler'; const LoginScreen = () => { const navigation = useNavigation>(); const [username, setUsername] = useState('sales@rumahjo.com'); const [password, setPassword] = useState('12345678'); const handleLogin = async () => { try{ DB(`SELECT * FROM "public".hr_employee WHERE work_email = '${username}' AND pin = '${password}'`) .then(async function(data){ if(data && Array.isArray(data) && data.length>0){ await AsyncStorage.setItem('login', JSON.stringify(data)); navigation.navigate('home') }else{ Alert.alert("Warning", "Pastikan username atau password sudah benar") } }) .catch(function(err){ }) // Alert.alert(JSON.stringify(data)); // if(data.length > 0){ // await AsyncStorage.setItem('login', JSON.stringify(data)); // }else{ // Alert.alert("Login", "Email atau Password salah") // } }catch(e){ Alert.alert(JSON.stringify(e)) } }; const handleSignUp = () => { navigation.navigate('signup'); }; const handleForgotPassword = () => { Alert.alert("Lupa Password", "Untuk mengganti Password baru, Harap menghubungi admin kantor."); }; return ( <> S.O.R.T Login Silahkan login ke akun anda EMAIL PASSWORD Log In Lupa Password? Belum memiliki akun? Daftar disini! ); }; const styles = StyleSheet.create({ primary:{ backgroundColor:"#2563eb" }, container: { flex: 1, paddingVertical:50, borderTopRightRadius:80, backgroundColor: 'white', justifyContent: 'center', alignItems: 'center', paddingHorizontal: 60 }, appName: { fontSize: 36, color: '#fff', fontWeight: 'bold', marginBottom: 10, }, title: { fontSize: 32, color: '#fff', marginBottom: 20, }, input: { width: '100%', borderWidth:1, borderColor:"#ddd", borderRadius: 10, padding: 15, marginBottom: 20, fontSize: 16, }, button: { backgroundColor: '#2563eb', padding: 15, borderRadius: 10, width: '100%', alignItems: 'center', marginBottom: 10, }, buttonSecondary: { borderWidth: 1, borderColor: '#fff', }, buttonText: { fontSize: 18, color: 'white', }, buttonTextSecondary: { color: '#fff', }, forgotPasswordText: { color: '#777', fontSize: 16, marginBottom: 20, textDecorationLine: 'underline', }, }); export default LoginScreen;