Quick style updates and dashboard tab selection memory

This commit is contained in:
Atridad Lahiji 2023-06-05 12:37:10 -06:00
parent 774fd8a464
commit 766a8ff1db
No known key found for this signature in database
9 changed files with 37 additions and 31 deletions

View file

@ -5,7 +5,8 @@ A scrum poker tool that helps agile teams plan their sprints in real-time.
## Stack ## Stack
- Front-end framework: Nextjs - Front-end framework: Nextjs
- Rendering method: SSR - Front-end library: Preact
- Rendering method: SSR SPA
- Hosting: Railway - Hosting: Railway
- Real-time pub/sub: Ably - Real-time pub/sub: Ably
- ORM: Prisma - ORM: Prisma

View file

@ -1,22 +1,12 @@
// @ts-check // @ts-check
import withPWA from "next-pwa"; 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")); !process.env.SKIP_ENV_VALIDATION && (await import("./src/env.mjs"));
/** @type {import("next").NextConfig} */ /** @type {import("next").NextConfig} */
const config = { const config = {
reactStrictMode: true, 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: { i18n: {
locales: ["en"], locales: ["en"],
defaultLocale: "en", defaultLocale: "en",

View file

@ -1,6 +1,6 @@
{ {
"name": "sprintpadawan", "name": "sprintpadawan",
"version": "1.1.3", "version": "1.1.4",
"description": "Plan. Sprint. Repeat.", "description": "Plan. Sprint. Repeat.",
"private": true, "private": true,
"scripts": { "scripts": {

View file

@ -95,10 +95,10 @@ const RoomList: React.FC = () => {
{roomsFromDb && roomsFromDb.length > 0 && ( {roomsFromDb && roomsFromDb.length > 0 && (
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-center break-all"> <table className="table text-center">
{/* head */} {/* head */}
<thead> <thead>
<tr> <tr className="border-white">
<th>Room Name</th> <th>Room Name</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
@ -106,7 +106,7 @@ const RoomList: React.FC = () => {
<tbody className=""> <tbody className="">
{roomsFromDb?.map((room) => { {roomsFromDb?.map((room) => {
return ( return (
<tr key={room.id}> <tr key={room.id} className="hover">
<td className="break-all max-w-[200px] md:max-w-[400px]"> <td className="break-all max-w-[200px] md:max-w-[400px]">
{room.roomName} {room.roomName}
</td> </td>
@ -138,7 +138,7 @@ const RoomList: React.FC = () => {
{roomsFromDb === undefined && ( {roomsFromDb === undefined && (
<div className="flex items-center justify-center"> <div className="flex items-center justify-center">
<Loading /> <span className="loading loading-spinner loading-lg"></span>
</div> </div>
)} )}
</div> </div>

View file

@ -43,7 +43,11 @@ const MyApp: AppType<{ session: Session | null }> = ({
<div className="block h-[100%]"> <div className="block h-[100%]">
<Navbar title="Sprint Padawan" /> <Navbar title="Sprint Padawan" />
<div className="flex flex-row items-center justify-center min-h-[calc(100%-114px)]"> <div className="flex flex-row items-center justify-center min-h-[calc(100%-114px)]">
{pageLoading ? <Loading /> : <Component {...pageProps} />} {pageLoading ? (
<span className="loading loading-spinner loading-lg"></span>
) : (
<Component {...pageProps} />
)}
</div> </div>
<Footer /> <Footer />
</div> </div>

View file

@ -130,7 +130,7 @@ const AdminBody: React.FC = () => {
<div className="stat-title">Users</div> <div className="stat-title">Users</div>
<div className="stat-value"> <div className="stat-value">
{usersCountLoading || usersCountFetching ? ( {usersCountLoading || usersCountFetching ? (
<Loading /> <span className="loading loading-spinner loading-lg"></span>
) : ( ) : (
<>{usersCount ? usersCount : "0"}</> <>{usersCount ? usersCount : "0"}</>
)} )}
@ -141,7 +141,7 @@ const AdminBody: React.FC = () => {
<div className="stat-title">Rooms</div> <div className="stat-title">Rooms</div>
<div className="stat-value"> <div className="stat-value">
{roomsCountLoading || roomsCountFetching ? ( {roomsCountLoading || roomsCountFetching ? (
<Loading /> <span className="loading loading-spinner loading-lg"></span>
) : ( ) : (
<>{roomsCount ? roomsCount : "0"}</> <>{roomsCount ? roomsCount : "0"}</>
)} )}
@ -152,7 +152,7 @@ const AdminBody: React.FC = () => {
<div className="stat-title">Votes</div> <div className="stat-title">Votes</div>
<div className="stat-value"> <div className="stat-value">
{votesCountLoading || votesCountFetching ? ( {votesCountLoading || votesCountFetching ? (
<Loading /> <span className="loading loading-spinner loading-lg"></span>
) : ( ) : (
<>{votesCount ? votesCount : "0"}</> <>{votesCount ? votesCount : "0"}</>
)} )}
@ -176,13 +176,13 @@ const AdminBody: React.FC = () => {
<h2 className="card-title">Users:</h2> <h2 className="card-title">Users:</h2>
{usersLoading || usersFetching ? ( {usersLoading || usersFetching ? (
<Loading /> <span className="loading loading-spinner loading-lg"></span>
) : ( ) : (
<div className="overflow-x-scroll w-[calc(80vw-4rem)]"> <div className="overflow-x-scroll">
<table className="w-full text-center"> <table className="table text-center">
{/* head */} {/* head */}
<thead> <thead>
<tr> <tr className="border-white">
<th>ID</th> <th>ID</th>
<th>Name</th> <th>Name</th>
<th>Created At</th> <th>Created At</th>
@ -197,7 +197,7 @@ const AdminBody: React.FC = () => {
) )
.map((user) => { .map((user) => {
return ( return (
<tr key={user.id}> <tr key={user.id} className="hover">
<td className="max-w-[100px] break-words"> <td className="max-w-[100px] break-words">
{user.id} {user.id}
</td> </td>

View file

@ -4,7 +4,7 @@ import { useSession } from "next-auth/react";
import RoomList from "~/components/RoomList"; import RoomList from "~/components/RoomList";
import { useState } from "react"; import { useEffect, useState } from "react";
import Link from "next/link"; import Link from "next/link";
import { FaShieldAlt } from "react-icons/fa"; import { FaShieldAlt } from "react-icons/fa";
import { getServerAuthSession } from "~/server/auth"; import { getServerAuthSession } from "~/server/auth";
@ -47,7 +47,12 @@ export default Home;
const HomePageBody: React.FC = () => { const HomePageBody: React.FC = () => {
const { data: sessionData } = useSession(); const { data: sessionData } = useSession();
const [joinRoomTextBox, setJoinRoomTextBox] = useState<string>(""); const [joinRoomTextBox, setJoinRoomTextBox] = useState<string>("");
const [tabIndex, setTabIndex] = useState<number>(0); const [tabIndex, setTabIndex] = useState<number>();
useEffect(() => {
const tabIndexLocal = localStorage.getItem(`dashboardTabIndex`);
setTabIndex(tabIndexLocal !== null ? Number(tabIndexLocal) : 0);
}, [tabIndex, sessionData]);
return ( return (
<> <>
@ -62,7 +67,10 @@ const HomePageBody: React.FC = () => {
className={ className={
tabIndex === 0 ? "tab no-underline tab-active" : "tab no-underline" tabIndex === 0 ? "tab no-underline tab-active" : "tab no-underline"
} }
onClick={() => setTabIndex(0)} onClick={() => {
setTabIndex(0);
localStorage.setItem("dashboardTabIndex", "0");
}}
> >
Join a Room Join a Room
</a> </a>
@ -70,7 +78,10 @@ const HomePageBody: React.FC = () => {
className={ className={
tabIndex === 1 ? "tab no-underline tab-active" : "tab no-underline" tabIndex === 1 ? "tab no-underline tab-active" : "tab no-underline"
} }
onClick={() => setTabIndex(1)} onClick={() => {
setTabIndex(1);
localStorage.setItem("dashboardTabIndex", "1");
}}
> >
Room List Room List
</a> </a>

View file

@ -128,7 +128,7 @@ const ProfileBody: React.FC = () => {
{providersLoading ? ( {providersLoading ? (
<div className="mx-auto"> <div className="mx-auto">
<Loading /> <span className="loading loading-spinner loading-lg"></span>
</div> </div>
) : ( ) : (
<div className="mx-auto"> <div className="mx-auto">

View file

@ -260,7 +260,7 @@ const RoomBody: React.FC = () => {
if (roomFromDb === undefined) { if (roomFromDb === undefined) {
return ( return (
<div className="flex flex-col items-center justify-center text-center"> <div className="flex flex-col items-center justify-center text-center">
<Loading /> <span className="loading loading-spinner loading-lg"></span>
</div> </div>
); );
// Room has been loaded // Room has been loaded