From 766a8ff1dbba53536ef46d88a838452d469ecb5d Mon Sep 17 00:00:00 2001 From: Atridad Lahiji <88056492+atridadl@users.noreply.github.com> Date: Mon, 5 Jun 2023 12:37:10 -0600 Subject: [PATCH] Quick style updates and dashboard tab selection memory --- README.md | 3 ++- next.config.mjs | 10 ---------- package.json | 2 +- src/components/RoomList.tsx | 8 ++++---- src/pages/_app.tsx | 6 +++++- src/pages/admin/index.tsx | 16 ++++++++-------- src/pages/dashboard/index.tsx | 19 +++++++++++++++---- src/pages/profile/index.tsx | 2 +- src/pages/room/[id].tsx | 2 +- 9 files changed, 37 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index e3aa4c0..6563460 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ A scrum poker tool that helps agile teams plan their sprints in real-time. ## Stack - Front-end framework: Nextjs -- Rendering method: SSR +- Front-end library: Preact +- Rendering method: SSR SPA - Hosting: Railway - Real-time pub/sub: Ably - ORM: Prisma diff --git a/next.config.mjs b/next.config.mjs index c2560d7..6b2de71 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,22 +1,12 @@ // @ts-check import withPWA from "next-pwa"; -/** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. - * This is especially useful for Docker builds. - */ !process.env.SKIP_ENV_VALIDATION && (await import("./src/env.mjs")); /** @type {import("next").NextConfig} */ const config = { reactStrictMode: true, - /** - * If you have the "experimental: { appDir: true }" setting enabled, then you - * must comment the below `i18n` config out. - * - * @see https://github.com/vercel/next.js/issues/41980 - */ i18n: { locales: ["en"], defaultLocale: "en", diff --git a/package.json b/package.json index a81db32..f979ddc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sprintpadawan", - "version": "1.1.3", + "version": "1.1.4", "description": "Plan. Sprint. Repeat.", "private": true, "scripts": { diff --git a/src/components/RoomList.tsx b/src/components/RoomList.tsx index 823b183..6856ef5 100644 --- a/src/components/RoomList.tsx +++ b/src/components/RoomList.tsx @@ -95,10 +95,10 @@ const RoomList: React.FC = () => { {roomsFromDb && roomsFromDb.length > 0 && (
- +
{/* head */} - + @@ -106,7 +106,7 @@ const RoomList: React.FC = () => { {roomsFromDb?.map((room) => { return ( - + @@ -138,7 +138,7 @@ const RoomList: React.FC = () => { {roomsFromDb === undefined && (
- +
)} diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index c9c08c6..c50632f 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -43,7 +43,11 @@ const MyApp: AppType<{ session: Session | null }> = ({
- {pageLoading ? : } + {pageLoading ? ( + + ) : ( + + )}
diff --git a/src/pages/admin/index.tsx b/src/pages/admin/index.tsx index 446a0f7..2635ee3 100644 --- a/src/pages/admin/index.tsx +++ b/src/pages/admin/index.tsx @@ -130,7 +130,7 @@ const AdminBody: React.FC = () => {
Users
{usersCountLoading || usersCountFetching ? ( - + ) : ( <>{usersCount ? usersCount : "0"} )} @@ -141,7 +141,7 @@ const AdminBody: React.FC = () => {
Rooms
{roomsCountLoading || roomsCountFetching ? ( - + ) : ( <>{roomsCount ? roomsCount : "0"} )} @@ -152,7 +152,7 @@ const AdminBody: React.FC = () => {
Votes
{votesCountLoading || votesCountFetching ? ( - + ) : ( <>{votesCount ? votesCount : "0"} )} @@ -176,13 +176,13 @@ const AdminBody: React.FC = () => {

Users:

{usersLoading || usersFetching ? ( - + ) : ( -
-
Room Name Actions
{room.roomName}
+
+
{/* head */} - + @@ -197,7 +197,7 @@ const AdminBody: React.FC = () => { ) .map((user) => { return ( - + diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index abce60d..823607f 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -4,7 +4,7 @@ import { useSession } from "next-auth/react"; import RoomList from "~/components/RoomList"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import Link from "next/link"; import { FaShieldAlt } from "react-icons/fa"; import { getServerAuthSession } from "~/server/auth"; @@ -47,7 +47,12 @@ export default Home; const HomePageBody: React.FC = () => { const { data: sessionData } = useSession(); const [joinRoomTextBox, setJoinRoomTextBox] = useState(""); - const [tabIndex, setTabIndex] = useState(0); + const [tabIndex, setTabIndex] = useState(); + + useEffect(() => { + const tabIndexLocal = localStorage.getItem(`dashboardTabIndex`); + setTabIndex(tabIndexLocal !== null ? Number(tabIndexLocal) : 0); + }, [tabIndex, sessionData]); return ( <> @@ -62,7 +67,10 @@ const HomePageBody: React.FC = () => { className={ tabIndex === 0 ? "tab no-underline tab-active" : "tab no-underline" } - onClick={() => setTabIndex(0)} + onClick={() => { + setTabIndex(0); + localStorage.setItem("dashboardTabIndex", "0"); + }} > Join a Room @@ -70,7 +78,10 @@ const HomePageBody: React.FC = () => { className={ tabIndex === 1 ? "tab no-underline tab-active" : "tab no-underline" } - onClick={() => setTabIndex(1)} + onClick={() => { + setTabIndex(1); + localStorage.setItem("dashboardTabIndex", "1"); + }} > Room List diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx index 5d5e90f..efd3249 100644 --- a/src/pages/profile/index.tsx +++ b/src/pages/profile/index.tsx @@ -128,7 +128,7 @@ const ProfileBody: React.FC = () => { {providersLoading ? (
- +
) : (
diff --git a/src/pages/room/[id].tsx b/src/pages/room/[id].tsx index 0edbd92..43ca4ce 100644 --- a/src/pages/room/[id].tsx +++ b/src/pages/room/[id].tsx @@ -260,7 +260,7 @@ const RoomBody: React.FC = () => { if (roomFromDb === undefined) { return (
- +
); // Room has been loaded
ID Name Created At
{user.id}