import Navbar from "@/components/editor/navbar"
import { Room } from "@/components/editor/live/room"
import { Sandbox, User, UsersToSandboxes } from "@/lib/types"
import { currentUser } from "@clerk/nextjs"
import { notFound, redirect } from "next/navigation"
import Editor from "@/components/editor"
import Loading from "@/components/editor/loading"
import dynamic from "next/dynamic"
export const revalidate = 0
const getUserData = async (id: string) => {
const userRes = await fetch(
`https://database.ishaan1013.workers.dev/api/user?id=${id}`
)
const userData: User = await userRes.json()
return userData
}
const getSandboxData = async (id: string) => {
const sandboxRes = await fetch(
`https://database.ishaan1013.workers.dev/api/sandbox?id=${id}`
)
const sandboxData: Sandbox = await sandboxRes.json()
return sandboxData
}
const getSharedUsers = async (usersToSandboxes: UsersToSandboxes[]) => {
if (!usersToSandboxes) {
return []
}
const shared = await Promise.all(
usersToSandboxes.map(async (user) => {
const userRes = await fetch(
`https://database.ishaan1013.workers.dev/api/user?id=${user.userId}`
)
const userData: User = await userRes.json()
return { id: userData.id, name: userData.name }
})
)
return shared
}
const CodeEditor = dynamic(() => import("@/components/editor"), {
ssr: false,
loading: () =>