"use client"; import { useActionState, useId, useState } from "react"; import type { FormState } from "@/app/actions/types"; import { CommitDialog } from "./commit-dialog"; import { TrashIcon } from "./icons"; import { Box, Button, ButtonLink, RefChip } from "./ui"; /** * Deleting a file: the question on an alert-dialog plate (what is lost, Cancel, then the red cap that * names the action), which opens the commit dialog to record the deletion. */ export function DeleteFileForm({ action, branch, baseSha, path, cancelHref, }: { action: (prev: FormState, formData: FormData) => Promise; branch: string; baseSha: string; path: string; cancelHref: string; }) { const formId = useId(); const [state, formAction, pending] = useActionState(action, undefined); const [dialogOpen, setDialogOpen] = useState(false); const filename = path.split("/").pop(); return (

Delete {filename}?

{path} will be removed from {branch}. It stays in the history.

Cancel
); }