profile send data
This commit is contained in:
		
							parent
							
								
									ee456580d3
								
							
						
					
					
						commit
						149ccd7c11
					
				| 
						 | 
				
			
			@ -27,7 +27,7 @@ const user = route.params;
 | 
			
		|||
// console.log(user);
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <Tab.Navigator params={user} initialRouteName="Comunicados" > 
 | 
			
		||||
    <Tab.Navigator initialParams={user} initialRouteName="Comunicados" > 
 | 
			
		||||
    <Tab.Screen  name="Comunicados" component={Home}  initialParams={user} options={{headerStyle: {
 | 
			
		||||
      backgroundColor: "#D7A86E"
 | 
			
		||||
    }, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}) {
 | 
			
		|||
<View style={styles.container}>
 | 
			
		||||
  <VStack space={3} mt="5">
 | 
			
		||||
            <FormControl isRequired >
 | 
			
		||||
              <FormControl.Label> Correo Electrónico </FormControl.Label>
 | 
			
		||||
              <FormControl.Label Text='bold'> Correo Electrónico </FormControl.Label>
 | 
			
		||||
 | 
			
		||||
              <View style={styles.viewSection}> 
 | 
			
		||||
              <Entypo name="email" size={20} color="grey" style={styles.iconStyle} />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 (
 | 
			
		||||
        <Center>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -39,26 +72,30 @@ export default function Profile({route, navigation}){
 | 
			
		|||
        <VStack space={3} mt="5">
 | 
			
		||||
        <FormControl>
 | 
			
		||||
            <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.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.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.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.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>
 | 
			
		||||
          
 | 
			
		||||
          <Button mt="2" backgroundColor="orange.300">
 | 
			
		||||
          <Button mt="2" backgroundColor="orange.300" onPress={() => updateInfo()}>
 | 
			
		||||
            Actualizar
 | 
			
		||||
          </Button>
 | 
			
		||||
          <Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Inicio')}>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import React from "react";
 | 
			
		||||
import React, { useState } from "react";
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
    Box, 
 | 
			
		||||
| 
						 | 
				
			
			@ -15,8 +15,17 @@ import {
 | 
			
		|||
export default function ProfileGuarda({route, navigation}){
 | 
			
		||||
 | 
			
		||||
  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() => {
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
    return (
 | 
			
		||||
        <Center>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -39,23 +48,23 @@ export default function ProfileGuarda({route, navigation}){
 | 
			
		|||
        <VStack space={3} mt="5">
 | 
			
		||||
        <FormControl>
 | 
			
		||||
            <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>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.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.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.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>
 | 
			
		||||
          
 | 
			
		||||
          <Button mt="2" backgroundColor="orange.300">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue