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 (

Reset password

setKey(e.target.value)} className="pl-3 pr-12 rounded-lg w-full h-10 bg-transparent border border-neutral-200 dark:border-neutral-500 focus:border-blue-500 focus:outline-none placeholder:text-neutral-400 dark:placeholder:text-neutral-600" />
setPassword(e.target.value)} className="px-3 rounded-lg h-10 bg-transparent border border-neutral-200 dark:border-neutral-500 focus:border-blue-500 focus:outline-none" />
Go back to previous screen
); }