import { Book } from '@/books/Book';
import data from '@/data/books.json';

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

const BookDetailPage = async ({
  params,
}: PageProps) => {
  const { id } = await params;

  const book = (data.books as Book[]).find((b) => b.id === parseInt(id, 10));

  if (!book) return <p>Not found</p>;

  return (
    <div>
      <h1>{book.title}</h1>
      <p>Author: {book.author}</p>
    </div>
  );
};

export default BookDetailPage;
