From 5991ee9471c3b21dea91e94f8a879f79abb04688 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Wed, 24 Aug 2022 19:58:49 -0600 Subject: [PATCH] profile dividing user info and password --- mobile-ui/components/LogIn.js | 1 + mobile-ui/components/Profile.js | 209 +++++++++++++++++++++++--------- mobile-ui/package.json | 3 +- 3 files changed, 155 insertions(+), 58 deletions(-) diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index fdb48f9f..f549fad3 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -60,6 +60,7 @@ export default function LogIn({ navigation }) { navigation.navigate('Comunicados', {user}) }else if(user.user_type == '3'){ addUser(user); + // cambiar por ComunicadosGuarda luego navigation.navigate('Comunicados', {user}) } }) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 76b45b55..1f42b353 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -1,29 +1,168 @@ 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 { Dimensions, StyleSheet, TextInput } from "react-native"; import { UserContext } from "../context/UserContext"; +import {SceneMap, TabView} from 'react-native-pager-view'; export default function Profile({ 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 [index, setIndex] = useState(0); + + const [routes] = useState([{ + key: "first", + title: 'Información' + }, { + key: "second", + title: 'Contraseña'}]) const userData = useContext(UserContext) const id = userData.user._id; console.log(userData.user); + const ProfileView = () => { + + + + Bienvenido {userData.user.name} + + + Modifique sus datos + + + + DNI + + + {/* + Teléfono + + */} + + Nombre + setName(value) }/> + + + Apellido + setApellido(value) } /> + + + Correo electrónico + setEmail(value) }/> + + + + + + + + + } + + const PasswordView = () => { + + + + + + Bienvenido {userData.user.name} + + + Modifique sus contraseña + + + + + Contraseña actual + setPassword(value) }/> + + + Nueva Contraseña + setPassword(value) }/> + + + + Confirmar nueva contraseña + setPassword(value) }/> + + + + + + + + + + + } + + const initialLayout = { + width: Dimensions.get('window').width + } + + const renderScene = SceneMap({ + first: ProfileView, + second: PasswordView + }) + + + const renderTabBar = props => { + const inputRange = props.navigationState.routes.map((x, i) => i); + return + {props.navigationState.routes.map((route, i) => { + const opacity = props.position.interpolate({ + inputRange, + outputRange: inputRange.map(inputIndex => inputIndex === i ? 1 : 0.5) + }); + const color = index === i ? useColorModeValue('#000', '#e5e5e5') : useColorModeValue('#1f2937', '#a1a1aa'); + const borderColor = index === i ? 'cyan.500' : useColorModeValue('coolGray.200', 'gray.400'); + return + { + console.log(i); + setIndex(i); + }}> + {route.title} + + ; + })} + ; + }; + + const updateInfo = async() => { const data = { @@ -65,61 +204,17 @@ export default function Profile({ navigation }) { console.log("ERROR: " + error); } } + + + return (
- - - - - Bienvenido {userData.user.name} - - - Modifique sus datos - - - - DNI - - - {/* - Teléfono - - */} - - Nombre - setName(value) }/> - - - Apellido - setApellido(value) } /> - - - Correo electrónico - setEmail(value) }/> - - - Contraseña actual - setPassword(value) }/> - - - - - - - - + ;
) diff --git a/mobile-ui/package.json b/mobile-ui/package.json index 310e6a33..9e728a9c 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -39,7 +39,8 @@ "react-native-table-component": "^1.2.2", "react-native-web": "0.17.1", "universal-cookie": "^4.0.4", - "@react-native-community/datetimepicker": "4.0.0" + "@react-native-community/datetimepicker": "4.0.0", + "react-native-pager-view": "5.4.9" }, "devDependencies": { "@babel/core": "^7.12.9"