import React, { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, Image } from 'react-native'; import { useNavigation, NavigationProp } from '@react-navigation/native'; import { RootStackParamList } from '@/types'; import { DB } from '@/components/lib/db'; import { Ionicons } from '@expo/vector-icons'; import AsyncStorage from '@react-native-async-storage/async-storage'; import { GestureHandlerRootView, ScrollView } from 'react-native-gesture-handler'; import config from '../../components/data/config.json'; const InfoLayer = ({info,navigation}:any) => { return <> Selamat! Akun anda berhasil dibuat Silahkan konfirmasi ke admin untuk aktivasi akun anda. { info(false); navigation.navigate('index') }}> Log In } const RegisterScreen = () => { const navigation = useNavigation>(); const [fullname, setFullname] = useState(''); const [username, setUsername] = useState(''); const [phone, setPhone] = useState(''); const [password, setPassword] = useState(''); const [passwordRepeat, setPasswordRepeat] = useState(''); const [info, setInfo] = useState(false); const handleRegister = async () => { if (password !== passwordRepeat) { Alert.alert('Password tidak sama'); return; } const query = `INSERT INTO "public".hr_employee ( name,work_phone , work_email , pin , resource_id , company_id , resource_calendar_id , color , address_id , work_contact_id , create_uid , write_uid , marital , certificate , employee_type ) VALUES ( '${fullname}' ,'${phone}' ,'${username}' , '${password}' , 6 , 1 , 1 , 0 , 1 , 17 , 6 , 2 , 'single' , 'other' , 'employee' )`; try { await DB(query); Alert.alert('Registrasi berhasil, silakan login'); const data = await DB(`SELECT * FROM "public".hr_employee WHERE work_email = '${username}' AND pin = '${password}'`) await AsyncStorage.setItem('login', JSON.stringify(data)); navigation.navigate('home') } catch (error) { Alert.alert('Gagal mendaftar, silakan coba lagi'); console.error(error); } }; const handleSignIn = () => { navigation.goBack(); }; return ( <> {info? <> : S.O.R.T Register {(`nama lengkap`).toUpperCase()} {(`email`).toUpperCase()} {(`no. telepon`).toUpperCase()} {(`PASSWORD`).toUpperCase()} {(`konfirmasi password`).toUpperCase()} {(`Register`).toUpperCase()} Sudah memiliki akun? Masuk disini! } ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'white', justifyContent: 'center', alignItems: 'center', paddingVertical: 20, paddingHorizontal:40, borderTopLeftRadius: 50 }, appName: { fontSize: 36, color: '#fff', fontWeight: 'bold', marginBottom: 10, }, title: { fontSize: 40, color: config.color.primary, marginBottom: 20, fontWeight:"bold" }, input: { width: '100%', backgroundColor: '#fff', borderWidth:1, borderRadius: 10, padding: 15, marginBottom: 20, fontSize: 16, }, button: { backgroundColor: config.color.primary, padding: 15, borderRadius: 10, width: '100%', alignItems: 'center', marginBottom: 10, }, buttonSecondary: { backgroundColor: 'transparent', borderWidth: 1, borderColor: '#fff', }, buttonText: { fontSize: 18, color: 'white', fontWeight:'bold' }, buttonTextSecondary: { color: '#fff', }, }); export default RegisterScreen;