fix reservas create
This commit is contained in:
parent
e58ddbb4df
commit
90c4fc188e
|
@ -25,6 +25,9 @@ export default function AreaComun({navigation}){
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const [mode, setMode] = useState('time');
|
const [mode, setMode] = useState('time');
|
||||||
|
|
||||||
|
const [startDate, setStartDate] = useState();
|
||||||
|
const [startTime, setStartTime] = useState()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
const onRequestReservasData = async () => {
|
const onRequestReservasData = async () => {
|
||||||
|
@ -62,43 +65,54 @@ export default function AreaComun({navigation}){
|
||||||
|
|
||||||
const postReserva = async() => {
|
const postReserva = async() => {
|
||||||
|
|
||||||
console.log(time);
|
// console.log(startDate.split('"')[1]);
|
||||||
|
// console.log(startTime.split('.')[0]);
|
||||||
|
|
||||||
// const data = {
|
|
||||||
|
const data = {
|
||||||
|
|
||||||
// "start_time": 7 + ":" +0,
|
"time": startTime.split('.')[0],
|
||||||
// "finish_time": 10 + ":" +0,
|
"date": startDate.split('"')[1],
|
||||||
// "status": 1,
|
"user_id" : user._id,
|
||||||
// "date_entry": date,
|
"common_area_id": service._id,
|
||||||
// "user_id" : user._id,
|
"common_area_name": service.name,
|
||||||
// "common_area_id": service._id,
|
"community_id": service.community_id
|
||||||
// "common_area_name": service.name,
|
|
||||||
// "community_id": service.community_id
|
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
// console.log(data);
|
console.log(data);
|
||||||
// try {
|
try {
|
||||||
|
|
||||||
// const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, {
|
const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, {
|
||||||
// cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
// method: 'POST',
|
method: 'POST',
|
||||||
// body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
// headers: {
|
headers: {
|
||||||
// 'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
|
|
||||||
// const response = await jsonDataResponse.json();
|
const response = await jsonDataResponse.json();
|
||||||
// console.log(response.message);
|
console.log(response.message);
|
||||||
|
|
||||||
// } catch (error) {
|
} catch (error) {
|
||||||
// console.log("ERROR:" + error);
|
console.log("ERROR:" + error);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const onChangeStart = (event, selectedDate) => {
|
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;
|
const currentDate = selectedDate || time;
|
||||||
|
|
||||||
setTime(currentDate);
|
setTime(currentDate);
|
||||||
|
@ -135,7 +149,7 @@ export default function AreaComun({navigation}){
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormControl.Label>Hora de inicio</FormControl.Label>
|
<FormControl.Label>Hora de inicio</FormControl.Label>
|
||||||
<View >
|
<View >
|
||||||
<DateTimePicker minimumDate={date} mode="datetime" is24Hour value={time} onChangeStart={onChangeStart}/>
|
<DateTimePicker minimumDate={date} mode="datetime" is24Hour value={time} onChange={onChangeStart}/>
|
||||||
</View>
|
</View>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ export default function Reservas({navigation}) {
|
||||||
const { user } = useContext(UserContext)
|
const { user } = useContext(UserContext)
|
||||||
const [isRequesting, setIsRequesting] = useState(false);
|
const [isRequesting, setIsRequesting] = useState(false);
|
||||||
const [reservas, setReservas] = useState([]);
|
const [reservas, setReservas] = useState([]);
|
||||||
// const id = user._id;
|
const id = user._id;
|
||||||
const id = "6301df20dac7dcf76dcecade";
|
// const id = "6301df20dac7dcf76dcecade";
|
||||||
|
|
||||||
console.log(user);
|
console.log(user);
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ export default function Reservas({navigation}) {
|
||||||
reservas.map(item => (
|
reservas.map(item => (
|
||||||
<ReservasCard
|
<ReservasCard
|
||||||
key={item._id}
|
key={item._id}
|
||||||
date={item.date_entry}
|
date={item.date}
|
||||||
startTime={item.start_time}
|
startTime={item.time}
|
||||||
status={item.status}
|
status={item.status}
|
||||||
name={item.common_area_name}
|
name={item.common_area_name}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -11,15 +11,14 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const ReservasCard = ({ date, startTime, endTime, status, name}) => {
|
export const ReservasCard = ({ date, startTime, name}) => {
|
||||||
const dateFormated = format(new Date(date), "dd LL yyyy")
|
|
||||||
|
|
||||||
|
const dateFormated = date.toString().split("T")[0]
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
console.log(dateFormated);
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView showsVerticalScrollIndicator={false}>
|
<ScrollView showsVerticalScrollIndicator={false}>
|
||||||
|
@ -43,7 +42,7 @@ export const ReservasCard = ({ date, startTime, endTime, status, name}) => {
|
||||||
{name}
|
{name}
|
||||||
</Heading>
|
</Heading>
|
||||||
<Text fontSize="md" _light={{
|
<Text fontSize="md" _light={{
|
||||||
color: "success.600"
|
color: "amber.600"
|
||||||
}} _dark={{
|
}} _dark={{
|
||||||
color: "violet.400"
|
color: "violet.400"
|
||||||
}} fontWeight="500" ml="-0.5" mt="-1">
|
}} fontWeight="500" ml="-0.5" mt="-1">
|
||||||
|
@ -64,8 +63,8 @@ export const ReservasCard = ({ date, startTime, endTime, status, name}) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
ReservasCard.propTypes = {
|
// ReservasCard.propTypes = {
|
||||||
date: PropTypes.string.isRequired,
|
// date: PropTypes.string.isRequired,
|
||||||
startTime: PropTypes.string.isRequired,
|
// startTime: PropTypes.string.isRequired,
|
||||||
status: PropTypes.string.isRequired
|
// status: PropTypes.string.isRequired
|
||||||
}
|
// }
|
Loading…
Reference in New Issue