correct user button in editor

This commit is contained in:
Ishaan Dey 2024-04-18 15:32:27 -04:00
parent a765eea5d8
commit 5f5125cccd
5 changed files with 44 additions and 45 deletions

View File

@ -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 (
<div className="overflow-hidden overscroll-none w-screen flex flex-col h-screen bg-background">
<Navbar />
<Navbar userData={userData} />
<div className="w-screen flex grow">
{clerk.loaded ? <CodeEditor /> : null}
<CodeEditor />
</div>
</div>
)

View File

@ -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 }) {
</div>
<div className="flex items-center space-x-4">
<DashboardNavbarSearch />
<DashboardUserButton userData={userData} />
<UserButton userData={userData} />
</div>
</div>
)

View File

@ -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 | monaco.editor.IStandaloneCodeEditor>(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,10 +74,11 @@ export default function CodeEditor() {
<Tab>style.css</Tab>
</div>
<div className="grow w-full overflow-hidden rounded-md">
{clerk.loaded ? (
<Editor
height="100%"
defaultLanguage="typescript"
onMount={handleEditorMount}
// onMount={handleEditorMount}
options={{
minimap: {
enabled: false,
@ -95,6 +91,7 @@ export default function CodeEditor() {
}}
theme="vs-dark"
/>
) : null}
</div>
</ResizablePanel>
<ResizableHandle />

View File

@ -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 (
<div className="h-14 px-2 w-full flex items-center justify-between border-b border-border">
<div className="flex items-center space-x-4">
@ -22,12 +22,7 @@ export default function Navbar() {
</div>
</div>
</div>
<UserButton
appearance={{
baseTheme: dark,
}}
afterSignOutUrl="/"
/>
<UserButton userData={userData} />
</div>
)
}

View File

@ -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 (
<DropdownMenu>
<DropdownMenuTrigger>