import EssayTitleView from "@/components/EssayTitleView";
import { EssayAPIEssay } from "@/type/wwwAPI";
import Link from "next/link";
import ListGroup from "react-bootstrap/ListGroup";
import ListGroupItem from "react-bootstrap/ListGroupItem";

export default function ForumItem({
  forum: { forumID, title, essays },
}: {
  forum: {
    forumID: string;
    title: string;
    essays: EssayAPIEssay[];
  };
}) {
  return (
    <ListGroup>
      <ListGroupItem as={Link} href={`/forum/${forumID}`}>
        {title}
      </ListGroupItem>
      {essays.map((essay) => (
        <ListGroupItem key={essay.essayID}>
          <EssayTitleView forumID={forumID} essay={essay} />
        </ListGroupItem>
      ))}
    </ListGroup>
  );
}
