"use client"; import { useActionState, useState } from "react"; import { FormField, Select } from "@unlocalhosted/metalui"; import type { FormState } from "@/app/actions/types"; import { BranchIcon, PencilIcon } from "@/components/icons"; import { TextareaField, TextField } from "@/components/settings-fields"; import { Alert, Button } from "@/components/ui"; /** Editing a pull request's title, description and (while it's open) the branch it merges into, behind an Edit button. */ export function EditPullForm({ action, title, body, base, branches, }: { action: (prev: FormState, formData: FormData) => Promise; title: string; body: string; base: string; /** Branches it could merge into instead; empty when the base can't change. */ branches: string[]; }) { const [open, setOpen] = useState(false); const [state, formAction, pending] = useActionState(async (prev: FormState, formData: FormData) => { const result = await action(prev, formData); if (result?.success) setOpen(false); return result; }, undefined); if (!open) { return ( ); } return (
{branches.length > 1 && ( Base branch