ConusAI vendor v0.1.0-dev.20261027+9b1131fb
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-dev.20261027+9b1131fb
2026-10-27 18:05:17 +00:00
commit 3102273ec7
538 changed files with 80203 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
"use client"
// Deleting a note, in two steps: the button asks, and a second press does it. The attached files are
// not deleted with the note (they are the project's); the confirmation says so.
import { type ProjectSlugs, useTransport } from "@conusai-kit/ui"
import { type ReactElement, useState } from "react"
export interface DeleteNoteLabels {
readonly button: string
readonly confirm: string
readonly yes: string
readonly no: string
readonly failed: string
}
export function DeleteNote({
slugs,
noteId,
listHref,
labels,
}: {
slugs: ProjectSlugs
noteId: string
/** Where to go once the note is gone. */
listHref: string
labels: DeleteNoteLabels
}): ReactElement {
const { call, describe } = useTransport()
const [state, setState] = useState<{ kind: "idle" | "asking" | "busy" } | { kind: "failed"; detail: string }>({
kind: "idle",
})
const remove = async (): Promise<void> => {
setState({ kind: "busy" })
try {
await call("notes.note.delete", { ...slugs, noteId })
window.location.assign(listHref)
} catch (error) {
setState({ kind: "failed", detail: describe(error) })
}
}
return (
<div>
{state.kind === "asking" || state.kind === "busy" ? (
<fieldset>
<legend>{labels.button}</legend>
<p>{labels.confirm}</p>
<button type="button" disabled={state.kind === "busy"} onClick={() => void remove()}>
{labels.yes}
</button>
<button type="button" disabled={state.kind === "busy"} onClick={() => setState({ kind: "idle" })}>
{labels.no}
</button>
</fieldset>
) : (
<button type="button" onClick={() => setState({ kind: "asking" })}>
{labels.button}
</button>
)}
{state.kind === "failed" ? (
<p className="app-error" role="alert">
{labels.failed.replace("{detail}", state.detail)}
</p>
) : null}
</div>
)
}