import { commands } from "@/commands.gen"; import { upload } from "@/commons"; import { Frame, GoBack, Spinner } from "@/components"; import { Plus } from "@phosphor-icons/react"; import { createLazyFileRoute } from "@tanstack/react-router"; import { message } from "@tauri-apps/plugin-dialog"; import { useState, useTransition } from "react"; export const Route = createLazyFileRoute("/auth/new")({ component: Screen, }); function Screen() { const navigate = Route.useNavigate(); const [password, setPassword] = useState(""); const [picture, setPicture] = useState(""); const [name, setName] = useState(""); const [about, setAbout] = useState(""); const [isPending, startTransition] = useTransition(); const uploadAvatar = async () => { const file = await upload(); if (file) { setPicture(file); } else { return; } }; const submit = () => { startTransition(async () => { if (!name.length) { await message("Please add your name", { title: "New Identity", kind: "info", }); return; } if (!password.length) { await message("You must set password to secure your account", { title: "New Identity", kind: "info", }); return; } const res = await commands.createAccount(name, picture, about, password); if (res.status === "ok") { navigate({ to: "/", replace: true, }); } else { await message(res.error, { title: "New Identity", kind: "error", }); return; } }); }; return (

New Identity

{picture.length ? ( avatar ) : null}
setName(e.target.value)} placeholder="e.g. Alice" spellCheck={false} className="px-3 rounded-lg h-10 bg-transparent border border-neutral-200 dark:border-neutral-500 focus:ring-0 focus:border-blue-500 focus:outline-none placeholder:text-neutral-400 dark:text-neutral-200" />