import React, { useEffect } from "react"; import { useUser } from "../user-context"; import { signOut } from "@lingdocs/lingdocs-main"; const providers: ("google" | "twitter" | "github")[] = ["google", "twitter", "github"]; let popupRef: Window | null = null; function AccountPage() { const { user, pullUser } = useUser(); useEffect(() => { window.addEventListener("message", handleIncomingMessage); return () => { window.removeEventListener("message", handleIncomingMessage); }; // eslint-disable-next-line }, []); function handleOpenSignup() { popupRef = window.open("https://account.lingdocs.com", "account", "height=800,width=500,top=50,left=400"); } async function handleSignOut() { await signOut(); pullUser(); } function handleIncomingMessage(event: MessageEvent) { if (event.origin === "https://account.lingdocs.com" && event.data === "signed in" && popupRef) { pullUser(); popupRef.close(); } } return
{!user ?

Sign in to LingDocs

When you sign in or make a LingDocs account you can:

Save your progress on quizzes
:

Account

  • Name: {user.name}
  • {user.email &&
  • Email: {user.email}
  • }
  • Account Level: {user.level} {user.upgradeToStudentRequest === "waiting" ? "(Upgrade Requested)" : ""}
  • Signs in with: {(user.password && user.email) && Password } {providers.map((provider) => ( {user[provider] && } ))}

Account Admin

}
; } export default AccountPage;