import React, { useState, useEffect } from "react"; import { TabView, TabPanel } from "primereact/tabview"; import UserProfile from "@/components/profile/UserProfile"; import UserContent from "@/components/profile/UserContent"; import UserSubscription from "@/components/profile/subscription/UserSubscription"; import { useRouter } from "next/router"; import { useSession } from "next-auth/react"; import { useIsAdmin } from "@/hooks/useIsAdmin"; import { ProgressSpinner } from "primereact/progressspinner"; //todo: Link below connect wallet, relays hidden in ... (open modal) const Profile = () => { const router = useRouter(); const { data: session, status } = useSession(); const [activeTab, setActiveTab] = useState(0); const {isAdmin, isLoading} = useIsAdmin(); const tabs = ["profile", "content", "subscribe"]; useEffect(() => { const { tab } = router.query; if (tab) { const index = tabs.indexOf(tab.toLowerCase()); if (index !== -1) { setActiveTab(index); } } }, [router.query]); useEffect(() => { if (status === 'unauthenticated') { router.push('/auth/signin'); } }, [status, router]); const onTabChange = (e) => { const newIndex = e.index; setActiveTab(newIndex); router.push(`/profile?tab=${tabs[newIndex]}`, undefined, { shallow: true }); }; if (status === 'loading' || isLoading) { return (