From 149ccd7c11c61a1e16fbed836cda6a08c0991449 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Mon, 22 Aug 2022 14:09:33 -0600 Subject: [PATCH] profile send data --- mobile-ui/App.js | 2 +- mobile-ui/components/Home.js | 2 +- mobile-ui/components/LogIn.js | 4 +-- mobile-ui/components/Profile.js | 51 +++++++++++++++++++++++---- mobile-ui/components/ProfileGuarda.js | 21 +++++++---- 5 files changed, 63 insertions(+), 17 deletions(-) diff --git a/mobile-ui/App.js b/mobile-ui/App.js index 95065cf4..06110bf4 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -27,7 +27,7 @@ const user = route.params; // console.log(user); return ( - + (} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)} diff --git a/mobile-ui/components/Home.js b/mobile-ui/components/Home.js index cd943f99..e9c418df 100644 --- a/mobile-ui/components/Home.js +++ b/mobile-ui/components/Home.js @@ -9,7 +9,7 @@ Pressable, ScrollView } from "native-base"; import { MaterialCommunityIcons } from '@expo/vector-icons'; -export default function Home(){ +export default function Home({route}){ const [selected, setSelected] = React.useState(0); return ( diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index 5b2089b5..85ef17a8 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -73,7 +73,7 @@ export default function LogIn({navigation}) { cookies.set('type',user.user_type, {path: "/"} ) if(user.user_type == '4'){ - + navigation.navigate('Comunicados', {user}) }else if(user.user_type == '3'){ navigation.navigate('Comunicados', {user}) } @@ -125,7 +125,7 @@ export default function LogIn({navigation}) { - Correo Electrónico + Correo Electrónico diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index e17e35e0..ac07ddaa 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import { Box, @@ -14,9 +14,42 @@ import { export default function Profile({route, navigation}){ + + + const baseURL = 'http://localhost:4000/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(); console.log(userData.user); + + + const updateInfo = async() => { + + try { + + await fetch(baseURL, { + cache: 'no-cache', + method: 'PUT', + body: JSON.stringify(userData), + 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 (
@@ -39,26 +72,30 @@ export default function Profile({route, navigation}){ DNI - + + + + Teléfono + Nombre - + setName(value) }/> Apellido - + setApellido(value) } /> Correo electrónico - + setEmail(value) }/> Contraseña actual - + setPassword(value) }/> -