import type { FormEvent } from "react"; import { CheckCircle2, RefreshCcw, XCircle } from "lucide-react"; import type { GatewayCheckStatus } from "@/lib/gateway-form"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; type GatewayFormProps = { name: string; gatewayUrl: string; gatewayToken: string; workspaceRoot: string; gatewayUrlError: string | null; gatewayCheckStatus: GatewayCheckStatus; gatewayCheckMessage: string | null; errorMessage: string | null; isLoading: boolean; canSubmit: boolean; workspaceRootPlaceholder: string; cancelLabel: string; submitLabel: string; submitBusyLabel: string; onSubmit: (event: FormEvent) => void; onCancel: () => void; onRunGatewayCheck: () => Promise; onNameChange: (next: string) => void; onGatewayUrlChange: (next: string) => void; onGatewayTokenChange: (next: string) => void; onWorkspaceRootChange: (next: string) => void; }; export function GatewayForm({ name, gatewayUrl, gatewayToken, workspaceRoot, gatewayUrlError, gatewayCheckStatus, gatewayCheckMessage, errorMessage, isLoading, canSubmit, workspaceRootPlaceholder, cancelLabel, submitLabel, submitBusyLabel, onSubmit, onCancel, onRunGatewayCheck, onNameChange, onGatewayUrlChange, onGatewayTokenChange, onWorkspaceRootChange, }: GatewayFormProps) { return (
onNameChange(event.target.value)} placeholder="Primary gateway" disabled={isLoading} />
onGatewayUrlChange(event.target.value)} onBlur={onRunGatewayCheck} placeholder="ws://gateway:18789" disabled={isLoading} className={gatewayUrlError ? "border-red-500" : undefined} />
{gatewayUrlError ? (

{gatewayUrlError}

) : gatewayCheckMessage ? (

{gatewayCheckMessage}

) : null}
onGatewayTokenChange(event.target.value)} onBlur={onRunGatewayCheck} placeholder="Bearer token" disabled={isLoading} />
onWorkspaceRootChange(event.target.value)} placeholder={workspaceRootPlaceholder} disabled={isLoading} />
{errorMessage ? (

{errorMessage}

) : null}
); }