import { Book } from '@/books/Book';
import Details from '@/books/Details';
import { NextPage } from 'next/dist/types';

async function getBook(id: string): Promise<Book> {
  const response = await fetch(`http://localhost:3001/books/${id}`);
  return response.json();
}

type Props = {
  params: Promise<{ id: string }>;
};

const BookDetailsPage: NextPage<Props> = async ({ params }) => {
  const { id } = await params;
  const book = getBook(id);
  return <Details book={book} />;
};

export default BookDetailsPage;
