diff --git a/mobile-ui/App.js b/mobile-ui/App.js index a8888f4e..4c75a8bd 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -19,8 +19,6 @@ import AgregarInvitados from "./components/AgregarInvitados"; const Stack = createNativeStackNavigator(); const Tab = createBottomTabNavigator(); - - function HomeTab({ route }) { const { user } = useContext(UserContext); const [selected, setSelected] = useState(0); diff --git a/mobile-ui/components/Home.js b/mobile-ui/components/Home.js index aa14e849..52df0632 100644 --- a/mobile-ui/components/Home.js +++ b/mobile-ui/components/Home.js @@ -11,6 +11,8 @@ export default function Home() { useEffect(() => { + console.log(user); + const onRequestCommentsData = async () => { setIsRequesting(true); @@ -23,7 +25,7 @@ export default function Home() { }) const response = await jsonResponse.json(); - console.log(response); + // console.log(response); setComments(response.message); diff --git a/mobile-ui/components/Reservas.js b/mobile-ui/components/Reservas.js index 33722f08..f0d03817 100644 --- a/mobile-ui/components/Reservas.js +++ b/mobile-ui/components/Reservas.js @@ -1,97 +1,76 @@ -import React from "react"; +import React, {useContext, useEffect, useState} from "react"; import { - Text, - HStack, - AntDesign, - Heading, - Stack, Box, ScrollView, Fab, Icon } from "native-base"; -import logo from "../assets/logo-katoikia.png"; -import { Entypo } from '@expo/vector-icons'; +import { API } from "../environment/api"; import { MaterialCommunityIcons } from '@expo/vector-icons'; -import { View, TextInput, StyleSheet } from "react-native"; -const styles = StyleSheet.create({ - input: { - height: 40, - margin: 10, - borderWidth: 0.5, - padding: 5, - flex: 1, - paddingTop: 10, - paddingRight: 10, - paddingBottom: 10, - paddingLeft: 0, - marginTop: 50, - marginBottom: 10 - }, - - iconStyle: { - padding: 10, - }, - - viewSection: { - flex: 1, - flexDirection: 'row', - justifyContent: 'center', - alignItems: 'center', - margin: 10 - }, - - container: { - - } -}) +import { UserContext } from "../context/UserContext"; +import { ReservasCard } from "./ReservasCard"; export default function Reservas({navigation}) { + + const { user } = useContext(UserContext) + const [isRequesting, setIsRequesting] = useState(false); + const [reservas, setReservas] = useState([]); + + useEffect(() => { + + console.log("im in"); + + const onRequestReservasData = async () => { + setIsRequesting(true); + + try { + const jsonResponse = await fetch(`${API.BASE_URL}/reservation/allReservations`, { + method: "GET", + headers: { + 'Content-Type': 'application/json' + } + }) + + const response = await jsonResponse.json(); + console.log(response); + + setReservas(response.message); + + try { + + + } catch (error) { + console.log("ERROR:" + error); + } + + } catch (error) { + console.log("ERROR:" + error); + } + + setIsRequesting(false) + } + + onRequestReservasData() + + }, [user]) + + return ( - - - - - - - - Reserva #1 - - - horario de Reserva - - - - Descripcion - - - - - 6 mins ago - - - - - - + { + reservas.map(item => ( + + )) + } { + const dateFormated = format(new Date(date), "dd LL yyyy") + + + try { + + } catch (error) { + + } + + return ( + + + + + + + + + Reserva #1 + + + {dateFormated} + + + + Hora de inicio: {startTime} + + + Hora de finalizaciĆ³n: {endTime} + + + + + + + ) + +} +ReservasCard.propTypes = { + date: PropTypes.string.isRequired, + startTime: PropTypes.string.isRequired, + endTime: PropTypes.string.isRequired, + status: PropTypes.string.isRequired +} \ No newline at end of file