import { NostrAccount } from "@lume/system"; import { Spinner } from "@lume/ui"; import { createLazyFileRoute } from "@tanstack/react-router"; import { useState } from "react"; import { toast } from "sonner"; export const Route = createLazyFileRoute("/auth/privkey")({ component: Screen, }); function Screen() { const navigate = Route.useNavigate(); const [key, setKey] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); const submit = async () => { if (!key.startsWith("nsec1")) return toast.warning( "You need to enter a valid private key starts with nsec or ncryptsec", ); try { setLoading(true); const npub = await NostrAccount.saveAccount(key, password); if (npub) { navigate({ to: "/$account/home", params: { account: npub }, replace: true, }); } } catch (e) { setLoading(false); toast.error(e); } }; return (