get hour picker on reservation

This commit is contained in:
Maria Sanchez 2022-08-23 00:21:25 -06:00
parent f9e2626e53
commit 98ef5dab17
2 changed files with 40 additions and 5 deletions

View File

@ -29,6 +29,8 @@ export default function AreaComun({navigation}){
const onRequestReservasData = async () => { const onRequestReservasData = async () => {
setIsRequesting(true); setIsRequesting(true);
try { try {
const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/allCommonAreas`, { const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/allCommonAreas`, {
@ -56,6 +58,39 @@ export default function AreaComun({navigation}){
}, [user]) }, [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);
// }
}
@ -83,14 +118,14 @@ 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.name} /> <Select.Item label={item.name} value={item.community_id} />
))} ))}
</Select> </Select>
</FormControl> </FormControl>
<FormControl isRequired> <FormControl isRequired>
<FormControl.Label>Hora de inicio</FormControl.Label> <FormControl.Label>Hora de inicio</FormControl.Label>
<View height="80" > <View >
<TimePicker <TimePicker
selectedHours={selectedHours} selectedHours={selectedHours}
selectedMinutes={selectedMinutes} selectedMinutes={selectedMinutes}
@ -102,7 +137,7 @@ export default function AreaComun({navigation}){
</FormControl> </FormControl>
<FormControl isRequired> <FormControl isRequired>
<FormControl.Label>Hora de finalización</FormControl.Label> <FormControl.Label>Hora de finalización</FormControl.Label>
<View height="80" > <View >
<TimePicker <TimePicker
selectedHours={selectedHours} selectedHours={selectedHours}
//initial Hourse value //initial Hourse value
@ -117,7 +152,7 @@ export default function AreaComun({navigation}){
</FormControl> </FormControl>
<Button mt="2" backgroundColor="tertiary.600"> <Button mt="2" backgroundColor="tertiary.600" onPress={()=> postReserva()}>
Reservar Reservar
</Button> </Button>
<Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Comunicados')}> <Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Comunicados')}>

View File

@ -28,7 +28,7 @@ export default function Invitados({navigation}) {
}) })
const response = await jsonResponse.json(); const response = await jsonResponse.json();
console.log(response); //console.log(response);
setInvitados(response.message); setInvitados(response.message);
} catch (error) { } catch (error) {