Initial changes to helpers (scope creep)
This commit is contained in:
parent
d4d70b5bc1
commit
19f2008617
4 changed files with 110 additions and 99 deletions
|
@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
|
|||
import { FaShieldAlt } from "react-icons/fa";
|
||||
import { GiStarFormation } from "react-icons/gi";
|
||||
import { useUser } from "@clerk/nextjs";
|
||||
import { isAdmin, isVIP } from "~/utils/helpers";
|
||||
|
||||
const Home: NextPage = () => {
|
||||
return (
|
||||
|
@ -43,10 +44,10 @@ const HomePageBody = () => {
|
|||
<>
|
||||
<h1 className="flex flex-row flex-wrap text-center justify-center items-center gap-1 text-4xl font-bold mx-auto">
|
||||
Hi, {user?.fullName}!{" "}
|
||||
{(user?.publicMetadata.isAdmin as boolean | undefined) && (
|
||||
{isVIP(user?.publicMetadata) && (
|
||||
<FaShieldAlt className="inline-block text-primary" />
|
||||
)}
|
||||
{(user?.publicMetadata.isVIP as boolean | undefined) && (
|
||||
{isAdmin(user?.publicMetadata) && (
|
||||
<GiStarFormation className="inline-block text-secondary" />
|
||||
)}
|
||||
</h1>
|
||||
|
|
|
@ -22,7 +22,7 @@ import Link from "next/link";
|
|||
import { FaShieldAlt } from "react-icons/fa";
|
||||
import { RiVipCrownFill } from "react-icons/ri";
|
||||
import { env } from "~/env.mjs";
|
||||
import { downloadCSV } from "~/utils/helpers";
|
||||
import { downloadCSV, isAdmin, isVIP } from "~/utils/helpers";
|
||||
import type { PresenceItem } from "~/utils/types";
|
||||
import { useUser } from "@clerk/nextjs";
|
||||
|
||||
|
@ -96,8 +96,8 @@ const RoomBody = ({}) => {
|
|||
name: user?.fullName || "",
|
||||
image: user?.imageUrl || "",
|
||||
client_id: user?.id || "",
|
||||
isAdmin: (user?.publicMetadata.isAdmin as boolean | undefined) || false,
|
||||
isVIP: (user?.publicMetadata.isVIP as boolean | undefined) || false,
|
||||
isAdmin: isAdmin(user?.publicMetadata),
|
||||
isVIP: isVIP(user?.publicMetadata),
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -347,7 +347,9 @@ const RoomBody = ({}) => {
|
|||
</div>
|
||||
)}
|
||||
|
||||
{isSignedIn && !!roomFromDb && roomFromDb.userId === user.id && (
|
||||
{isSignedIn &&
|
||||
!!roomFromDb &&
|
||||
(roomFromDb.userId === user.id || isAdmin(user?.publicMetadata)) && (
|
||||
<>
|
||||
<div className="card card-compact bg-neutral shadow-xl mx-auto m-4">
|
||||
<div className="card-body flex flex-col flex-wrap">
|
||||
|
@ -432,7 +434,8 @@ const RoomBody = ({}) => {
|
|||
</div>
|
||||
|
||||
{votesFromDb &&
|
||||
(roomFromDb.logs.length > 0 || votesFromDb.length > 0) && (
|
||||
(roomFromDb.logs.length > 0 ||
|
||||
votesFromDb.length > 0) && (
|
||||
<div>
|
||||
<button
|
||||
onClick={() => downloadLogs()}
|
||||
|
|
|
@ -139,7 +139,6 @@ export const roomRouter = createTRPCRouter({
|
|||
.update(rooms)
|
||||
.set({
|
||||
storyName: input.name,
|
||||
userId: ctx.auth.userId,
|
||||
visible: input.visible,
|
||||
scale: [...new Set(input.scale.split(","))]
|
||||
.filter((item) => item !== "")
|
||||
|
|
|
@ -15,3 +15,11 @@ export function downloadCSV(
|
|||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
export function isAdmin(meta: UserPublicMetadata | undefined) {
|
||||
return (meta?.isAdmin as boolean | undefined) || false;
|
||||
}
|
||||
|
||||
export function isVIP(meta: UserPublicMetadata | undefined) {
|
||||
return (meta?.isVIP as boolean | undefined) || false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue