diff --git a/frontend/app/(app)/code/[id]/page.tsx b/frontend/app/(app)/code/[id]/page.tsx
index ca464dc..15c9f04 100644
--- a/frontend/app/(app)/code/[id]/page.tsx
+++ b/frontend/app/(app)/code/[id]/page.tsx
@@ -1,21 +1,28 @@
-"use client"
-
import Navbar from "@/components/editor/navbar"
-import { useClerk } from "@clerk/nextjs"
+import { User } from "@/lib/types"
+import { currentUser } from "@clerk/nextjs"
import dynamic from "next/dynamic"
+import { redirect } from "next/navigation"
const CodeEditor = dynamic(() => import("@/components/editor"), {
ssr: false,
})
-export default function CodePage() {
- const clerk = useClerk()
+export default async function CodePage() {
+ const user = await currentUser()
+
+ if (!user) {
+ redirect("/")
+ }
+
+ const userRes = await fetch(`http://localhost:8787/api/user?id=${user.id}`)
+ const userData = (await userRes.json()) as User
return (
-
+
- {clerk.loaded ? : null}
+
)
diff --git a/frontend/components/dashboard/navbar/index.tsx b/frontend/components/dashboard/navbar/index.tsx
index 1753c13..8b1f02e 100644
--- a/frontend/components/dashboard/navbar/index.tsx
+++ b/frontend/components/dashboard/navbar/index.tsx
@@ -2,7 +2,7 @@ import Image from "next/image"
import Link from "next/link"
import Logo from "@/assets/logo.svg"
import DashboardNavbarSearch from "./search"
-import DashboardUserButton from "./userButton"
+import UserButton from "../../ui/userButton"
import { User } from "@/lib/types"
export default function DashboardNavbar({ userData }: { userData: User }) {
@@ -19,7 +19,7 @@ export default function DashboardNavbar({ userData }: { userData: User }) {
-
+
)
diff --git a/frontend/components/editor/index.tsx b/frontend/components/editor/index.tsx
index 0e4c230..fef8fe7 100644
--- a/frontend/components/editor/index.tsx
+++ b/frontend/components/editor/index.tsx
@@ -22,6 +22,7 @@ import {
} from "lucide-react"
import Tab from "../ui/tab"
import Sidebar from "./sidebar"
+import { useClerk } from "@clerk/nextjs"
export default function CodeEditor() {
const editorRef = useRef(null)
@@ -52,17 +53,11 @@ export default function CodeEditor() {
},
])
- const handleEditorMount: OnMount = (editor, monaco) => {
- editorRef.current = editor
+ // const handleEditorMount: OnMount = (editor, monaco) => {
+ // editorRef.current = editor
+ // }
- // import("monaco-themes/themes/Blackboard.json").then((data) => {
- // monaco.editor.defineTheme(
- // "Blackboard",
- // data as monaco.editor.IStandaloneThemeData
- // )
- // })
- // monaco.editor.setTheme("Blackboard")
- }
+ const clerk = useClerk()
return (
<>
@@ -79,22 +74,24 @@ export default function CodeEditor() {
style.css
-
+ {clerk.loaded ? (
+
+ ) : null}
diff --git a/frontend/components/editor/navbar/index.tsx b/frontend/components/editor/navbar/index.tsx
index 032517e..0afd848 100644
--- a/frontend/components/editor/navbar/index.tsx
+++ b/frontend/components/editor/navbar/index.tsx
@@ -1,11 +1,11 @@
import Image from "next/image"
import Logo from "@/assets/logo.svg"
import { Pencil } from "lucide-react"
-import { UserButton } from "@clerk/nextjs"
import Link from "next/link"
-import { dark } from "@clerk/themes"
+import { User } from "@/lib/types"
+import UserButton from "@/components/ui/userButton"
-export default function Navbar() {
+export default function Navbar({ userData }: { userData: User }) {
return (
@@ -22,12 +22,7 @@ export default function Navbar() {
-
+
)
}
diff --git a/frontend/components/dashboard/navbar/userButton.tsx b/frontend/components/ui/userButton.tsx
similarity index 93%
rename from frontend/components/dashboard/navbar/userButton.tsx
rename to frontend/components/ui/userButton.tsx
index 99f37d5..d9868bf 100644
--- a/frontend/components/dashboard/navbar/userButton.tsx
+++ b/frontend/components/ui/userButton.tsx
@@ -11,7 +11,7 @@ import {
import { User } from "@/lib/types"
import { LogOut, Pencil } from "lucide-react"
-export default function DashboardUserButton({ userData }: { userData: User }) {
+export default function UserButton({ userData }: { userData: User }) {
return (