import { Button, Input } from "@refs/design-system"; import { PencilSimpleIcon } from "@refs/design-system/icons"; import { MAX_TITLE_LENGTH } from "@refs/backend/contract"; import { useState } from "react"; import { useFetcher } from "react-router"; import { useOnSuccess } from "./use-on-success"; /** The title of a task or pull request, with an editor that posts `intent=title` to the page's action. */ export function TitleEditor({ title, number, meta }: { title: string; number: number; meta: (edit: React.ReactNode) => React.ReactNode }) { const fetcher = useFetcher<{ error: string | null }>(); const [editing, setEditing] = useState(false); const saving = fetcher.state !== "idle"; useOnSuccess(fetcher, () => setEditing(false)); if (!editing) { return (
{fetcher.data.error}
}