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 (
Registrar invitado Registre el invitado que desee Nombre setName(value)}/> Apellido setApellido(value)}/> Identificación setDNI(value)}/> Teléfono setPhone(value)} /> Placa setPhone(value)} />
) } const styles = StyleSheet.create({ input: { height: 10, margin: 3, borderWidth: 0.5, padding: 5, flex: 1, paddingTop: 9, paddingRight: 19, paddingBottom: 20, paddingLeft: 0, marginTop: 6, marginBottom: 6, borderRadius: 4 } })