diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index 3981310c79..919204550d 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -25,6 +25,8 @@ "@trigger.dev/react": "^2.2.6", "@trigger.dev/sdk": "^2.2.6", "@trigger.dev/supabase": "^2.2.6", + "@vercel/edge-config": "^0.4.1", + "@vercel/toolbar": "^0.1.5", "change-case": "^5.1.2", "framer-motion": "^10.16.5", "next": "14.0.3-canary.5", @@ -32,12 +34,12 @@ "next-safe-action": "^5.0.3", "next-themes": "^0.2.1", "next-usequerystate": "^1.12.0", - "sharp": "^0.32.6", "react": "18.2.0", "react-dom": "18.2.0", "react-dropzone": "^14.2.3", "react-hook-form": "^7.48.2", "recharts": "^2.9.3", + "sharp": "^0.32.6", "zod": "^3.22.4" }, "devDependencies": { diff --git a/apps/dashboard/src/app/layout.tsx b/apps/dashboard/src/app/layout.tsx index 1e1db41456..5566320647 100644 --- a/apps/dashboard/src/app/layout.tsx +++ b/apps/dashboard/src/app/layout.tsx @@ -1,4 +1,5 @@ import { Deployments } from "@/components/deployments"; +import { StaffToolbar } from "@/components/staff-toolbar"; import { ThemeProvider } from "@/components/theme-provider"; import "@/styles/globals.css"; import "@midday/ui/globals.css"; @@ -6,7 +7,7 @@ import { Toaster } from "@midday/ui/toaster"; import { cn } from "@midday/ui/utils"; import type { Metadata } from "next"; import { Instrument_Sans } from "next/font/google"; -import type { ReactElement } from "react"; +import { type ReactElement, Suspense } from "react"; const fontSans = Instrument_Sans({ subsets: ["latin"], @@ -36,6 +37,10 @@ export default function Layout({ children }: { children: ReactElement }) { + + + + ); diff --git a/apps/dashboard/src/components/staff-toolbar.tsx b/apps/dashboard/src/components/staff-toolbar.tsx new file mode 100644 index 0000000000..2dd2c8f5a5 --- /dev/null +++ b/apps/dashboard/src/components/staff-toolbar.tsx @@ -0,0 +1,16 @@ +import { createClient } from "@midday/supabase/server"; +import { get } from "@vercel/edge-config"; +import { VercelToolbar } from "@vercel/toolbar/next"; + +export async function StaffToolbar() { + const supabase = createClient(); + + const { + data: { session }, + } = await supabase.auth.getSession(); + const admins = await get("admins"); + + const isAdmin = admins?.includes(session.user.id); + + return isAdmin ? : null; +} diff --git a/apps/dashboard/src/middleware.ts b/apps/dashboard/src/middleware.ts index 1633d7b294..d567da3bf8 100644 --- a/apps/dashboard/src/middleware.ts +++ b/apps/dashboard/src/middleware.ts @@ -1,4 +1,5 @@ import { createClient } from "@midday/supabase/middleware"; +import { get } from "@vercel/edge-config"; import { createI18nMiddleware } from "next-international/middleware"; import { NextRequest, NextResponse } from "next/server"; @@ -8,16 +9,6 @@ const I18nMiddleware = createI18nMiddleware({ urlMappingStrategy: "rewrite", }); -const ADMINS = [ - "ec10c095-8cf7-4ba3-a62e-98f2a3d40c4c", - "7d723617-c2e1-4b71-8bf4-fb02479b264a", - "efea0311-0786-4f70-9b5a-63e3efa5d319", - "2f76981b-fc66-479c-8203-521a5a1f734a", - "3cb7ad12-907e-49c6-9f3a-ea3eeb1d34cf", - "71908de2-2727-43a8-8a3f-4ae203faa4c5", - "a9f6e6f2-8d58-4cf7-a3e7-312be3ee9560", // Ali Saheli -]; - export async function middleware(request: NextRequest) { const response = I18nMiddleware(request); const { supabase } = createClient(request, response); @@ -30,7 +21,7 @@ export async function middleware(request: NextRequest) { if ( data.session && - !ADMINS.includes(data.session.user.id) && + !(await get("beta"))?.includes(data.session.user.id) && request.nextUrl.pathname !== "/closed" ) { return NextResponse.redirect(new URL("/closed", request.url)); diff --git a/bun.lockb b/bun.lockb index 32efbb5e51..d627d636bc 100755 Binary files a/bun.lockb and b/bun.lockb differ