post de reservas

This commit is contained in:
Maria Sanchez 2022-08-23 18:43:50 -06:00
parent d8be6c02a0
commit ff1af19613
2 changed files with 23 additions and 24 deletions

View File

@ -19,10 +19,8 @@ export default function AreaComun({navigation}){
const [service, setService] = useState(""); const [service, setService] = useState("");
const [areas, setAreas] = useState([]) const [areas, setAreas] = useState([])
const [isRequesting, setIsRequesting] = useState(false); const [isRequesting, setIsRequesting] = useState(false);
const [selectedHours, setSelectedHours] = useState(0); const [selectedHours, setSelectedHours] = useState(0);
const [selectedMinutes, setSelectedMinutes] = useState(0); const [selectedMinutes, setSelectedMinutes] = useState(0);
const [endSelectedHours, setEndSelectedHours] = useState(0); const [endSelectedHours, setEndSelectedHours] = useState(0);
const [endSelectedMinutes, setEndSelectedMinutes] = useState(0); const [endSelectedMinutes, setEndSelectedMinutes] = useState(0);
const date = new Date(); const date = new Date();
@ -68,34 +66,35 @@ export default function AreaComun({navigation}){
const data = { const data = {
"start_time": Number.parseInt(selectedHours) + ":" +selectedMinutes, "start_time": 7 + ":" +0,
"finish_time": endSelectedHours + ":" +endSelectedMinutes, "finish_time": 10 + ":" +0,
"status": 1,
"date_entry": date, "date_entry": date,
"user_id" : user._id, "user_id" : user._id,
"common_area_id": service, "common_area_id": service._id,
"common_area_name": "", "common_area_name": service.name,
"community_id": "" "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 jsonResponse.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);
// } }
} }
@ -124,7 +123,7 @@ export default function AreaComun({navigation}){
}} mt={1} onValueChange={itemValue => setService(itemValue)}> }} mt={1} onValueChange={itemValue => setService(itemValue)}>
{areas.map(item => ( {areas.map(item => (
<Select.Item label={item.name} value={item.community_id} /> <Select.Item key={item._id} label={item.name} value={item} />
))} ))}
</Select> </Select>

View File

@ -38,10 +38,10 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => {
<Stack p="4" space={3}> <Stack p="4" space={3}>
<Stack space={2}> <Stack space={2}>
<Badge backgroundColor={status === 1 ? 'tertiary.500' : 'danger.600'} _text={{ <Badge backgroundColor={status == 1 ? 'tertiary.500' : 'danger.600'} _text={{
color: "white" color: "white"
}} variant="solid" rounded="4"> }} variant="solid" rounded="4">
<Text bold={true} color='danger.50'> {status === 1 ? 'LIBRE' : 'RESERVADO'}</Text> <Text bold={true} color='danger.50'> {status == 1 ? 'LIBRE' : 'RESERVADO'}</Text>
</Badge> </Badge>
<Heading size="md" ml="-1"> <Heading size="md" ml="-1">
Reserva #1 Reserva #1