"use client"; import { useEffect, useState } from "react"; import dynamic from "next/dynamic"; import Image from "next/image"; import { Button } from "@/components/ui/button"; import { HiCheckBadge } from "react-icons/hi2"; import Tabs from "@/components/Tabs"; import useProfile from "@/lib/hooks/useProfile"; import { getTwoLetters, truncateText } from "@/lib/utils"; import ProfileFeed from "./_components/Feed"; import Subscriptions from "./_components/Subscriptions"; import { nip19 } from "nostr-tools"; import useLists from "@/lib/hooks/useLists"; import { useModal } from "@/app/_providers/modal/provider"; import useCurrentUser from "@/lib/hooks/useCurrentUser"; import { NDKUser } from "@nostr-dev-kit/ndk"; import MySubscription from "./_components/MySubscription"; import { getTagValues } from "@/lib/nostr/utils"; const EditProfileModal = dynamic( () => import("@/components/Modals/EditProfile"), { ssr: false, }, ); const CreateSubecriptionTierModal = dynamic( () => import("@/components/Modals/CreateSubscriptionTier"), { ssr: false, }, ); const FollowButton = dynamic(() => import("./_components/FollowButton"), { ssr: false, }); export default function ProfilePage({ params: { npub }, }: { params: { npub: string; }; }) { const modal = useModal(); const { currentUser, mySubscription, initSubscriptions } = useCurrentUser(); const [activeTab, setActiveTab] = useState("feed"); const { type, data } = nip19.decode(npub); const pubkey = data.toString(); // useEffect(() => { // initSubscriptions(pubkey); // }, []); if (type !== "npub") { throw new Error("Invalid list"); } const { profile } = useProfile(pubkey); return (
{!!profile?.banner && ( banner )}
{profile?.image ? ( profile picture ) : (
{getTwoLetters({ npub, profile, })}
)}
{currentUser?.pubkey === pubkey && !mySubscription && ( )} {currentUser?.pubkey === pubkey && ( )} {currentUser && }

{profile?.displayName ?? profile?.name ?? truncateText(npub)}

{!!profile?.nip05 && ( )}
{!!profile?.name &&

{profile.name}

} {!!profile?.name && !!profile.nip05 && ( <>
ยท

{profile.nip05}

)}
{!!profile?.about && (

{profile.about}

)}
setActiveTab(t.name)} />
{activeTab === "feed" ? : ""} {activeTab === "subscriptions" ? : ""}
); }