243 lines · 8.4 KB
import { SELECTED_SURFACE } from "~/ui/tones";
import { useState } from "react";
import {
  editDiscussionComment,
  markDiscussionAnswer,
  replyToDiscussion,
  toggleDiscussionVote,
} from "~/fns/discussions";
import { useAction } from "~/hooks/use-action";
import type { getDiscussion } from "~/fns/discussions";
import { MarkdownEditor } from "./MarkdownEditor";
import { ReactionBar } from "./ReactionBar";
import { Avatar } from "~/ui/Avatar";
import { Badge } from "~/ui/Badge";
import { Markdown } from "~/ui/Markdown";
import { RelativeTime } from "~/ui/RelativeTime";
import { Button } from "~/ui/Button";
import { cn } from "~/utils/cn";
import { ReportLink } from "./ReportLink";

type Data = Awaited<ReturnType<typeof getDiscussion>>;
type Thread = Data["threads"][number];
type Comment = Thread["replies"][number];
type Context = { owner: string; repo: string; number: number; signedIn: boolean };

export function UpvoteButton({
  context,
  subjectId,
  count,
  voted,
}: {
  context: Context;
  subjectId: string;
  count: number;
  voted: boolean;
}) {
  const vote = useAction(toggleDiscussionVote);
  return (
    <button
      type="button"