sandbox data route + cosmetic changes

This commit is contained in:
Ishaan Dey
2024-04-27 00:28:00 -04:00
parent 39696128db
commit 1b6bd01989
5 changed files with 42 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import Navbar from "@/components/editor/navbar"
import { User } from "@/lib/types"
import { Sandbox, User } from "@/lib/types"
import { currentUser } from "@clerk/nextjs"
import dynamic from "next/dynamic"
import { redirect } from "next/navigation"
@ -14,6 +14,12 @@ const getUserData = async (id: string) => {
return userData
}
const getSandboxData = async (id: string) => {
const sandboxRes = await fetch(`http://localhost:8787/api/sandbox?id=${id}`)
const sandboxData: Sandbox = await sandboxRes.json()
return sandboxData
}
export default async function CodePage({ params }: { params: { id: string } }) {
const user = await currentUser()
const sandboxId = params.id
@ -23,10 +29,11 @@ export default async function CodePage({ params }: { params: { id: string } }) {
}
const userData = await getUserData(user.id)
const sandboxData = await getSandboxData(sandboxId)
return (
<div className="overflow-hidden overscroll-none w-screen flex flex-col h-screen bg-background">
<Navbar userData={userData} />
<Navbar userData={userData} sandboxData={sandboxData} />
<div className="w-screen flex grow">
<CodeEditor userId={user.id} sandboxId={sandboxId} />
</div>