Currently I am fetching data, then I want to send this data to a component on the page to be rendered but it isn't displaying.
import {useSession} from "next-auth/react";
import getAllReservationsForIdentity from "@/lib/getAllReservationsForIdentity";
import ReservationBuyingPanel from "@/components/ReservationBuyingPanel";
export default function ReservationsPage ({ params }: { params: { identityId: string, string }}) {
const { data: session } = useSession();
let reservationData: Reservation[] = [];
let reservationSelling: Reservation[] = [];
let reservationBuying: Reservation[] = [];
const getReservationsData = async () => {
reservationData = await getAllReservationsForIdentity(session?.user.identityId, session?.user.backendToken);
splitReservationData();
console.log(reservationData);
console.log(reservationBuying)
console.log(reservationSelling)
}
function splitReservationData() {
reservationData.forEach((reservation => {
if (reservation.identity.identityId == session?.user.identityId) {
reservationBuying.push(reservation);
} else {
reservationSelling.push(reservation);
}
}))
}
getReservationsData();
return (
<>
<div className="px-16">
<div className="border-2 border-rtBlue px-4 py-4">
<div className="my-8 border-2 border-rtBlue">
<div className="py-4 px-4">
<ul className="grid xl:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 grid-cols-1 gap-10 my-10 px-10 w-full">
<ReservationBuyingPanel reservations={reservationBuying}/>
</ul>
</div>
</div>
</div>
</div>
</>
)
}```
Component:
type Props = {
reservations: Reservation[]
}
export default function ReservationBuyingPanel({ reservations }: Props ) {
const reservationsList = reservations;
const content = reservationsList.map(reservation => {
return (
<>
<div>Test</div>
<div>{reservation.reservationId}</div>
</>
)
})
return content;
}```