import { setTimeout } from 'node:timers/promises';

type Props = {
  bookId: string;
};

type Author = {
  name: string;
  biography: string;
  books: string[];
};

async function getAuthorDetails(bookId: string): Promise<Author> {
  await setTimeout(3_000);
  return {
    name: 'Philip Ackermann',
    biography: 'Experienced JavaScript and web development author',
    books: [bookId],
  };
}

const AuthorDetails: React.FC<Props> = async ({ bookId }) => {
  const author = await getAuthorDetails(bookId);
  return (
    <div>
      <h2>{author.name}</h2>
      <p>{author.biography}</p>
    </div>
  );
};

export default AuthorDetails;
