Components
Registry
Components
"use client";
import { useState } from "react";Installation#
pnpm dlx shadcn@latest add @repost/endpoint-formInstalls this item, every component it depends on, and the npm packages listed below.
Usage#
This component is presentational: it renders what you pass it and calls back on
interaction. In a live dashboard the data comes from useCreateEndpoint() / useUpdateEndpoint()
(@repost/portal-react), but any data of
the same shape works.
"use client";
import { useState } from "react";
import { EndpointForm, type EndpointFormValues } from "@/components/endpoint-form";
export function EndpointFormDemo() {
const [submitted, setSubmitted] = useState<EndpointFormValues | null>(null);
return (
<div className="mx-auto flex max-w-md flex-col gap-3">
<EndpointForm onSubmit={setSubmitted} submitLabel="Create endpoint" />
{submitted && (
<pre className="overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs">{JSON.stringify(submitted, null, 2)}</pre>
)}
</div>
);
}
Props#
| Prop | Type | Description |
|---|---|---|
initialValues | Partial<EndpointFormValues> | Prefill for editing. |
onSubmit | (values) => void | Called with validated values. |
isSubmitting | boolean | Disables the submit button. |
error | `string | null` |