screen de agregar invitado
This commit is contained in:
parent
1eb3fa41e6
commit
2a8233cceb
|
@ -14,6 +14,7 @@ import Profile from "./components/Profile";
|
||||||
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
||||||
import AreaComun from "./components/AreaComun";
|
import AreaComun from "./components/AreaComun";
|
||||||
import { UserContext, UserContextProvider } from "./context/UserContext";
|
import { UserContext, UserContextProvider } from "./context/UserContext";
|
||||||
|
import AgregarInvitados from "./components/AgregarInvitados";
|
||||||
|
|
||||||
const Stack = createNativeStackNavigator();
|
const Stack = createNativeStackNavigator();
|
||||||
const Tab = createBottomTabNavigator();
|
const Tab = createBottomTabNavigator();
|
||||||
|
@ -34,6 +35,9 @@ function HomeTab({ route }) {
|
||||||
<Tab.Screen name="Reservas" component={Reservas } initialParams={user} options={{headerStyle: {
|
<Tab.Screen name="Reservas" component={Reservas } initialParams={user} options={{headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
||||||
|
<Tab.Screen name="Invitados" component={AgregarInvitados} initialParams={user} options={{headerStyle: {
|
||||||
|
backgroundColor: "#D7A86E"
|
||||||
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'contacts' : 'contacts-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
||||||
<Tab.Screen name="Perfil" component={Profile} initialParams={user} options={{headerStyle: {
|
<Tab.Screen name="Perfil" component={Profile} initialParams={user} options={{headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 2 ? 'account' : 'account-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(2)} />
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 2 ? 'account' : 'account-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(2)} />
|
||||||
|
|
|
@ -1,22 +1,146 @@
|
||||||
import React from "react";
|
import React, { useContext, useState } from "react";
|
||||||
|
import { API } from "../environment/api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Box, Button,
|
||||||
Center,
|
Center, FormControl, Heading, ScrollView, VStack
|
||||||
|
|
||||||
} from "native-base";
|
} from "native-base";
|
||||||
|
|
||||||
|
import { StyleSheet, TextInput } from "react-native";
|
||||||
|
import { UserContext } from "../context/UserContext";
|
||||||
|
|
||||||
export default function AgregarInvitados({navigation}) {
|
export default function AgregarInvitados({ navigation }) {
|
||||||
return (
|
|
||||||
|
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 userData = useContext(UserContext)
|
||||||
|
const id = userData.user._id;
|
||||||
|
|
||||||
|
|
||||||
<Center w="100%">
|
|
||||||
|
|
||||||
|
|
||||||
</Center>
|
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 (
|
||||||
|
<Center>
|
||||||
|
|
||||||
|
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
|
||||||
|
px: "20px",
|
||||||
|
mb: "4",
|
||||||
|
minW: "72"
|
||||||
|
}}>
|
||||||
|
<Box safeArea p="2" w="90%" maxW="290" py="8">
|
||||||
|
<Heading size="lg" color="coolGray.800" _dark={{
|
||||||
|
color: "warmGray.50"
|
||||||
|
}} fontWeight="semibold">
|
||||||
|
Registrar invitado
|
||||||
|
</Heading>
|
||||||
|
<Heading mt="1" color="coolGray.600" _dark={{
|
||||||
|
color: "warmGray.200"
|
||||||
|
}} fontWeight="medium" size="xs">
|
||||||
|
Registre el invitado que desee
|
||||||
|
</Heading>
|
||||||
|
<VStack space={3} mt="5">
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>DNI</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="text" onChangeText={(value) => setName(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Teléfono</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="text" onChangeText={(value) => setName(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Nombre</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="text" onChangeText={(value) => setName(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Apellido</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="text" onChangeText={(value) => setApellido(value) } />
|
||||||
|
</FormControl>
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Correo electrónico</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="text" onChangeText={(value) => setEmail(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Contraseña actual</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="password" onChangeText={(value) => setPassword(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
|
<Button mt="2" backgroundColor="orange.300" onPress={() => updateInfo()}>
|
||||||
|
Guardar
|
||||||
|
</Button>
|
||||||
|
{/* <Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Inicio')}>
|
||||||
|
Cerrar sesión
|
||||||
|
</Button> */}
|
||||||
|
</VStack>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
</Center>
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ export default function LogIn({ navigation }) {
|
||||||
const { addUser } = useContext(UserContext);
|
const { addUser } = useContext(UserContext);
|
||||||
|
|
||||||
const [credentials, setCredentials] = useState({
|
const [credentials, setCredentials] = useState({
|
||||||
email: "",
|
email: "lalo@lalo.com",
|
||||||
password: ""
|
password: "12345"
|
||||||
});
|
});
|
||||||
|
|
||||||
const onHandleChange = (name) => (value) => setCredentials(prev => ({ ...prev, [name]: value }))
|
const onHandleChange = (name) => (value) => setCredentials(prev => ({ ...prev, [name]: value }))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
|
import { API } from "../environment/api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Box, Button,
|
Box, Button,
|
||||||
|
@ -12,18 +11,18 @@ import { UserContext } from "../context/UserContext";
|
||||||
|
|
||||||
export default function Profile({ navigation }) {
|
export default function Profile({ navigation }) {
|
||||||
|
|
||||||
const baseURL = 'http://localhost:4000/user/updateUser'
|
const baseURL = `${API.BASE_URL}/user/updateUser/`
|
||||||
//const userData = JSON.parse(JSON.stringify(route.params));
|
//const userData = JSON.parse(JSON.stringify(route.params));
|
||||||
const [name, setName] = useState();
|
const [name, setName] = useState();
|
||||||
const [apellido, setApellido] =useState();
|
const [apellido, setApellido] =useState();
|
||||||
const [email, setEmail] = useState();
|
const [email, setEmail] = useState();
|
||||||
const [password, setPassword] = useState();
|
const [password, setPassword] = useState();
|
||||||
|
|
||||||
|
const userData = useContext(UserContext)
|
||||||
const id = userData.user._id;
|
const id = userData.user._id;
|
||||||
|
|
||||||
console.log(userData.user);
|
console.log(userData.user);
|
||||||
|
|
||||||
const userData = useContext(UserContext)
|
|
||||||
|
|
||||||
|
|
||||||
const updateInfo = async() => {
|
const updateInfo = async() => {
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ export default function Profile({ navigation }) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await fetch(baseURL+':'+id, {
|
await fetch(baseURL+`${id}`, {
|
||||||
|
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
@ -54,7 +53,7 @@ export default function Profile({ navigation }) {
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
||||||
console.log(baseURL+'/:'+id);
|
console.log(baseURL+`${id}`);
|
||||||
if (response.status != 201){
|
if (response.status != 201){
|
||||||
console.log('ocurrio un error ');
|
console.log('ocurrio un error ');
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default function Reservas({navigation}) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Box alignItems="center">
|
<Box mt="5" alignItems="center">
|
||||||
<Box width="80" rounded="lg" overflow="hidden" borderColor="coolGray.200" borderWidth="1" _dark={{
|
<Box width="80" rounded="lg" overflow="hidden" borderColor="coolGray.200" borderWidth="1" _dark={{
|
||||||
borderColor: "coolGray.600",
|
borderColor: "coolGray.600",
|
||||||
backgroundColor: "gray.700"
|
backgroundColor: "gray.700"
|
||||||
|
@ -93,45 +93,6 @@ export default function Reservas({navigation}) {
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box alignItems="center" width={"100%"}>
|
|
||||||
<Box width="80" rounded="lg" overflow="hidden" borderColor="coolGray.200" borderWidth="1" _dark={{
|
|
||||||
borderColor: "coolGray.600",
|
|
||||||
backgroundColor: "gray.700"
|
|
||||||
}} _web={{
|
|
||||||
shadow: 2,
|
|
||||||
borderWidth: 0
|
|
||||||
}} _light={{
|
|
||||||
backgroundColor: "gray.50"
|
|
||||||
}}>
|
|
||||||
|
|
||||||
<Stack p="4" space={3}>
|
|
||||||
<Stack space={2}>
|
|
||||||
<Heading size="md" ml="-1">
|
|
||||||
Reserva #1
|
|
||||||
</Heading>
|
|
||||||
<Text fontSize="xs" _light={{
|
|
||||||
color: "violet.500"
|
|
||||||
}} _dark={{
|
|
||||||
color: "violet.400"
|
|
||||||
}} fontWeight="500" ml="-0.5" mt="-1">
|
|
||||||
horario de Reserva
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
<Text fontWeight="400">
|
|
||||||
Descripcion
|
|
||||||
</Text>
|
|
||||||
<HStack alignItems="center" space={4} justifyContent="space-between">
|
|
||||||
<HStack alignItems="center">
|
|
||||||
<Text color="coolGray.600" _dark={{
|
|
||||||
color: "warmGray.200"
|
|
||||||
}} fontWeight="400">
|
|
||||||
6 mins ago
|
|
||||||
</Text>
|
|
||||||
</HStack>
|
|
||||||
</HStack>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box height="200" w="300" shadow="2" rounded="lg" m='5' ml='9' _dark={{
|
<Box height="200" w="300" shadow="2" rounded="lg" m='5' ml='9' _dark={{
|
||||||
bg: "coolGray.200:alpha.20"
|
bg: "coolGray.200:alpha.20"
|
||||||
|
|
Loading…
Reference in New Issue