import { getAllHotelData } from "@/lib/trpc/memoizedRequests"

import { RewardNightsTable } from "./Table"

import type { HotelData } from "./util"

export async function RewardNights() {
  const hotelData = await getAllHotelData()

  const rewardNightsData: HotelData[] = hotelData.map(({ url, hotel }) => ({
    url: url ?? "",
    name: hotel.name,
    city: hotel.address.city,
    country: hotel.address.country,
    rewardNight: hotel.rewardNight,
  }))

  return <RewardNightsTable hotelData={rewardNightsData} />
}
