From 2a8233ccebf5c10079faaa707c9f2d8594ba0891 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Mon, 22 Aug 2022 19:31:42 -0600 Subject: [PATCH] screen de agregar invitado --- mobile-ui/App.js | 4 + mobile-ui/components/AgregarInvitados.js | 152 ++++++++++++++++++++--- mobile-ui/components/LogIn.js | 4 +- mobile-ui/components/Profile.js | 13 +- mobile-ui/components/Reservas.js | 41 +----- 5 files changed, 151 insertions(+), 63 deletions(-) diff --git a/mobile-ui/App.js b/mobile-ui/App.js index 9578ae45..a8888f4e 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -14,6 +14,7 @@ import Profile from "./components/Profile"; import { MaterialCommunityIcons } from '@expo/vector-icons'; import AreaComun from "./components/AreaComun"; import { UserContext, UserContextProvider } from "./context/UserContext"; +import AgregarInvitados from "./components/AgregarInvitados"; const Stack = createNativeStackNavigator(); const Tab = createBottomTabNavigator(); @@ -34,6 +35,9 @@ function HomeTab({ route }) { (} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} /> + (} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} /> (} color="#D7A86E" size="md" />)}} onclick={() => setSelected(2)} /> diff --git a/mobile-ui/components/AgregarInvitados.js b/mobile-ui/components/AgregarInvitados.js index deca694b..82eb3a10 100644 --- a/mobile-ui/components/AgregarInvitados.js +++ b/mobile-ui/components/AgregarInvitados.js @@ -1,22 +1,146 @@ -import React from "react"; +import React, { useContext, useState } from "react"; +import { API } from "../environment/api"; import { - - Center, - + 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}) { - return ( - +export default function AgregarInvitados({ navigation }) { + + const baseURL = `${API.BASE_URL}/user/updateUser/` + //const userData = JSON.parse(JSON.stringify(route.params)); + const [name, setName] = useState(); + const [apellido, setApellido] =useState(); + const [email, setEmail] = useState(); + const [password, setPassword] = useState(); + + const userData = useContext(UserContext) + const id = userData.user._id; + + + + + const updateInfo = async() => { + + const data = { + "_id": "6301df20dac7dcf76dcecade", + "dni": "1234567890", + "name": name, + "last_name": apellido, + "email": email, + "phone": 12121212, + "password": "827ccb0eea8a706c4c34a16891f84e7b", + "user_type": "3", + "status": "1", + "date_entry": "2022-08-21T07:30:09.929Z", + "community_id": null, + } + + try { + + await fetch(baseURL+`${id}`, { + + cache: 'no-cache', + method: 'PUT', + body: JSON.stringify(data), + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + + console.log(baseURL+`${id}`); + 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 + + + + DNI + setName(value) }/> + + + Teléfono + setName(value) }/> + + + Nombre + setName(value) }/> + + + Apellido + setApellido(value) } /> + + + Correo electrónico + setEmail(value) }/> + + + Contraseña actual + setPassword(value) }/> + + + + {/* */} + + + + +
+ + ) - -} \ No newline at end of file +} + +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 + } +}) + diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index 489acfb9..758166c3 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -25,8 +25,8 @@ export default function LogIn({ navigation }) { const { addUser } = useContext(UserContext); const [credentials, setCredentials] = useState({ - email: "", - password: "" + email: "lalo@lalo.com", + password: "12345" }); const onHandleChange = (name) => (value) => setCredentials(prev => ({ ...prev, [name]: value })) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 0319c5fc..dc15f209 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -1,6 +1,5 @@ - import React, { useContext, useState } from "react"; - +import { API } from "../environment/api"; import { Box, Button, @@ -12,18 +11,18 @@ import { UserContext } from "../context/UserContext"; export default function Profile({ navigation }) { - const baseURL = 'http://localhost:4000/user/updateUser' + const baseURL = `${API.BASE_URL}/user/updateUser/` //const userData = JSON.parse(JSON.stringify(route.params)); const [name, setName] = useState(); const [apellido, setApellido] =useState(); const [email, setEmail] = useState(); const [password, setPassword] = useState(); + + const userData = useContext(UserContext) const id = userData.user._id; console.log(userData.user); - const userData = useContext(UserContext) - const updateInfo = async() => { @@ -43,7 +42,7 @@ export default function Profile({ navigation }) { try { - await fetch(baseURL+':'+id, { + await fetch(baseURL+`${id}`, { cache: 'no-cache', method: 'PUT', @@ -54,7 +53,7 @@ export default function Profile({ navigation }) { }) .then(response => { - console.log(baseURL+'/:'+id); + console.log(baseURL+`${id}`); if (response.status != 201){ console.log('ocurrio un error '); }else{ diff --git a/mobile-ui/components/Reservas.js b/mobile-ui/components/Reservas.js index dd5b8532..33722f08 100644 --- a/mobile-ui/components/Reservas.js +++ b/mobile-ui/components/Reservas.js @@ -54,7 +54,7 @@ export default function Reservas({navigation}) { - + - - - - - - - Reserva #1 - - - horario de Reserva - - - - Descripcion - - - - - 6 mins ago - - - - - -