From 4426981d24eaa7a89da4e0c97ee6d615e2c32b7b Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Thu, 1 Sep 2022 12:36:28 -0600 Subject: [PATCH] fix profile --- mobile-ui/components/Profile.js | 43 +++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 8b656a59..1900c950 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -1,22 +1,19 @@ import React, { useContext, useState } from "react"; import { API } from "../environment/api"; import { - Box, Button, - Center, FormControl, Heading, ScrollView, VStack + Box, Button, FormControl, Heading, ScrollView, VStack } from "native-base"; -import { StyleSheet, TextInput, useWindowDimensions } from "react-native"; +import { StyleSheet, TextInput} from "react-native"; import { UserContext } from "../context/UserContext"; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { stringMd5 } from 'react-native-quick-md5'; - const { Navigator, Screen } = createMaterialTopTabNavigator(); export default function Profile({ navigation }) { const baseURL = `${API.BASE_URL}/user/updateUser/` - const [index, setIndex] = useState(0); - const layout = useWindowDimensions(); + const userData = useContext(UserContext) const [name, setName] = useState(userData.user.name); const [apellido, setApellido] =useState(userData.user.last_name); @@ -29,6 +26,26 @@ export default function Profile({ navigation }) { console.log(userData.user); + + const [info, setInfo] = useState({ + _id: userData.user._id, + dni: userData.user.dni, + name: "", + last_name: "", + email: "", + community_id: userData.user.community_id, + }); + + const [infoPassword, setInfoPassword] = useState({ + _id: userData.user._id, + dni: userData.user.dni, + password: "" + + }); + + + const onHandleChange = (name) => (value) => setInfo(prev => ({...prev, [name]: value})) + const onHandleChangePassword = (value) => { //console.log(value); const dpassword = stringMd5(value) @@ -77,20 +94,20 @@ export default function Profile({ navigation }) { */} Nombre - setName(value) }/> + Apellido - setApellido(value) } /> + Correo electrónico - setEmail(value) }/> + - @@ -214,7 +231,7 @@ export default function Profile({ navigation }) { cache: 'no-cache', method: 'PUT', - body: JSON.stringify(data), + body: JSON.stringify(info), headers: { 'Content-Type': 'application/json' } @@ -258,11 +275,7 @@ const styles = StyleSheet.create({ height: 35, margin: 3, borderWidth: 0.5, - padding: 5, flex: 1, - paddingTop: 9, - paddingRight: 19, - paddingLeft: 0, marginTop: 6, borderRadius: 4 },