From ff1af1961387bb91b86f148e49e2d09bddb595f9 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 23 Aug 2022 18:43:50 -0600 Subject: [PATCH] post de reservas --- mobile-ui/components/AreaComun.js | 43 +++++++++++----------- mobile-ui/components/ReservasCard/index.js | 4 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index c419786d..03c6c7db 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -19,10 +19,8 @@ export default function AreaComun({navigation}){ 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); const date = new Date(); @@ -68,34 +66,35 @@ export default function AreaComun({navigation}){ const data = { - "start_time": Number.parseInt(selectedHours) + ":" +selectedMinutes, - "finish_time": endSelectedHours + ":" +endSelectedMinutes, + "start_time": 7 + ":" +0, + "finish_time": 10 + ":" +0, + "status": 1, "date_entry": date, "user_id" : user._id, - "common_area_id": service, - "common_area_name": "", - "community_id": "" + "common_area_id": service._id, + "common_area_name": service.name, + "community_id": service.community_id } console.log(data); - // try { + 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 jsonResponse.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); + } } @@ -124,7 +123,7 @@ export default function AreaComun({navigation}){ }} mt={1} onValueChange={itemValue => setService(itemValue)}> {areas.map(item => ( - + ))} diff --git a/mobile-ui/components/ReservasCard/index.js b/mobile-ui/components/ReservasCard/index.js index 43a67af2..800cd75b 100644 --- a/mobile-ui/components/ReservasCard/index.js +++ b/mobile-ui/components/ReservasCard/index.js @@ -38,10 +38,10 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => { - - {status === 1 ? 'LIBRE' : 'RESERVADO'} + {status == 1 ? 'LIBRE' : 'RESERVADO'} Reserva #1