// import { Room } from "@/components/editor/live/room"
import Loading from "@/components/editor/loading"
import Navbar from "@/components/editor/navbar"
import { TerminalProvider } from "@/context/TerminalContext"
import { Sandbox, User, UsersToSandboxes } from "@/lib/types"
import { currentUser } from "@clerk/nextjs"
import dynamic from "next/dynamic"
import { notFound, redirect } from "next/navigation"
export const revalidate = 0
const getUserData = async (id: string) => {
const userRes = await fetch(
`${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/user?id=${id}`,
{
headers: {
Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`,
},
}
)
const userData: User = await userRes.json()
return userData
}
const getSandboxData = async (id: string) => {
const sandboxRes = await fetch(
`${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/sandbox?id=${id}`,
{
headers: {
Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`,
},
}
)
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(
`${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/user?id=${user.userId}`,
{
headers: {
Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`,
},
}
)
const userData: User = await userRes.json()
return {
id: userData.id,
name: userData.name,
avatarUrl: userData.avatarUrl,
}
})
)
return shared
}
const CodeEditor = dynamic(() => import("@/components/editor"), {
ssr: false,
loading: () =>