import React, {useState} from "react"; import Cookies from 'universal-cookie'; import { Text, Link, Center, Heading, VStack, Box, FormControl, Button, Image } from "native-base"; import logo from "../assets/logo-katoikia.png"; import { Entypo } from '@expo/vector-icons'; import { MaterialCommunityIcons } from '@expo/vector-icons'; import { View, TextInput, StyleSheet } from "react-native"; const baseURL = "http://localhost:4000/user/loginUser"; const cookies = new Cookies(); // const handleChange = (value) => { // console.log(value); // } export default function LogIn({navigation}) { const [email, setEmail] = useState(); const [password, setPassword] = useState(); // const [inputs, setInputs] = useState(); const iniciarSesion = async () => { console.log(email); const userData = { email: "lalo@lalo.com", password: '12345' } console.log(userData); // const userData = JSON.stringify(FormControl.toString); // console.log(userData); try { await fetch(baseURL, { cache: 'no-cache', method: 'POST', body: JSON.stringify(userData), headers: { 'Content-Type': 'application/json' } }) .then(response => { if (response.status != 201){ console.log('ocurrio un error '); }else{ return response.json(); } }) .then( response => { // inqulino 4 y guarda 63 const user = response.message //console.log(user); cookies.set('id',user._id, {path: "/"} ) cookies.set('name',user.name, {path: "/"} ) cookies.set('email',user.email, {path: "/"} ) cookies.set('type',user.user_type, {path: "/"} ) if(user.user_type == '4'){ }else if(user.user_type == '3'){ navigation.navigate('Comunicados', {user}) } }) } catch (error) { console.log("ERROR: " +error); } } return (