generated from nhcarrigan/template
feat: add public player profile page
This commit is contained in:
@@ -2,6 +2,12 @@ import { useState } from "react";
|
||||
import { GameProvider } from "./context/GameContext.js";
|
||||
import { GameLayout } from "./components/game/GameLayout.js";
|
||||
import { LoginPage } from "./components/game/LoginPage.js";
|
||||
import { ProfilePage } from "./components/game/ProfilePage.js";
|
||||
|
||||
const getProfileDiscordId = (): string | null => {
|
||||
const match = /^\/profile\/(\d+)$/.exec(window.location.pathname);
|
||||
return match?.[1] ?? null;
|
||||
};
|
||||
|
||||
const handleAuthCallback = (): boolean => {
|
||||
if (window.location.pathname !== "/auth/callback") {
|
||||
@@ -27,6 +33,11 @@ const isAuthenticated = (): boolean => {
|
||||
export const App = (): React.JSX.Element => {
|
||||
const [loggedIn, setLoggedIn] = useState(isAuthenticated);
|
||||
|
||||
const profileDiscordId = getProfileDiscordId();
|
||||
if (profileDiscordId) {
|
||||
return <ProfilePage discordId={profileDiscordId} />;
|
||||
}
|
||||
|
||||
if (!loggedIn) {
|
||||
return <LoginPage onLogin={() => { setLoggedIn(true); }} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user