nomadro/apps/nomadvip/app/vip/components/DashboardPage.tsx
eric 56b29205e7 Integrate four verticals into nomadro portal with shared packages and API gateway.
Mount /vip with nomadvip+payjsapi, add @nomadro/pay|pb|sdk, apps/api, /admin shell, and backup/rollback scripts under git.nomadro.cn workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 20:16:44 -05:00

54 lines
1.5 KiB
TypeScript

"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 (
<>
<WelcomeBlock
userName={userName}
userEmail={userEmail}
bindingRequired={bindingRequired}
/>
<UnlockedStats />
<TopicEbookShowcase onCommunityCardClick={() => setCommunityModalOpen(true)} />
<CommunityAccessModal
open={communityModalOpen}
onClose={() => setCommunityModalOpen(false)}
/>
</>
);
}