import { Handle } from "@atcute/lexicons"; import { createSignal, Show } from "solid-js"; import { resolveHandle } from "../../lib/api"; import { Button } from "../button.jsx"; import { TextInput } from "../text-input.jsx"; export const HandleInput = (props: { onInsert: (text: string) => void; onClose: () => void }) => { const [resolving, setResolving] = createSignal(false); const [error, setError] = createSignal(""); let handleFormRef!: HTMLFormElement; const resolveDid = async (e: SubmitEvent) => { e.preventDefault(); const formData = new FormData(handleFormRef); const handleValue = formData.get("handle")?.toString().trim(); if (!handleValue) { setError("Please enter a handle"); return; } setResolving(true); setError(""); try { const did = await resolveHandle(handleValue as Handle); props.onInsert(JSON.stringify(did)); props.onClose(); handleFormRef.reset(); } catch (err: any) { setError(err.message || "Failed to resolve handle"); } finally { setResolving(false); } }; return ( <>