265 lines · 9.8 KB
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { useState } from "react";
import { z } from "zod";
import { getPullFiles } from "~/fns/pulls";
import { replyReviewComment, submitReview } from "~/fns/reviews";
import { commitSuggestions } from "~/fns/pull-review";
import { useAction } from "~/hooks/use-action";
import { useViewer } from "~/hooks/use-viewer";
import { usePull } from "~/hooks/use-pull";
import { useReviewDraft } from "~/hooks/use-review-draft";
import { usePullCodeAlerts } from "~/hooks/use-pull-code-alerts";
import type { PullCodeAlert } from "~/hooks/use-pull-code-alerts";
import { CodeAnnotation } from "~/components/security/CodeAnnotation";
import type { DraftComment } from "~/hooks/use-review-draft";
import { useSuggestionBatch } from "~/hooks/use-suggestion-batch";
import { DiffView } from "~/components/DiffView";
import type { LineAnchor } from "~/components/DiffView";
import { ReviewThread } from "~/components/ReviewThread";
import type { ReviewComment } from "~/components/ReviewThread";
import { ReviewComposer } from "~/components/ReviewComposer";
import { DiffRangePicker } from "~/components/DiffRangePicker";
import { MarkdownEditor } from "~/components/MarkdownEditor";
import { Panel } from "~/ui/Panel";
import { Button } from "~/ui/Button";
import { SelectField } from "~/ui/Field";
import { ErrorBanner } from "~/ui/Callout";
import { newSideLines } from "~/lib/patch-lines";

const filesSearch = z.object({
  commit: z.string().length(40).optional(),
  since: z.string().length(40).optional(),
});

export const Route = createFileRoute("/$owner/$repo/pull/$number/files")({
  validateSearch: filesSearch,
  loaderDeps: ({ search }) => search,
  loader: ({ params, deps }) =>
    getPullFiles({
      data: { owner: params.owner, repo: params.repo, number: Number(params.number), ...deps },
    }),