import { listArticles } from "@/app/api/articles";
import { Fragment } from "react";
import styles from "./styles.module.scss";
import Link from "next/link";
import Pagination from "@/app/components/Pagination";

const Page = async ({
  params,
}: {
  params: {
    pageIndex: string;
  };
}) => {
  const data = await listArticles({
    cid: "3",
    pageNo: params.pageIndex,
    pageSize: 20,
  });
  return (
    <div>
      <h2 className={"text-[#0f6fca] text-sm"}>公告通知</h2>
      <ul className={`${styles.articles} mt-5`}>
        {data.lists.map((article, index) => (
          <li className={`${styles.article}`} key={article.id}>
            <Link
              className={"flex h-8 text-sm text-[#666666] items-center"}
              href={`/announcements/${article.id}`}
            >
              {article.title}
            </Link>
          </li>
        ))}
      </ul>
      <Pagination
        page={parseInt(params.pageIndex)}
        total={data.count}
        perPage={20}
      />
    </div>
  );
};

export default Page;
