profile send data

This commit is contained in:
Maria Sanchez 2022-08-22 14:09:33 -06:00
parent ee456580d3
commit 149ccd7c11
5 changed files with 63 additions and 17 deletions

View File

@ -27,7 +27,7 @@ const user = route.params;
// console.log(user); // console.log(user);
return ( return (
<Tab.Navigator params={user} initialRouteName="Comunicados" > <Tab.Navigator initialParams={user} initialRouteName="Comunicados" >
<Tab.Screen name="Comunicados" component={Home} initialParams={user} options={{headerStyle: { <Tab.Screen name="Comunicados" component={Home} initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E" backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)} }, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}

View File

@ -9,7 +9,7 @@ Pressable,
ScrollView ScrollView
} from "native-base"; } from "native-base";
import { MaterialCommunityIcons } from '@expo/vector-icons'; import { MaterialCommunityIcons } from '@expo/vector-icons';
export default function Home(){ export default function Home({route}){
const [selected, setSelected] = React.useState(0); const [selected, setSelected] = React.useState(0);
return ( return (

View File

@ -73,7 +73,7 @@ export default function LogIn({navigation}) {
cookies.set('type',user.user_type, {path: "/"} ) cookies.set('type',user.user_type, {path: "/"} )
if(user.user_type == '4'){ if(user.user_type == '4'){
navigation.navigate('Comunicados', {user})
}else if(user.user_type == '3'){ }else if(user.user_type == '3'){
navigation.navigate('Comunicados', {user}) navigation.navigate('Comunicados', {user})
} }
@ -125,7 +125,7 @@ export default function LogIn({navigation}) {
<View style={styles.container}> <View style={styles.container}>
<VStack space={3} mt="5"> <VStack space={3} mt="5">
<FormControl isRequired > <FormControl isRequired >
<FormControl.Label> Correo Electrónico </FormControl.Label> <FormControl.Label Text='bold'> Correo Electrónico </FormControl.Label>
<View style={styles.viewSection}> <View style={styles.viewSection}>
<Entypo name="email" size={20} color="grey" style={styles.iconStyle} /> <Entypo name="email" size={20} color="grey" style={styles.iconStyle} />

View File

@ -1,4 +1,4 @@
import React from "react"; import React, { useState } from "react";
import { import {
Box, Box,
@ -14,9 +14,42 @@ import {
export default function Profile({route, navigation}){ export default function Profile({route, navigation}){
const baseURL = 'http://localhost:4000/user/updateUser'
const userData = JSON.parse(JSON.stringify(route.params)); 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); 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 ( return (
<Center> <Center>
@ -39,26 +72,30 @@ export default function Profile({route, navigation}){
<VStack space={3} mt="5"> <VStack space={3} mt="5">
<FormControl> <FormControl>
<FormControl.Label>DNI</FormControl.Label> <FormControl.Label>DNI</FormControl.Label>
<TextInput type="text" defaultValue={userData.user.dni} editable='false'/> <TextInput type="text" defaultValue={userData.user.dni} editable={false} />
</FormControl>
<FormControl>
<FormControl.Label>Teléfono</FormControl.Label>
<TextInput type="text" defaultValue={userData.user.phone} editable={false} />
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Nombre</FormControl.Label> <FormControl.Label>Nombre</FormControl.Label>
<TextInput style={styles.input} type="text" defaultValue={userData.user.name}/> <TextInput style={styles.input} type="text" defaultValue={userData.user.name} onChangeText={(value) => setName(value) }/>
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Apellido</FormControl.Label> <FormControl.Label>Apellido</FormControl.Label>
<TextInput style={styles.input} type="text"defaultValue={userData.user.last_name} /> <TextInput style={styles.input} type="text"defaultValue={userData.user.last_name} onChangeText={(value) => setApellido(value) } />
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Correo electrónico</FormControl.Label> <FormControl.Label>Correo electrónico</FormControl.Label>
<TextInput style={styles.input} type="text" defaultValue={userData.user.email}/> <TextInput style={styles.input} type="text" defaultValue={userData.user.email} onChangeText={(value) => setEmail(value) }/>
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Contraseña actual</FormControl.Label> <FormControl.Label>Contraseña actual</FormControl.Label>
<TextInput style={styles.input} type="password" defaultValue=""/> <TextInput style={styles.input} type="password" defaultValue="" onChangeText={(value) => setPassword(value) }/>
</FormControl> </FormControl>
<Button mt="2" backgroundColor="orange.300"> <Button mt="2" backgroundColor="orange.300" onPress={() => updateInfo()}>
Actualizar Actualizar
</Button> </Button>
<Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Inicio')}> <Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Inicio')}>

View File

@ -1,4 +1,4 @@
import React from "react"; import React, { useState } from "react";
import { import {
Box, Box,
@ -15,8 +15,17 @@ import {
export default function ProfileGuarda({route, navigation}){ export default function ProfileGuarda({route, navigation}){
const userData = JSON.parse(JSON.stringify(route.params)); 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); console.log(userData.user);
const updateInfo = async() => {
}
return ( return (
<Center> <Center>
@ -39,23 +48,23 @@ export default function ProfileGuarda({route, navigation}){
<VStack space={3} mt="5"> <VStack space={3} mt="5">
<FormControl> <FormControl>
<FormControl.Label>DNI</FormControl.Label> <FormControl.Label>DNI</FormControl.Label>
<TextInput type="text" defaultValue={userData.user.dni} editable='false'/> <TextInput type="text" defaultValue={userData.user.dni} editable='false' />
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Nombre</FormControl.Label> <FormControl.Label>Nombre</FormControl.Label>
<TextInput style={styles.input} type="text" defaultValue={userData.user.name}/> <TextInput style={styles.input} type="text" defaultValue={userData.user.name} onChangeText={(value) => setName(value) }/>
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Apellido</FormControl.Label> <FormControl.Label>Apellido</FormControl.Label>
<TextInput style={styles.input} type="text"defaultValue={userData.user.last_name} /> <TextInput style={styles.input} type="text"defaultValue={userData.user.last_name} onChangeText={(value) => setApellido(value) } />
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Correo electrónico</FormControl.Label> <FormControl.Label>Correo electrónico</FormControl.Label>
<TextInput style={styles.input} type="text" defaultValue={userData.user.email}/> <TextInput style={styles.input} type="text" defaultValue={userData.user.email} onChangeText={(value) => setEmail(value) }/>
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label>Contraseña actual</FormControl.Label> <FormControl.Label>Contraseña actual</FormControl.Label>
<TextInput style={styles.input} type="password" defaultValue=""/> <TextInput style={styles.input} type="password" defaultValue="" onChangeText={(value) => setPassword(value) }/>
</FormControl> </FormControl>
<Button mt="2" backgroundColor="orange.300"> <Button mt="2" backgroundColor="orange.300">