import React, { useContext, useState } from "react"; import { API } from "../environment/api"; import { Box, Button, Center, FormControl, Heading, ScrollView, VStack } from "native-base"; import { StyleSheet, TextInput } from "react-native"; import { UserContext } from "../context/UserContext"; export default function AgregarInvitados({ navigation }) { const baseURL = `${API.BASE_URL}/guest/createGuest/`; const [name, setName] = useState(); const [apellido, setApellido] =useState(); const [dni, setDNI] = useState(); const [phone, setPhone] = useState(); const [number_plate, setNumber_plate] = useState(); const [tenant_id, setTenant_id] = useState(); const [community_id, setCommunity_id] = useState(); const { user } = useContext(UserContext); const saveInvitado = async() => { const data = { "name": name, "last_name": apellido, "dni": dni, "phone": phone, "number_plate": number_plate, "tenant_id": user.id, "community_id": user.community_id } try { await fetch(baseURL, { cache: 'no-cache', method: 'POST', body: JSON.stringify(data), headers: { 'Content-Type': 'application/json' } }) .then(response => { if (response.status != 201){ console.log('ocurrio un error '); }else{ return response.json(); } }) } catch (error) { console.log("ERROR: " + error); } } return (