"use client"; import { useActionState, useEffect, useRef } from "react"; import { Textarea } from "@unlocalhosted/metalui"; import type { FormState } from "@/app/actions/types"; import { CheckIcon, CommentIcon, XIcon } from "@/components/icons"; import { Alert, Button } from "@/components/ui"; /** * Answering a pull request: a comment on its conversation, or a review (approve, request changes) * of its latest commit, from one box. */ export function RespondForm({ action, canReview, }: { action: (prev: FormState, formData: FormData) => Promise; /** Push access, and not the viewer's own pull request. */ canReview: boolean; }) { const [state, formAction, pending] = useActionState(action, undefined); const form = useRef(null); useEffect(() => { if (state?.success) form.current?.reset(); }, [state]); return (