diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 2e4ebe78..98dfa3cc 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -25,6 +25,9 @@ export default function AreaComun({navigation}){ const date = new Date(); const [mode, setMode] = useState('time'); + const [startDate, setStartDate] = useState(); + const [startTime, setStartTime] = useState() + useEffect(() => { const onRequestReservasData = async () => { @@ -62,43 +65,54 @@ export default function AreaComun({navigation}){ const postReserva = async() => { - console.log(time); + // console.log(startDate.split('"')[1]); + // console.log(startTime.split('.')[0]); - // 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 + "time": startTime.split('.')[0], + "date": startDate.split('"')[1], + "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) => { + + // console.log(selectedDate); + + const dateString = JSON.stringify(selectedDate).toString().split("T") + + setStartDate(dateString[0]) + setStartTime(dateString[1]) + + console.log(dateString); + + // console.log(Date.toString(selectedDate)); const currentDate = selectedDate || time; setTime(currentDate); @@ -135,7 +149,7 @@ export default function AreaComun({navigation}){ Hora de inicio - + diff --git a/mobile-ui/components/Reservas.js b/mobile-ui/components/Reservas.js index 3177d762..e5cab394 100644 --- a/mobile-ui/components/Reservas.js +++ b/mobile-ui/components/Reservas.js @@ -18,8 +18,8 @@ export default function Reservas({navigation}) { const { user } = useContext(UserContext) const [isRequesting, setIsRequesting] = useState(false); const [reservas, setReservas] = useState([]); - // const id = user._id; - const id = "6301df20dac7dcf76dcecade"; + const id = user._id; + // const id = "6301df20dac7dcf76dcecade"; console.log(user); @@ -74,8 +74,8 @@ export default function Reservas({navigation}) { reservas.map(item => ( diff --git a/mobile-ui/components/ReservasCard/index.js b/mobile-ui/components/ReservasCard/index.js index 69dea5ec..d244c4ad 100644 --- a/mobile-ui/components/ReservasCard/index.js +++ b/mobile-ui/components/ReservasCard/index.js @@ -11,15 +11,14 @@ import PropTypes from 'prop-types'; import React from 'react'; -export const ReservasCard = ({ date, startTime, endTime, status, name}) => { - const dateFormated = format(new Date(date), "dd LL yyyy") +export const ReservasCard = ({ date, startTime, name}) => { + + + const dateFormated = date.toString().split("T")[0] - try { - - } catch (error) { - - } + + console.log(dateFormated); return ( @@ -43,7 +42,7 @@ export const ReservasCard = ({ date, startTime, endTime, status, name}) => { {name} @@ -64,8 +63,8 @@ export const ReservasCard = ({ date, startTime, endTime, status, name}) => { ) } -ReservasCard.propTypes = { - date: PropTypes.string.isRequired, - startTime: PropTypes.string.isRequired, - status: PropTypes.string.isRequired -} \ No newline at end of file +// ReservasCard.propTypes = { +// date: PropTypes.string.isRequired, +// startTime: PropTypes.string.isRequired, +// status: PropTypes.string.isRequired +// } \ No newline at end of file