diff --git a/src/app/_components/AdminWrap.tsx b/src/app/_components/AdminWrap.tsx index bf15da6..58c1439 100644 --- a/src/app/_components/AdminWrap.tsx +++ b/src/app/_components/AdminWrap.tsx @@ -1,7 +1,10 @@ -import { isAdmin } from "~/app/actions" - -export default async function AdminWrap({children,}: Readonly<{ children: React.ReactNode }>) { - if (await isAdmin()) { +// "use client" +// import { isAdmin } from "~/app/actions" +import { useUser } from "@clerk/nextjs" +import { env } from "~/env" +export default function AdminWrap({children,}: Readonly<{ children: React.ReactNode }>) { + const user = useUser(); + if (user.isSignedIn && user.user.id == env.NEXT_PUBLIC_ADMIN_USER_CLERK_ID) { return <>{children} } return (<>) diff --git a/src/app/_components/TopNav.tsx b/src/app/_components/TopNav.tsx index a932a47..34f797a 100644 --- a/src/app/_components/TopNav.tsx +++ b/src/app/_components/TopNav.tsx @@ -1,6 +1,7 @@ +"use client" import Link from "next/link" import AdminWrap from "./AdminWrap" -import { Show, SignInButton, SignOutButton, SignUpButton, UserButton } from "@clerk/nextjs" +import { ClerkLoaded, Show, SignInButton, SignOutButton, SignUpButton, UserButton } from "@clerk/nextjs" import { Button } from "~/components/ui/button" import { ThemeSwitch } from "./ThemeSwitch" @@ -39,13 +40,15 @@ export default function TopNav() { - - - + + + + + diff --git a/src/app/admin/cv/category/list/page.tsx b/src/app/admin/cv/category/list/page.tsx index 4359d7c..1e3fd95 100644 --- a/src/app/admin/cv/category/list/page.tsx +++ b/src/app/admin/cv/category/list/page.tsx @@ -47,7 +47,7 @@ export default function CvPage() { entires[0].filter((e) => { return e.categoryId == cat.id }).length > 0 ? ( <> {entires[0].filter((e) => { return e.categoryId == cat.id }).map((entry) => ( - + ))} ) : (<>) diff --git a/src/app/admin/project/list/page.tsx b/src/app/admin/project/list/page.tsx index e01506c..d560f43 100644 --- a/src/app/admin/project/list/page.tsx +++ b/src/app/admin/project/list/page.tsx @@ -38,7 +38,7 @@ export default function ProjectList() { techStacks[0].filter((e) => { return e.id == project.stackId }).length > 0 ? ( <> {techStacks[0].filter((e) => { return e.id == project.stackId }).map((stack) => ( - + ))} ) : (<>) diff --git a/src/env.js b/src/env.js index 29c5a1c..2b0220e 100644 --- a/src/env.js +++ b/src/env.js @@ -38,6 +38,7 @@ export const env = createEnv({ * `NEXT_PUBLIC_`. */ client: { + NEXT_PUBLIC_ADMIN_USER_CLERK_ID: z.string(), NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string() // NEXT_PUBLIC_CLIENTVAR: z.string(), }, @@ -63,6 +64,7 @@ export const env = createEnv({ POSTGRES_URL_NO_SSL: process.env.POSTGRES_URL_NO_SSL, POSTGRES_PRISMA_URL: process.env.POSTGRES_PRISMA_URL, ADMIN_USER_CLERK_ID: process.env.ADMIN_USER_CLERK_ID, + NEXT_PUBLIC_ADMIN_USER_CLERK_ID: process.env.NEXT_PUBLIC_ADMIN_USER_CLERK_ID, CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY, NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, NODE_ENV: process.env.NODE_ENV, diff --git a/src/proxy.ts b/src/proxy.ts index 14e61e4..5538077 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -4,6 +4,7 @@ import { env } from "~/env"; const isTenantAdminRoute = createRouteMatcher(['/admin(.*)']) export default clerkMiddleware(async (auth,req) => { if (isTenantAdminRoute(req)) { + console.log("running clerk middleware"); let userid = (await auth()).userId if (userid != env.ADMIN_USER_CLERK_ID) { await auth.protect() diff --git a/src/server/dbschema/schema.ts b/src/server/dbschema/schema.ts index 806f9bc..bca0a8e 100644 --- a/src/server/dbschema/schema.ts +++ b/src/server/dbschema/schema.ts @@ -55,7 +55,7 @@ export const cvEntryRelations = relations(cvEntry, ({one}) => ({ export const sourceTypeEnum = pgEnum('source_type',['open','closed']) export const releaseStatus = pgEnum('release_status',['released','unreleased']) -export const stackItemEnum = pgEnum('stack_item',['drizzle','postgres','nextjs','react','servercomponents','php','laravel','reactnative','expo','mysql','nginx','protobuf','grpc']) +export const stackItemEnum = pgEnum('stack_item',['drizzle','postgres','nextjs','react','servercomponents','php','laravel','reactnative','expo','mysql','nginx','protobuf','grpc','java','graalvm','spring','aws','s3','react-native','linux','debian','htmx']) export const project = createTable( "project",