From 3a59114683b26dc7e8e9db917d8b81a304971bee Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Fri, 28 Mar 2025 10:59:52 -0500 Subject: [PATCH] Consolidate profile and settings tabs, fix some styles --- src/components/MoreInfo.js | 8 ++-- src/components/navbar/Navbar.js | 9 ++-- .../profile/DataTables/UserRelaysTable.js | 6 +-- src/components/profile/UserProfile.js | 2 + src/components/profile/UserProfileCard.js | 24 ++++++++++ src/components/profile/UserSettings.js | 47 ------------------- .../profile/subscription/UserSubscription.js | 4 +- src/config/appConfig.js | 2 +- src/pages/about.js | 1 + src/pages/index.js | 2 - src/pages/profile.js | 10 +--- 11 files changed, 41 insertions(+), 74 deletions(-) delete mode 100644 src/components/profile/UserSettings.js diff --git a/src/components/MoreInfo.js b/src/components/MoreInfo.js index cb5aedf..b93eb98 100644 --- a/src/components/MoreInfo.js +++ b/src/components/MoreInfo.js @@ -3,7 +3,7 @@ import { Dialog } from 'primereact/dialog'; import { Tooltip } from 'primereact/tooltip'; import useWindowWidth from '@/hooks/useWindowWidth'; -const MoreInfo = ({ tooltip, modalTitle, modalBody, className = '' }) => { +const MoreInfo = ({ tooltip, modalTitle, modalBody, className = '', tooltipPosition = 'right' }) => { const [visible, setVisible] = useState(false); const windowWidth = useWindowWidth(); const isMobile = windowWidth < 768; @@ -14,11 +14,9 @@ const MoreInfo = ({ tooltip, modalTitle, modalBody, className = '' }) => { className={`pi pi-question-circle cursor-pointer ${className}`} onClick={() => setVisible(true)} data-pr-tooltip={tooltip} - data-pr-position="right" - data-pr-at="right+5 top" - data-pr-my="left center-2" + data-pr-position={tooltipPosition} /> - {!isMobile && } + {!isMobile && } { const router = useRouter(); const windowWidth = useWindowWidth(); const navbarHeight = '60px'; - const { ndk } = useNDKContext(); + const { data: session } = useSession(); const [isHovered, setIsHovered] = useState(false); const [showMobileSearch, setShowMobileSearch] = useState(false); const menu = useRef(null); @@ -47,7 +46,7 @@ const Navbar = () => { { label: 'Subscribe', icon: 'pi pi-star', - command: () => router.push('/about') + command: () => session?.user ? router.push('/profile?tab=subscribe') : router.push('/about') }, { label: 'About', @@ -62,7 +61,7 @@ const Navbar = () => {
{/* Left section */}
-
router.push('/')} className="flex flex-row items-center justify-center cursor-pointer"> +
router.push('/')} className="flex flex-row items-center justify-center cursor-pointer hover:opacity-80"> logo
-

Relays

Manage your connected relays

className="flex-1" /> }; return ( -
+
{ const windowWidth = useWindowWidth(); @@ -42,6 +43,7 @@ const UserProfile = () => {
{user && } + {user && }
diff --git a/src/components/profile/UserProfileCard.js b/src/components/profile/UserProfileCard.js index af37210..4ace6bd 100644 --- a/src/components/profile/UserProfileCard.js +++ b/src/components/profile/UserProfileCard.js @@ -2,19 +2,24 @@ import React, { useRef, useState } from 'react'; import Image from 'next/image'; import { Menu } from 'primereact/menu'; import { Tooltip } from 'primereact/tooltip'; +import { Dialog } from 'primereact/dialog'; import { nip19 } from 'nostr-tools'; import { useImageProxy } from '@/hooks/useImageProxy'; import { useToast } from '@/hooks/useToast'; import UserBadges from '@/components/profile/UserBadges'; import useWindowWidth from '@/hooks/useWindowWidth'; import MoreInfo from '@/components/MoreInfo'; +import UserRelaysTable from '@/components/profile/DataTables/UserRelaysTable'; +import { useNDKContext } from "@/context/NDKContext"; const UserProfileCard = ({ user }) => { const [showBadges, setShowBadges] = useState(false); + const [showRelaysModal, setShowRelaysModal] = useState(false); const menu = useRef(null); const { showToast } = useToast(); const { returnImageProxy } = useImageProxy(); const windowWidth = useWindowWidth(); + const { ndk, userRelays, setUserRelays, reInitializeNDK } = useNDKContext(); const copyToClipboard = (text) => { navigator.clipboard.writeText(text); @@ -43,6 +48,11 @@ const UserProfileCard = ({ user }) => { label: 'Open Nostr Profile', icon: 'pi pi-external-link', command: () => window.open(`https://nostr.com/${nip19.npubEncode(user?.pubkey)}`, '_blank') + }, + { + label: 'Manage Relays', + icon: 'pi pi-server', + command: () => setShowRelaysModal(true) } ]; @@ -282,6 +292,20 @@ const UserProfileCard = ({ user }) => { visible={showBadges} onHide={() => setShowBadges(false)} /> + setShowRelaysModal(false)} + header="Manage Relays" + className="w-[90vw] max-w-[800px]" + modal + > + + ); }; diff --git a/src/components/profile/UserSettings.js b/src/components/profile/UserSettings.js deleted file mode 100644 index afb3f05..0000000 --- a/src/components/profile/UserSettings.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { useState, useEffect } from "react"; -import UserProfileCard from "@/components/profile/UserProfileCard"; -import { useSession } from 'next-auth/react'; -import { useNDKContext } from "@/context/NDKContext"; -import useWindowWidth from "@/hooks/useWindowWidth"; -import UserRelaysTable from "@/components/profile/DataTables/UserRelaysTable"; -import UserAccountLinking from "@/components/profile/UserAccountLinking"; -const UserSettings = () => { - const [user, setUser] = useState(null); - const { ndk, userRelays, setUserRelays, reInitializeNDK } = useNDKContext(); - const { data: session } = useSession(); - const windowWidth = useWindowWidth(); - - useEffect(() => { - if (session?.user) { - setUser(session.user); - } - }, [session]); - - return ( - user && ( -
- {windowWidth < 768 && ( -

Settings

- )} -
-
- - - {user && } -
- -
- -
-
-
- ) - ); -}; - -export default UserSettings; diff --git a/src/components/profile/subscription/UserSubscription.js b/src/components/profile/subscription/UserSubscription.js index 4d41c02..59358f8 100644 --- a/src/components/profile/subscription/UserSubscription.js +++ b/src/components/profile/subscription/UserSubscription.js @@ -117,7 +117,7 @@ const UserSubscription = () => { {!subscribed && ( { )} - +

How does the subscription work?

diff --git a/src/config/appConfig.js b/src/config/appConfig.js index 784cb30..98cefb8 100644 --- a/src/config/appConfig.js +++ b/src/config/appConfig.js @@ -9,7 +9,7 @@ const appConfig = { "wss://purplerelay.com/", "wss://relay.devs.tools/" ], - authorPubkeys: ["f33c8a9617cb15f705fc70cd461cfd6eaf22f9e24c33eabad981648e5ec6f741", "c67cd3e1a83daa56cff16f635db2fdb9ed9619300298d4701a58e68e84098345"], + authorPubkeys: ["f33c8a9617cb15f705fc70cd461cfd6eaf22f9e24c33eabad981648e5ec6f741", "c67cd3e1a83daa56cff16f635db2fdb9ed9619300298d4701a58e68e84098345", "6260f29fa75c91aaa292f082e5e87b438d2ab4fdf96af398567b01802ee2fcd4"], customLightningAddresses: [ { // todo remove need for lowercase diff --git a/src/pages/about.js b/src/pages/about.js index 5e7bd51..bf47495 100644 --- a/src/pages/about.js +++ b/src/pages/about.js @@ -211,6 +211,7 @@ const AboutPage = () => {

Subscribe to PlebDevs

filteredContent, [filteredContent]); - useEffect(() => { if (documents && !documentsLoading) { const processedDocuments = documents.map(document => ({...parseEvent(document), type: 'document'})); diff --git a/src/pages/profile.js b/src/pages/profile.js index 6edafa2..935f457 100644 --- a/src/pages/profile.js +++ b/src/pages/profile.js @@ -1,7 +1,6 @@ import React, { useState, useEffect } from "react"; import { TabView, TabPanel } from "primereact/tabview"; import UserProfile from "@/components/profile/UserProfile"; -import UserSettings from "@/components/profile/UserSettings"; import UserContent from "@/components/profile/UserContent"; import UserSubscription from "@/components/profile/subscription/UserSubscription"; import { useRouter } from "next/router"; @@ -16,7 +15,7 @@ const Profile = () => { const [activeTab, setActiveTab] = useState(0); const {isAdmin, isLoading} = useIsAdmin(); - const tabs = ["profile", "settings", "content", "subscribe"]; + const tabs = ["profile", "content", "subscribe"]; useEffect(() => { const { tab } = router.query; @@ -74,13 +73,6 @@ const Profile = () => { }}> - - - {isAdmin && (