"use client"; import { useState } from "react"; import { WelcomeBlock } from "./dashboard/WelcomeBlock"; import { CommunityAccessModal } from "./dashboard/CommunityAccessModal"; import { UnlockedStats } from "./dashboard/UnlockedStats"; import { TopicEbookShowcase } from "./landing/TopicEbookShowcase"; type DashboardPageProps = { userName: string | null; userEmail?: string | null; }; function getStorage(key: string): string | null { if (typeof window === "undefined") return null; return localStorage.getItem(key); } function requiresEmailBinding(): boolean { const userId = getStorage("userId"); const emailLinked = getStorage("emailLinked") === "1"; const userEmail = getStorage("userEmail"); const userName = getStorage("userName"); return ( !!userId && /^user\d+$/.test(userId) && !emailLinked && !userEmail && !userName?.includes("@") ); } export function DashboardPage({ userName, userEmail }: DashboardPageProps) { const bindingRequired = requiresEmailBinding(); const [communityModalOpen, setCommunityModalOpen] = useState(false); return ( <> setCommunityModalOpen(true)} /> setCommunityModalOpen(false)} /> ); }