import { commands } from "@/commands.gen"; import { Frame, GoBack, Spinner } from "@/components"; 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("/reset")({ component: Screen, }); function Screen() { const navigate = Route.useNavigate(); const [key, setKey] = useState(""); const [password, setPassword] = useState(""); const [isPending, startTransition] = useTransition(); const pasteFromClipboard = async () => { const val = await readText(); setKey(val); }; const submit = () => { startTransition(async () => { if (!key.startsWith("nsec1")) { await message( "You need to enter a valid private key starts with nsec", { title: "Reset Password", kind: "info" }, ); return; } if (!password.length) { await message("You must set password to secure your key", { title: "Reset Password", kind: "info", }); return; } const res = await commands.resetPassword(key, password); if (res.status === "ok") { navigate({ to: "/", replace: true }); } else { await message(res.error, { title: "Import Private Ket", kind: "error", }); return; } }); }; return (