"use client"; import { useActionState, useRef } from "react"; import { Select } from "@unlocalhosted/metalui"; import type { FormState } from "@/app/actions/types"; import { BranchIcon, PlusIcon } from "@/components/icons"; import { TextField } from "@/components/settings-fields"; import { Alert, Box, Button } from "@/components/ui"; /** A new branch: its name, and the branch it starts from. */ export function NewBranchForm({ action, branches, from }: { action: (prev: FormState, formData: FormData) => Promise; branches: string[]; from: string }) { const form = useRef(null); const [state, formAction, pending] = useActionState(async (prev: FormState, formData: FormData) => { const result = await action(prev, formData); if (result?.success) form.current?.reset(); return result; }, undefined); return (
} />
From