From 7a3e972149920078913cb044afaac9a600199908 Mon Sep 17 00:00:00 2001
From: lingdocs <71590811+lingdocs@users.noreply.github.com>
Date: Sat, 18 Sep 2021 20:08:06 -0400
Subject: [PATCH] allowing for signin
---
.eslintrc.json | 5 ++
src/App.tsx | 4 ++
src/components/Header.js | 11 +++-
src/components/Table.js | 2 +-
src/content/nouns/nouns-gender.mdx | 8 +--
src/pages/AccountPage.tsx | 86 ++++++++++++++++++++++++++++++
6 files changed, 111 insertions(+), 5 deletions(-)
create mode 100644 .eslintrc.json
create mode 100644 src/pages/AccountPage.tsx
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..1292f6f
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "rules": {
+ "jsx-a11y/accessible-emoji": "off"
+ }
+}
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 782c17d..598c66a 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -16,6 +16,7 @@ import { content } from "./content/index";
import Sidebar from "./components/Sidebar";
import Header from "./components/Header";
import TableOfContentsPage from "./pages/TableOfContentsPage";
+import AccountPage from "./pages/AccountPage";
import { useEffect } from "react";
import ReactGA from "react-ga";
@@ -65,6 +66,9 @@ function App(props: RouteComponentProps) {
{chapter}
))}
+
+
+
diff --git a/src/components/Header.js b/src/components/Header.js
index d039edc..cb37118 100644
--- a/src/components/Header.js
+++ b/src/components/Header.js
@@ -19,7 +19,16 @@ function Header({ setNavOpen }) {
{hamburger}
-
Pashto Grammar
+
+
+
Pashto Grammar
+
+
+
+
+
+
+
);
}
diff --git a/src/components/Table.js b/src/components/Table.js
index a5ae97f..bff9308 100644
--- a/src/components/Table.js
+++ b/src/components/Table.js
@@ -26,7 +26,7 @@ function Table({ headRow, children, opts, wide }) {
{row.map((cell, j) => (
{isObject(cell)
- ? (console.log(cell), {[cell]})
+ ? {[cell]}
: cell
}
|
diff --git a/src/content/nouns/nouns-gender.mdx b/src/content/nouns/nouns-gender.mdx
index 5610f8f..ff53826 100644
--- a/src/content/nouns/nouns-gender.mdx
+++ b/src/content/nouns/nouns-gender.mdx
@@ -14,8 +14,10 @@ import Link from "../../components/Link";
import words from "../../words/nouns-adjs";
export const femColor = genderColors.f;
export const mascColor = genderColors.m;
-import nounGenderGame1 from "../../games/games";
-import nounGenderGame2 from "../../games/games";
+import {
+ nounGenderGame1,
+ nounGenderGame2,
+} from "../../games/games";
import GameDisplay from "../../games/GameDisplay";
export const femEndingWConsonant = words.filter((w) => w.category === "consonant-fem");
@@ -166,4 +168,4 @@ Some words are used to describe people who obviously have a gender and they *tot
},
]} />
-
+
diff --git a/src/pages/AccountPage.tsx b/src/pages/AccountPage.tsx
new file mode 100644
index 0000000..2876dfe
--- /dev/null
+++ b/src/pages/AccountPage.tsx
@@ -0,0 +1,86 @@
+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 (🚧 not working yet 👷♂️)
+
+
+ :
+
+
Account
+
+
+ - Name: {user.name}
+ {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;
\ No newline at end of file