27 lines · 867 B
import { createFileRoute } from "@tanstack/react-router";
import { getPullCommits } from "~/fns/pulls";
import { usePull } from "~/hooks/use-pull";
import { CommitList } from "~/components/CommitList";
import { EmptyState } from "~/ui/EmptyState";
import { Panel } from "~/ui/Panel";

export const Route = createFileRoute("/$owner/$repo/pull/$number/commits")({
  loader: ({ params }) =>
    getPullCommits({ data: { owner: params.owner, repo: params.repo, number: Number(params.number) } }),
  component: PullCommits,
});

function PullCommits() {
  const commits = Route.useLoaderData();
  const { pull } = usePull();
  return (
    <Panel>
      {commits.length === 0 ? (
        <EmptyState title="No commits" icon="commit" />
      ) : (
        <CommitList owner={pull.headRepo.owner} repo={pull.headRepo.name} commits={commits} />
      )}
    </Panel>
  );
}