import React, { ReactElement } from 'react'
import BookingTable from '../../components/bookingTable'
import Layout from '../../components/layout'
import withAuth from '../../helpers/withAuth'

import { getServerSideRecentBookings } from '../../lib/getServerSideProps'

export const getServerSideProps = getServerSideRecentBookings

function AdminRecentBookings({ bookings }) {
  if (!bookings || !bookings.length) {
    return (
      <h3 className="text-lg leading-6 font-medium text-gray-900">
        No recent bookings 😿
      </h3>
    )
  }

  return (
    <>
      {bookings.map((booking: any) => (
        <BookingTable key={booking.uuid} booking={booking} />
      ))}
    </>
  )
}

export default withAuth(AdminRecentBookings)
