import { useState } from "react" import { Pencil, Check, X, Cable } from "lucide-react" import type { GatewayInfo } from "@/types" import { useSaveGatewayConfig } from "@/services/api/hooks" /** Editable gateway routing + public-exposure settings (domain / public_domain / * tunnel / tls). Saves to wildpc.yaml; changes take effect on the next apply. */ export function GatewaySettings({ gateway }: { gateway: GatewayInfo }) { const { mutate: save, isPending, data: saved } = useSaveGatewayConfig() const [editing, setEditing] = useState(false) const [form, setForm] = useState({ tls: gateway.tls ?? "", domain: gateway.domain ?? "", public_domain: gateway.public_domain ?? "", tunnel_id: gateway.tunnel_id ?? "", }) const field = (k: keyof typeof form) => (e: React.ChangeEvent) => setForm((f) => ({ ...f, [k]: e.target.value })) const publicConfigured = !!gateway.public_domain && !!gateway.tunnel_id if (editing) { return (
Run wildpc apply (or the Apply button) to converge.
) } return (
TLS {gateway.tls ?? "off"} Domain {gateway.domain ?? "—"} Public {publicConfigured ? ( <> {gateway.public_domain} {gateway.tunnel_connected ? "● tunnel up" : "○ tunnel down"} ) : ( not configured )} {saved && {saved.message}}
) } const INPUT = "bg-black/30 border border-[var(--border)] rounded px-2 py-1 text-sm font-mono w-64 focus:outline-none focus:border-[var(--primary)]" function Row({ label, children }: { label: string; children: React.ReactNode }) { return ( ) }