generated from nhcarrigan/template
feat: add race/class to character sheet, public /character/:id page
Players can now set their character's race and class in the Character tab. A new public page at /character/:id displays the full character sheet — name, pronouns, race, class, bio, and guild lore.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { GameProvider } from "./context/GameContext.js";
|
||||
import { CharacterPage } from "./components/game/CharacterPage.js";
|
||||
import { GameLayout } from "./components/game/GameLayout.js";
|
||||
import { LoginPage } from "./components/game/LoginPage.js";
|
||||
import { ProfilePage } from "./components/game/ProfilePage.js";
|
||||
@@ -9,6 +10,11 @@ const getProfileDiscordId = (): string | null => {
|
||||
return match?.[1] ?? null;
|
||||
};
|
||||
|
||||
const getCharacterDiscordId = (): string | null => {
|
||||
const match = /^\/character\/(\d+)$/.exec(window.location.pathname);
|
||||
return match?.[1] ?? null;
|
||||
};
|
||||
|
||||
const handleAuthCallback = (): boolean => {
|
||||
if (window.location.pathname !== "/auth/callback") {
|
||||
return false;
|
||||
@@ -38,6 +44,11 @@ export const App = (): React.JSX.Element => {
|
||||
return <ProfilePage discordId={profileDiscordId} />;
|
||||
}
|
||||
|
||||
const characterDiscordId = getCharacterDiscordId();
|
||||
if (characterDiscordId) {
|
||||
return <CharacterPage discordId={characterDiscordId} />;
|
||||
}
|
||||
|
||||
if (!loggedIn) {
|
||||
return <LoginPage onLogin={() => { setLoggedIn(true); }} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user