import { AvatarUploader } from "@/components/avatarUploader"; import { PlusIcon } from "@lume/icons"; import { NostrAccount } from "@lume/system"; import type { Metadata } from "@lume/types"; import { Spinner } from "@lume/ui"; import { createFileRoute, useNavigate } from "@tanstack/react-router"; import { useState } from "react"; import { useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; export const Route = createFileRoute("/auth/new/profile")({ component: Screen, loader: async () => { const account = await NostrAccount.createAccount(); return account; }, }); function Screen() { const account = Route.useLoaderData(); const navigate = useNavigate(); const { t } = useTranslation(); const { register, handleSubmit } = useForm(); const [picture, setPicture] = useState(""); const [loading, setLoading] = useState(false); const onSubmit = async (data: { name: string; about: string; website: string; }) => { setLoading(true); try { // Save account keys const save = await NostrAccount.saveAccount(account.nsec); // Then create profile if (save) { const profile: Metadata = { ...data, picture }; const eventId = await NostrAccount.createProfile(profile); if (eventId) { navigate({ to: "/auth/$account/backup", params: { account: account.npub }, replace: true, }); } } } catch (e) { setLoading(false); toast.error(String(e)); } }; return (

Let's set up your profile.

{picture ? ( avatar ) : null}