.ts
TypeScript
(application/typescript)
// 1st-party
import type { ReactView } from "@ethicdevs/react-monolith";
// 3rd-party
import React from "react";
// generated via script[generate:prisma]
import type { Organization, Repository } from "@prisma/client";
// app
import type { CommonProps, RepositoryLog } from "../../types";
import { Layout, PageWrapper } from "../../components";

export interface RepositoryCommitsLogViewProps extends CommonProps {
  history: RepositoryLog[];
  parentOrg: Organization;
  repo: Repository;
}

const RepositoryCommitsLogView: ReactView<RepositoryCommitsLogViewProps> = ({
  commonProps,
  history,
  parentOrg,
  repo,
}) => {
  return (
    <Layout {...commonProps}>
      <PageWrapper>
        <h1>
          <a href={`/${parentOrg.slug}`}>
            {parentOrg.displayName || parentOrg.slug}
          </a>
          {" / "}
          <a href={`/${parentOrg.slug}/${repo.slug}`}>
            {repo.displayName || repo.slug}
          </a>
          {" / Commits"}
        </h1>
        <div style={{ width: "100%" }}>
          <ul>
            {history.map((log) => (
              <li key={log.tree}>
                <a
                  href={`/${parentOrg.slug}/${repo.slug}/commits/${log.commit}`}
                >
                  <strong>{log.author.name}</strong>
                  {" ∙ "}
                  <span>{log.subject}</span>
                  {" - "}
                  <span>
                    {log.abbreviated_commit}
                    {log.abbreviated_parent.trim() != ""
                      ? ` ∙ parent ${log.abbreviated_parent}`
                      : ""}
                  </span>
                  {" ∙ "}
                  <span>{new Date(log.author.date).toUTCString()}</span>
                </a>
              </li>
            ))}
          </ul>
        </div>
      </PageWrapper>
    </Layout>
  );
};

RepositoryCommitsLogView.displayName = "RepositoryCommitsLogView";
export default RepositoryCommitsLogView;