fix reservas

This commit is contained in:
Maria Sanchez 2022-08-31 22:14:08 -06:00
parent 0b2ec5800a
commit 8b09f2812f
4 changed files with 22 additions and 23 deletions

View File

@ -20,13 +20,10 @@ export default function AreaComun({navigation}){
const [service, setService] = useState(""); const [service, setService] = useState("");
const [areas, setAreas] = useState([]) const [areas, setAreas] = useState([])
const [isRequesting, setIsRequesting] = useState(false); const [isRequesting, setIsRequesting] = useState(false);
const [selectedHours, setSelectedHours] = useState(0);
const [selectedMinutes, setSelectedMinutes] = useState(0);
const [endSelectedHours, setEndSelectedHours] = useState(0);
const [endSelectedMinutes, setEndSelectedMinutes] = useState(0);
const [time, setTime] = useState(new Date()) const [time, setTime] = useState(new Date())
const [endTime, setEndTime] = useState(new Date()) const idComunidad = user.community_id
const date = new Date(); const date = new Date();
const [mode, setMode] = useState('time');
useEffect(() => { useEffect(() => {
@ -36,7 +33,7 @@ export default function AreaComun({navigation}){
try { try {
const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/allCommonAreas`, { const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/findByCommunity/` + `${idComunidad}`, {
method: "GET", method: "GET",
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
@ -44,7 +41,7 @@ export default function AreaComun({navigation}){
}) })
const response = await jsonResponse.json(); const response = await jsonResponse.json();
console.log(response.message); // console.log(response.message);
setAreas(response.message); setAreas(response.message);
@ -102,16 +99,10 @@ export default function AreaComun({navigation}){
const onChangeStart = (event, selectedDate) => { const onChangeStart = (event, selectedDate) => {
const currentDate = selectedDate; const currentDate = selectedDate || time;
setShow(false);
setTime(currentDate); setTime(currentDate);
}; };
const onChangeEnd = (event, selectedDate) => {
const currentDate = selectedDate;
setShow(false);
setEndTime(currentDate);
};
return ( return (
<Center> <Center>

View File

@ -4,7 +4,7 @@ import {
Box, Button, Box, Button,
Center, FormControl, Heading, ScrollView, VStack Center, FormControl, Heading, ScrollView, VStack
} from "native-base"; } from "native-base";
import { Dimensions, StyleSheet, TextInput, useWindowDimensions } from "react-native"; import { StyleSheet, TextInput, useWindowDimensions } from "react-native";
import { UserContext } from "../context/UserContext"; import { UserContext } from "../context/UserContext";
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import { stringMd5 } from 'react-native-quick-md5'; import { stringMd5 } from 'react-native-quick-md5';
@ -14,7 +14,7 @@ const { Navigator, Screen } = createMaterialTopTabNavigator();
export default function Profile({ navigation }) { export default function Profile({ navigation }) {
const baseURL = `${API.BASE_URL}/user/updateGuarda/` const baseURL = `${API.BASE_URL}/user/updateUser/`
const [index, setIndex] = useState(0); const [index, setIndex] = useState(0);
const layout = useWindowDimensions(); const layout = useWindowDimensions();
const userData = useContext(UserContext) const userData = useContext(UserContext)
@ -22,6 +22,7 @@ export default function Profile({ navigation }) {
const [apellido, setApellido] =useState(userData.user.last_name); const [apellido, setApellido] =useState(userData.user.last_name);
const [email, setEmail] = useState(userData.user.email); const [email, setEmail] = useState(userData.user.email);
const [password, setPassword] = useState(); const [password, setPassword] = useState();
const [confirmPassword, setConfirmPassword] = useState()
const id = userData.user._id; const id = userData.user._id;
const decode = userData.Password; const decode = userData.Password;
const [error, setError] = useState({}) const [error, setError] = useState({})
@ -132,7 +133,7 @@ export default function Profile({ navigation }) {
<FormControl> <FormControl>
<FormControl.Label>Confirmar nueva contraseña</FormControl.Label> <FormControl.Label>Confirmar nueva contraseña</FormControl.Label>
<TextInput editable={!error} style={styles.input} type="password" onChangeText={(value) => setPassword(value) }/> <TextInput editable={!error} style={styles.input} type="password" onChangeText={(value) => setConfirmPassword(value) }/>
</FormControl> </FormControl>
<Button mt="2" backgroundColor="orange.300" onPress={() => updatePassword()} disabled={error}> <Button mt="2" backgroundColor="orange.300" onPress={() => updatePassword()} disabled={error}>
@ -202,7 +203,6 @@ export default function Profile({ navigation }) {
"name": name, "name": name,
"last_name": apellido, "last_name": apellido,
"email": email, "email": email,
"phone": userData.user.phone,
"community_id": userData.user.community_id "community_id": userData.user.community_id
} }
@ -221,10 +221,13 @@ export default function Profile({ navigation }) {
}) })
.then(response => { .then(response => {
console.log(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 ');
console.log(response.json());
}else{ }else{
return response.json(); return response.json();
} }

View File

@ -72,7 +72,9 @@ export class UsersController {
@MessagePattern({ cmd: 'updateUser' }) @MessagePattern({ cmd: 'updateUser' })
update(@Payload() user: UserDocument) { update(@Payload() user: UserDocument) {
return this.userService.update(user._id, user); console.log(user);
return this.userService.update(user['id'], user);
} }
@MessagePattern({ cmd: 'updateGuard' }) @MessagePattern({ cmd: 'updateGuard' })

View File

@ -120,7 +120,10 @@ export class UsersService {
console.log(id) console.log(id)
console.log(user) console.log(user)
return this.userModel.findOneAndUpdate({ _id: id }, user, { return this.userModel.findOneAndUpdate({ _id: id }, {
name: user['name'], last_name: user['last_name'],
dni: user['dni'], email: user['email'], phone: user['phone']
}, {
new: true, new: true,
}); });
} }