diff --git a/src/app/space/components/blocks/profile.tsx b/src/app/space/components/blocks/profile.tsx new file mode 100644 index 00000000..4ec091ad --- /dev/null +++ b/src/app/space/components/blocks/profile.tsx @@ -0,0 +1,107 @@ +import { ArrowLeftIcon } from "@shared/icons"; +import { Image } from "@shared/image"; +import { useActiveAccount } from "@stores/accounts"; +import { DEFAULT_AVATAR } from "@stores/constants"; +import { useProfile } from "@utils/hooks/useProfile"; +import { compactNumber } from "@utils/number"; +import { shortenKey } from "@utils/shortenKey"; +import useSWR from "swr"; + +const fetcher = (url: string) => fetch(url).then((r) => r.json()); + +export function ProfileBlock({ params }: { params: any }) { + const removeBlock = useActiveAccount((state: any) => state.removeBlock); + + const close = () => { + removeBlock(params.id, true); + }; + + const { user } = useProfile(params.pubkey); + const { data: userStats } = useSWR( + user ? `https://api.nostr.band/v0/stats/profile/${params.pubkey}` : null, + fetcher, + ); + + return ( +
+
+ +

{params.title}

+
+
+
+
+
+
+
+ {params.pubkey} +
+
+

+ {user?.display_name || user?.name || "Anon"} +

+
+ {user?.nip05 || shortenKey(params.pubkey)} +
+

+ {user?.bio || user.about} +

+
+ {!userStats ? ( +

Loading...

+ ) : ( +
+
+ + {userStats.stats[params.pubkey] + .followers_pubkey_count ?? 0} + + + Followers + +
+
+ + {userStats.stats[params.pubkey] + .pub_following_pubkey_count ?? 0} + + + Following + +
+
+ + {userStats.stats[params.pubkey].zaps_received + ? compactNumber.format( + userStats.stats[params.pubkey].zaps_received + .msats / 1000, + ) + : 0} + + + Zaps received + +
+
+ )} +
+
+
+
+
+
+ ); +} diff --git a/src/app/user/_default.page.tsx b/src/app/user/_default.page.tsx deleted file mode 100644 index e4596971..00000000 --- a/src/app/user/_default.page.tsx +++ /dev/null @@ -1 +0,0 @@ -export { LayoutUser as Layout } from "./layout"; diff --git a/src/app/user/layout.tsx b/src/app/user/layout.tsx deleted file mode 100644 index 90a31e26..00000000 --- a/src/app/user/layout.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { MultiAccounts } from "@shared/multiAccounts"; -import { Navigation } from "@shared/navigation"; - -export function LayoutUser({ children }: { children: React.ReactNode }) { - return ( -
-
- - -
-
{children}
-
- ); -} diff --git a/src/app/user/pages/index.page.tsx b/src/app/user/pages/index.page.tsx deleted file mode 100644 index aec93a38..00000000 --- a/src/app/user/pages/index.page.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { usePageContext } from "@utils/hooks/usePageContext"; - -export function Page() { - const pageContext = usePageContext(); - const searchParams: any = pageContext.urlParsed.search; - const pubkey = searchParams.pubkey; - - return ( -
-

{pubkey}

-
- ); -} diff --git a/src/shared/user.tsx b/src/shared/user.tsx index 297cd5ae..9b6c45d1 100644 --- a/src/shared/user.tsx +++ b/src/shared/user.tsx @@ -65,27 +65,27 @@ export function User({ leaveFrom="opacity-100 translate-y-0" leaveTo="opacity-0 translate-y-1" > - -
-
+ +
+
{pubkey} -
-
-
+
+
+
{user?.displayName || user?.name || (
)}
- + {user?.nip05 || shortenKey(pubkey)}
-

+

{user?.about}

@@ -94,13 +94,13 @@ export function User({