import React, {useContext, useEffect, useState} from "react"; import { Box, ScrollView, Fab, Icon, Button, Heading } from "native-base"; import { API } from "../environment/api"; import { MaterialCommunityIcons } from '@expo/vector-icons'; 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([]); const id = user._id; //const id = "6301df20dac7dcf76dcecade"; useEffect(() => { const onRequestReservasData = async () => { setIsRequesting(true); try { const jsonResponse = await fetch(`${API.BASE_URL}/reservation/findReservationUser/`+`${id}`, { method: "GET", headers: { 'Content-Type': 'application/json' } }) const response = await jsonResponse.json(); console.log(response); setReservas(response.message); } catch (error) { console.log("ERROR:" + error); } setIsRequesting(false) } onRequestReservasData() }, [user]) return ( Lista de reservas { reservas.map(item => ( )) } ); }