import { commands } from "@/commands.gen"; import { Spinner, User } from "@/components"; import { Lock } from "@phosphor-icons/react"; import { createLazyFileRoute } from "@tanstack/react-router"; import { getCurrentWindow } from "@tauri-apps/api/window"; import { message } from "@tauri-apps/plugin-dialog"; import { useState, useTransition } from "react"; export const Route = createLazyFileRoute("/set-signer/$id")({ component: Screen, }); function Screen() { const { id } = Route.useParams(); const [password, setPassword] = useState(""); const [isPending, startTransition] = useTransition(); const unlock = () => { startTransition(async () => { if (!password.length) { await message("Password is required", { kind: "info" }); return; } const window = getCurrentWindow(); const res = await commands.setSigner(id, password); if (res.status === "ok") { await window.close(); } else { await message(res.error, { kind: "error" }); return; } }); }; return (
setPassword(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") unlock(); }} disabled={isPending} placeholder="Enter password to unlock" className="px-3 w-full rounded-lg h-10 text-center bg-transparent border border-black/10 dark:border-white/10 focus:border-blue-500 focus:outline-none placeholder:text-neutral-400" />
); }