's'
This commit is contained in:
@@ -6,12 +6,39 @@ import { TopicEbookShowcase } from "./landing/TopicEbookShowcase";
|
||||
|
||||
type DashboardPageProps = {
|
||||
userName: string | null;
|
||||
userEmail?: string | null;
|
||||
};
|
||||
|
||||
export function DashboardPage({ userName }: DashboardPageProps) {
|
||||
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();
|
||||
|
||||
return (
|
||||
<>
|
||||
<WelcomeBlock userName={userName} />
|
||||
<WelcomeBlock
|
||||
userName={userName}
|
||||
userEmail={userEmail}
|
||||
bindingRequired={bindingRequired}
|
||||
/>
|
||||
<UnlockedStats />
|
||||
<TopicEbookShowcase />
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user