import React, { useContext, useState } from "react"; import { API } from "../environment/api"; import { Box, Button, Center, FormControl, Heading, ScrollView, VStack } from "native-base"; import { Dimensions, StyleSheet, TextInput, useWindowDimensions } from "react-native"; import { UserContext } from "../context/UserContext"; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; const { Navigator, Screen } = createMaterialTopTabNavigator(); export default function Profile({ navigation }) { const baseURL = `${API.BASE_URL}/user/updateUser/` const [name, setName] = useState(); const [apellido, setApellido] =useState(); const [email, setEmail] = useState(); const [password, setPassword] = useState(); const [index, setIndex] = useState(0); const layout = useWindowDimensions(); // 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 = { "_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 ( ) } 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 } })