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 { Link } from "@tanstack/react-router"; import { createFileRoute } from "@tanstack/react-router"; import { message } from "@tauri-apps/plugin-dialog"; import { useState } from "react"; import { useForm } from "react-hook-form"; export const Route = createFileRoute("/settings/user")({ beforeLoad: async () => { const profile = await NostrAccount.getProfile(); return { profile }; }, component: Screen, }); function Screen() { const { profile } = Route.useRouteContext(); const { register, handleSubmit } = useForm({ defaultValues: profile }); const [loading, setLoading] = useState(false); const [picture, setPicture] = useState(""); const onSubmit = async (data: Metadata) => { try { setLoading(true); const newProfile: Metadata = { ...profile, ...data, picture }; await NostrAccount.createProfile(newProfile); setLoading(false); } catch (e) { setLoading(false); await message(String(e), { title: "Profile", kind: "error" }); } }; return (
{profile.picture ? ( avatar ) : null}
{profile.display_name}
{profile.nip05}
Backup Account
); }