import { Banner, Button, InputArea, Popover, Radio } from "@refs/design-system"; import { CheckCircleIcon, XIcon } from "@refs/design-system/icons"; import { useEffect, useRef, useState } from "react"; import { useFetcher } from "react-router"; const VERDICTS = [ { value: "comment", label: "Comment", description: "Give feedback without a verdict." }, { value: "approve", label: "Approve", description: "Give feedback and approve the merge of this revision." }, { value: "request-changes", label: "Request changes", description: "Give feedback that must be addressed before the merge." }, ] as const; /** The Review button of a pull request. It opens a form for a summary and a verdict on the revision `revision`. */ export function FinishReview({ action, revision }: { action: string; revision: string }) { const [open, setOpen] = useState(false); const fetcher = useFetcher<{ error?: string | null }>(); const busy = fetcher.state !== "idle"; const sent = useRef(false); useEffect(() => { if (busy) sent.current = true; else if (sent.current) { sent.current = false; if (!fetcher.data?.error) setOpen(false); } }, [busy, fetcher.data]); return ( }> Review } />
Finish your review
{ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) event.currentTarget.form?.requestSubmit(); }} /> {VERDICTS.map((verdict) => ( ))} {fetcher.data?.error && }
); }