From b7ee2a20a967882d6fbb84d8a3577ca4bb3f683d Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 23 Aug 2022 20:35:11 -0600 Subject: [PATCH] modified time picker for reservas --- mobile-ui/components/AreaComun.js | 89 +++++++++++++++---------------- mobile-ui/package.json | 3 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 03c6c7db..0ad1a059 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -13,6 +13,7 @@ import { API } from "../environment/api"; import {TimePicker} from 'react-native-simple-time-picker'; import { View, StyleSheet } from "react-native"; import { number } from "prop-types"; +import DateTimePicker from '@react-native-community/datetimepicker'; export default function AreaComun({navigation}){ const { user } = useContext(UserContext) @@ -23,6 +24,8 @@ export default function AreaComun({navigation}){ const [selectedMinutes, setSelectedMinutes] = useState(0); const [endSelectedHours, setEndSelectedHours] = useState(0); const [endSelectedMinutes, setEndSelectedMinutes] = useState(0); + const [time, setTime] = useState(new Date(1598051730000)) + const [endTime, setEndTime] = useState(new Date(1598051730000)) const date = new Date(); useEffect(() => { @@ -62,43 +65,53 @@ export default function AreaComun({navigation}){ const postReserva = async() => { - //console.log(date); + console.log(time); - const data = { + // const data = { - "start_time": 7 + ":" +0, - "finish_time": 10 + ":" +0, - "status": 1, - "date_entry": date, - "user_id" : user._id, - "common_area_id": service._id, - "common_area_name": service.name, - "community_id": service.community_id + // "start_time": 7 + ":" +0, + // "finish_time": 10 + ":" +0, + // "status": 1, + // "date_entry": date, + // "user_id" : user._id, + // "common_area_id": service._id, + // "common_area_name": service.name, + // "community_id": service.community_id - } + // } - console.log(data); - try { + // console.log(data); + // try { - const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, { - cache: 'no-cache', - method: 'POST', - body: JSON.stringify(data), - headers: { - 'Content-Type': 'application/json' - } - }) + // const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, { + // cache: 'no-cache', + // method: 'POST', + // body: JSON.stringify(data), + // headers: { + // 'Content-Type': 'application/json' + // } + // }) - const response = await jsonDataResponse.json(); - console.log(response.message); + // const response = await jsonDataResponse.json(); + // console.log(response.message); - } catch (error) { - console.log("ERROR:" + error); - } + // } catch (error) { + // console.log("ERROR:" + error); + // } } - + const onChangeStart = (event, selectedDate) => { + const currentDate = selectedDate; + setShow(false); + setTime(currentDate); + }; + const onChangeEnd = (event, selectedDate) => { + const currentDate = selectedDate; + setShow(false); + setEndTime(currentDate); + }; + return (
@@ -131,36 +144,22 @@ export default function AreaComun({navigation}){ Hora de inicio - { - setSelectedHours(hours); - setSelectedMinutes(minutes); - }}/> + Hora de finalizaciĆ³n - { - setEndSelectedHours(hours); - setEndSelectedMinutes(minutes); - }}/> + - - diff --git a/mobile-ui/package.json b/mobile-ui/package.json index ba741594..310e6a33 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -38,7 +38,8 @@ "react-native-svg": "12.1.1", "react-native-table-component": "^1.2.2", "react-native-web": "0.17.1", - "universal-cookie": "^4.0.4" + "universal-cookie": "^4.0.4", + "@react-native-community/datetimepicker": "4.0.0" }, "devDependencies": { "@babel/core": "^7.12.9"