import type React from 'react';
import { List } from 'antd';
import dayjs from 'dayjs';

interface CommitInfo {
  id: string;
  message: string;
  author: string;
  date: string;
}

interface CommitListProps {
  commits: CommitInfo[];
}

const CommitList: React.FC<CommitListProps> = ({ commits }) => {
  return (
    <div className="size-full overflow-y-auto">
      <List
        dataSource={commits}
        renderItem={(commit) => (
          <List.Item>
            <List.Item.Meta
              title={commit.message}
              description={
                <>
                  <div>提交者: {commit.author}</div>
                  <div>
                    提交时间:{" "}
                    {dayjs(
                      new Date(Number.parseInt(commit.date) * 1000),
                    ).format("YYYY-MM-DD HH:mm")}
                  </div>
                  <div>提交ID: {commit.id}</div>
                </>
              }
            />
          </List.Item>
        )}
      />
    </div>
  );
};

export default CommitList;