From 57b098efd90b72c854582de9d7dafdc40506d5a9 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 9 Mar 2021 18:28:04 +0100 Subject: user page :tada: --- pages/account.tsx | 112 ------------------------------------------- pages/search.tsx | 2 +- pages/user.tsx | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 113 deletions(-) delete mode 100644 pages/account.tsx create mode 100644 pages/user.tsx (limited to 'pages') diff --git a/pages/account.tsx b/pages/account.tsx deleted file mode 100644 index 82e21fa..0000000 --- a/pages/account.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import { ReactNode, Children } from 'react'; -import Icon from '@mdi/react'; - -import { NavBar } from '../components/navbar'; -import { CenteredPage, PageTitle } from '../components/page'; -import { Vierkant, IconLabelButton } from '../components/ui'; -import { AccountAvatar } from '../components/account'; -import RecentGames from '../components/recentGames'; - -import PersonAddOutlinedIcon from '@material-ui/icons/PersonAddOutlined'; -import AssignmentIndOutlinedIcon from '@material-ui/icons/AssignmentIndOutlined'; -import ArrowDownwardOutlinedIcon from '@material-ui/icons/ArrowDownwardOutlined'; -import ArrowUpwardOutlinedIcon from '@material-ui/icons/ArrowUpwardOutlined'; -import PeopleOutlineOutlinedIcon from '@material-ui/icons/PeopleOutlineOutlined'; -import { - mdiAccountCancelOutline, - mdiEqual, - mdiCheckboxBlankCircle, - mdiClipboardTextOutline, - mdiGamepadSquareOutline, - mdiEarth } from '@mdi/js'; - -function InfoModule(props: { - label: string; - icon: ReactNode; -}) { - return
-
{props.icon}
-
- {props.label} -
-
-} - -function InfoSection(props: { children: ReactNode }) { - return -
- {props.children} -
-
-} - -export default function AccountPage() { - return
- - - Profiel - - -
-

Gebruikersnaam

-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et -

-
-
- } text="Vriendschapsverzoek"/> - } text="Blokkeren"/> -
-
- - } label="Online"/> - } label="Lid sinds 14 december 2020"/> - } label="2 vrienden"/> - } label="Nederland"/> - - - } label="4 keer gewonnen"/> - } label="2 keer gelijkspel"/> - } label="2 keer verloren"/> - } label="Score: 400"/> - } label="6 potjes"/> - - - - -
-
-} - diff --git a/pages/search.tsx b/pages/search.tsx index 52dfed5..963fcba 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -32,7 +32,7 @@ function SearchResults(props: { userList: Array }) { function SearchResult(props: { user: userInfo }) { return + }} fullwidth href={`/user?id=${props.user.id}`}>
+
{props.icon}
+
+ {props.label} +
+
+} + +function InfoSection(props: { children: ReactNode }) { + return +
+ {props.children} +
+
+} + +export default function AccountPage() { + var [gotData, setGotData] = useState(false); + var [user, setUser] = useState(); + + typeof window !== "undefined" && console.log(new URLSearchParams(window.location.search).get("id")) + useEffect(() => { + if (gotData) return; + if (typeof window === "undefined") return; + + var id = new URLSearchParams(window.location.search).get("id"); + var loggedIn = document.cookie.includes("token"); + + if (id || loggedIn) { + axios.request({ + method: id ? "post" : "get", + url: `/api/user/info`, + headers: {"content-type": "application/json"}, + data: id ? { id } : undefined + }) + .then(request => setUser(request.data)) + .catch(() => {}); + } else { + window.history.go(-1); + } + + setGotData(true); + }) + + return
+ + + Profiel + + +
+

{user?.username}

+

{user?.status}

+
+
+ } text="Vriendschapsverzoek"/> + } text="Blokkeren"/> +
+
+ + } label="Online"/> + } label="Lid sinds 14 december 2020"/> + } label="2 vrienden"/> + } label="Nederland"/> + + + } label="4 keer gewonnen"/> + } label="2 keer gelijkspel"/> + } label="2 keer verloren"/> + } label="Score: 400"/> + } label="6 potjes"/> + + + + +
+
+} + -- cgit v1.2.3