From 8a928132112d996ed5d0589a096a85455c263a90 Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Sat, 1 Jul 2023 15:18:21 +0700 Subject: [PATCH] fix errors --- src/app/auth/components/user.tsx | 64 +++++----- src/app/auth/create/step-2.tsx | 132 +++++++++++++-------- src/app/auth/create/step-4.tsx | 64 ++++++---- src/app/auth/import/step-2.tsx | 4 +- src/app/space/components/blocks/thread.tsx | 9 +- src/shared/avatarUploader.tsx | 2 +- src/shared/bannerUploader.tsx | 2 +- src/shared/notes/replies/form.tsx | 18 +-- src/utils/hooks/useProfile.tsx | 14 ++- 9 files changed, 186 insertions(+), 123 deletions(-) diff --git a/src/app/auth/components/user.tsx b/src/app/auth/components/user.tsx index 58af589b..629e290a 100644 --- a/src/app/auth/components/user.tsx +++ b/src/app/auth/components/user.tsx @@ -3,40 +3,42 @@ import { DEFAULT_AVATAR } from "@stores/constants"; import { useProfile } from "@utils/hooks/useProfile"; import { shortenKey } from "@utils/shortenKey"; -export function User({ pubkey }: { pubkey: string }) { - const { status, user } = useProfile(pubkey); +export function User({ + pubkey, + fallback, +}: { pubkey: string; fallback?: string }) { + const { status, user } = useProfile(pubkey, fallback); + + if (status === "loading") { + return ( +
+
+
+ + +
+
+ ); + } return (
- {status === "loading" ? ( - <> -
-
- - -
- - ) : ( - <> -
- {pubkey} -
-
- - {user.displayName || user.name} - - - {user.nip05?.toLowerCase() || shortenKey(pubkey)} - -
- - )} +
+ {pubkey} +
+
+ + {user.name || user.displayName || user.display_name} + + + {user.nip05?.toLowerCase() || shortenKey(pubkey)} + +
); } diff --git a/src/app/auth/create/step-2.tsx b/src/app/auth/create/step-2.tsx index 97e163d5..993d23ef 100644 --- a/src/app/auth/create/step-2.tsx +++ b/src/app/auth/create/step-2.tsx @@ -1,9 +1,10 @@ import { AvatarUploader } from "@shared/avatarUploader"; +import { BannerUploader } from "@shared/bannerUploader"; import { LoaderIcon } from "@shared/icons"; import { Image } from "@shared/image"; import { DEFAULT_AVATAR } from "@stores/constants"; import { useOnboarding } from "@stores/onboarding"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; @@ -11,32 +12,36 @@ export function CreateStep2Screen() { const navigate = useNavigate(); const createProfile = useOnboarding((state: any) => state.createProfile); - const [image, setImage] = useState(DEFAULT_AVATAR); + const [picture, setPicture] = useState(DEFAULT_AVATAR); + const [banner, setBanner] = useState(""); const [loading, setLoading] = useState(false); const { register, handleSubmit, - setValue, formState: { isDirty, isValid }, } = useForm(); const onSubmit = (data: any) => { setLoading(true); try { - const profile = { ...data, name: data.displayName }; + const profile = { + ...data, + username: data.name, + display_name: data.name, + bio: data.about, + }; createProfile(profile); - // redirect to step 3 - navigate("/auth/create/step-3"); + // redirect to next step + setTimeout( + () => navigate("/auth/create/step-3", { replace: true }), + 1200, + ); } catch { console.log("error"); } }; - useEffect(() => { - setValue("picture", image); - }, [setValue, image]); - return (
@@ -44,55 +49,84 @@ export function CreateStep2Screen() { Create your profile
-
-
+
+ -
- -
+ +
+
avatar -
- +
+ +
+
+
+
+ user's avatar +
+ +
-
- - -
-
- -