import { commands } from "@/commands.gen"; import { Frame, GoBack } from "@/components"; import { Spinner } from "@/components/spinner"; import { createLazyFileRoute } from "@tanstack/react-router"; import { readText } from "@tauri-apps/plugin-clipboard-manager"; import { message } from "@tauri-apps/plugin-dialog"; import { useState, useTransition } from "react"; export const Route = createLazyFileRoute("/new-account/watch")({ component: Screen, }); function Screen() { const navigate = Route.useNavigate(); const [key, setKey] = useState(""); const [isPending, startTransition] = useTransition(); const pasteFromClipboard = async () => { const val = await readText(); setKey(val); }; const submit = () => { startTransition(async () => { if (!key.startsWith("npub") && !key.startsWith("nprofile")) { await message( "You need to enter a valid public key starts with npub or nprofile", { kind: "info" }, ); return; } const res = await commands.watchAccount(key); if (res.status === "ok") { navigate({ to: "/", replace: true }); } else { await message(res.error, { kind: "error", }); return; } }); }; return (