2024-04-16 16:25:21 -04:00
|
|
|
import { UserButton, currentUser } from "@clerk/nextjs"
|
|
|
|
import { redirect } from "next/navigation"
|
|
|
|
import Dashboard from "@/components/dashboard"
|
|
|
|
import Navbar from "@/components/dashboard/navbar"
|
2024-04-18 00:13:40 -04:00
|
|
|
import { Sandbox } from "@/lib/types"
|
2024-04-16 16:25:21 -04:00
|
|
|
|
|
|
|
export default async function DashboardPage() {
|
|
|
|
const user = await currentUser()
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
redirect("/")
|
|
|
|
}
|
|
|
|
|
2024-04-18 00:13:40 -04:00
|
|
|
const res = await fetch(
|
|
|
|
`http://localhost:8787/api/user/sandbox?id=${user.id}`
|
|
|
|
)
|
|
|
|
const data = (await res.json()).sandbox as Sandbox[]
|
|
|
|
|
|
|
|
console.log(data)
|
|
|
|
|
2024-04-16 16:25:21 -04:00
|
|
|
return (
|
|
|
|
<div className="w-screen h-screen flex flex-col overflow-hidden overscroll-none">
|
|
|
|
<Navbar />
|
2024-04-18 00:13:40 -04:00
|
|
|
<Dashboard sandboxes={data} />
|
2024-04-16 16:25:21 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|