diff --git a/prisma/schema.prisma b/prisma/schema.prisma index bd8df38..41ff26a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,7 +1,7 @@ enum RoleValue { USER ADMIN - MATT + VIP } generator client { diff --git a/src/pages/admin/index.tsx b/src/pages/admin/index.tsx index d66a1cd..0a081d0 100644 --- a/src/pages/admin/index.tsx +++ b/src/pages/admin/index.tsx @@ -5,6 +5,7 @@ import { AiOutlineClear } from "react-icons/ai"; import { FaShieldAlt } from "react-icons/fa"; import { IoTrashBinOutline } from "react-icons/io5"; import { SiGithub, SiGoogle } from "react-icons/si"; +import { GiStarFormation } from "react-icons/gi"; import { api } from "~/utils/api"; import type { Role } from "~/utils/types"; import { getServerAuthSession } from "../../server/auth"; @@ -158,70 +159,70 @@ const AdminBody: React.FC = () => {
Users
- { usersCountLoading || usersCountFetching ? ( + {usersCountLoading || usersCountFetching ? ( ) : ( - <>{ usersCount ? usersCount : "0" } - ) } + <>{usersCount ? usersCount : "0"} + )}
Rooms
- { roomsCountLoading || roomsCountFetching ? ( + {roomsCountLoading || roomsCountFetching ? ( ) : ( - <>{ roomsCount ? roomsCount : "0" } - ) } + <>{roomsCount ? roomsCount : "0"} + )}
Votes
- { votesCountLoading || votesCountFetching ? ( + {votesCountLoading || votesCountFetching ? ( ) : ( - <>{ votesCount ? votesCount : "0" } - ) } + <>{votesCount ? votesCount : "0"} + )}
- { usersCountFetching || - usersFetching || - roomsCountFetching || - votesCountFetching ? ( + {usersCountFetching || + usersFetching || + roomsCountFetching || + votesCountFetching ? ( ) : (
- ) } + )}

Users:

- { usersLoading || usersFetching ? ( + {usersLoading || usersFetching ? ( ) : (
- {/* head */ } + {/* head */} @@ -233,55 +234,72 @@ const AdminBody: React.FC = () => { - { users + {users ?.sort((user1, user2) => user2.createdAt > user1.createdAt ? 1 : -1 ) .map((user) => { return ( - + ); - }) } + })}
ID
- { user.id } + {user.id} - { user.name } + {user.name} - { user.createdAt.toLocaleDateString() } + {user.createdAt.toLocaleDateString()} - { user.sessions.length } + {user.sessions.length} - { getProviders(user).includes("google") && ( + {getProviders(user).includes("google") && ( - ) } - { getProviders(user).includes("github") && ( + )} + {getProviders(user).includes("github") && ( - ) } + )} +
- ) } + )}
diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 6ad31f0..7ed5495 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -8,6 +8,7 @@ import Link from "next/link"; import { useEffect, useState } from "react"; import { FaShieldAlt } from "react-icons/fa"; import { getServerAuthSession } from "~/server/auth"; +import { GiStarFormation } from "react-icons/gi"; export const getServerSideProps: GetServerSideProps = async (ctx) => { const session = await getServerAuthSession(ctx); @@ -57,20 +58,23 @@ const HomePageBody: React.FC = () => { return ( <>

- Hi, { sessionData?.user.name }!{ " " } - { sessionData?.user.role === "ADMIN" && ( + Hi, {sessionData?.user.name}!{" "} + {sessionData?.user.role === "ADMIN" && ( - ) } + )} + {sessionData?.user.role === "VIP" && ( + + )}

{ + onClick={() => { setTabIndex(0); localStorage.setItem("dashboardTabIndex", "0"); - } } + }} > Join a Room @@ -78,36 +82,36 @@ const HomePageBody: React.FC = () => { className={ tabIndex === 1 ? "tab no-underline tab-active" : "tab no-underline" } - onClick={ () => { + onClick={() => { setTabIndex(1); localStorage.setItem("dashboardTabIndex", "1"); - } } + }} > Room List
- { tabIndex === 0 && ( + {tabIndex === 0 && ( <> { + onChange={(event) => { console.log(event.target.value); setJoinRoomTextBox(event.target.value); - } } + }} /> 0 ? `/room/${joinRoomTextBox}` : "/" } + href={joinRoomTextBox.length > 0 ? `/room/${joinRoomTextBox}` : "/"} className="btn btn-secondary" > Join Room - ) } + )} - { tabIndex === 1 && } + {tabIndex === 1 && } ); }; diff --git a/src/pages/room/[id].tsx b/src/pages/room/[id].tsx index 68652a1..29c15d0 100644 --- a/src/pages/room/[id].tsx +++ b/src/pages/room/[id].tsx @@ -311,10 +311,10 @@ const RoomBody: React.FC = ({}) => { )}{" "} - {presenceItem.data.role === "MATT" && ( + {presenceItem.data.role === "VIP" && (
diff --git a/src/server/api/routers/user.ts b/src/server/api/routers/user.ts index d7eff4f..f5995cf 100644 --- a/src/server/api/routers/user.ts +++ b/src/server/api/routers/user.ts @@ -153,7 +153,11 @@ export const userRouter = createTRPCRouter({ .input( z.object({ userId: z.string(), - role: z.union([z.literal("ADMIN"), z.literal("USER")]), + role: z.union([ + z.literal("ADMIN"), + z.literal("USER"), + z.literal("VIP"), + ]), }) ) .mutation(async ({ ctx, input }) => { diff --git a/src/utils/types.ts b/src/utils/types.ts index f2a5477..cf71bb6 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -10,7 +10,7 @@ export type EventType = BetterEnum; const RoleValues = { ADMIN: "ADMIN", USER: "USER", - MATT: "MATT", + VIP: "VIP", } as const; export type Role = BetterEnum;