From 639cece8f55e4304fb78a770209629818789af56 Mon Sep 17 00:00:00 2001 From: Aelita4 Date: Fri, 15 Nov 2024 22:53:09 +0100 Subject: [PATCH] Implement layout for logged user and cleanup styles --- src/components/Card.astro | 61 --- src/components/NavBar.astro | 5 +- src/components/ResourceBar.astro | 2 - src/env.d.ts | 9 + src/layouts/Layout.astro | 32 +- src/layouts/LoggedIn.astro | 34 ++ src/middleware.ts | 35 ++ src/pages/game/buildings.astro | 204 +++------- src/pages/game/fleet.astro | 358 ++++++------------ src/pages/game/galaxyView.astro | 126 +++--- src/pages/game/index.astro | 105 +---- src/pages/game/profile.astro | 166 ++------ src/pages/game/research.astro | 186 +++------ src/pages/game/ships.astro | 187 +++------ src/pages/game/systemManager/index.astro | 133 +++---- src/pages/game/systemManager/select.astro | 78 ++-- src/pages/game/systemManager/structures.astro | 157 ++++---- tsconfig.json | 8 +- 18 files changed, 625 insertions(+), 1261 deletions(-) delete mode 100644 src/components/Card.astro create mode 100644 src/layouts/LoggedIn.astro create mode 100644 src/middleware.ts diff --git a/src/components/Card.astro b/src/components/Card.astro deleted file mode 100644 index bd6d597..0000000 --- a/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/src/components/NavBar.astro b/src/components/NavBar.astro index 5ec9a2e..8faf30c 100644 --- a/src/components/NavBar.astro +++ b/src/components/NavBar.astro @@ -1,5 +1,6 @@ --- import { getHighestWeightedLanguage, getLocales, getName } from '../lib/utils/langDriver'; + interface Props { loggedIn: string; active: string; @@ -133,7 +134,6 @@ const bottomRow = filteredList.filter(element => element.position === "bottom"); const username = Astro.cookies.get('username')?.value ?? ""; --- - - - \ No newline at end of file diff --git a/src/pages/game/galaxyView.astro b/src/pages/game/galaxyView.astro index 13ca768..b31db4d 100644 --- a/src/pages/game/galaxyView.astro +++ b/src/pages/game/galaxyView.astro @@ -1,16 +1,6 @@ --- -import Layout from '../../layouts/Layout.astro'; -import NavBar from '../../components/NavBar.astro'; -import { getUserByAccessToken } from '../../lib/db/users'; +import LoggedIn from '../../layouts/LoggedIn.astro'; import locationManager from '../../lib/classes/managers/LocationManager'; -import ResourceBar from '../../components/ResourceBar.astro'; - -const loggedToken = Astro.cookies.get('sessionToken')?.value ?? null; -const username = Astro.cookies.get('username')?.value ?? ""; -if(loggedToken === null || username === "") return Astro.redirect('/logout'); - -const checkUser = await getUserByAccessToken(loggedToken); -if(checkUser === null || checkUser.username !== username) return Astro.redirect('/logout'); const allGalaxies = locationManager.galaxies; @@ -33,10 +23,7 @@ const galaxies = allGalaxies.map(galaxy => { }; }) --- - - - - +
{galaxies.map(galaxy => <> @@ -49,73 +36,70 @@ const galaxies = allGalaxies.map(galaxy => {

-
- -
+
-
- +