import React, {useContext, useEffect, useState} from "react"; import { Box, Heading, VStack, FormControl, Button, Center, Select, CheckIcon, ScrollView } from "native-base"; import { UserContext } from "../context/UserContext"; import { API } from "../environment/api"; import {TimePicker} from 'react-native-simple-time-picker'; import { View, StyleSheet } from "react-native"; export default function AreaComun({navigation}){ const { user } = useContext(UserContext) const [service, setService] = useState(""); const [areas, setAreas] = useState([]) 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); useEffect(() => { const onRequestReservasData = async () => { setIsRequesting(true); try { const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/allCommonAreas`, { method: "GET", headers: { 'Content-Type': 'application/json' } }) const response = await jsonResponse.json(); console.log(response.message); setAreas(response.message); } catch (error) { console.log("ERROR:" + error); } setIsRequesting(false) } onRequestReservasData() }, [user]) const postReserva = async() => { const data = { "start_time": selectedHours + ":" +selectedMinutes, "finish_time": endSelectedHours + ":" +endSelectedMinutes, "date_entry": "", "user_id" : user._id, "common_area_id": service } 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 response = await jsonResponse.json(); // console.log(response.message); // } catch (error) { // console.log("ERROR:" + error); // } } return (