37 lines
1001 B
TypeScript
Raw Normal View History

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 15:25:20 -04:00
import { Sandbox, User } from "@/lib/types"
2024-04-16 16:25:21 -04:00
export default async function DashboardPage() {
const user = await currentUser()
if (!user) {
redirect("/")
}
const userRes = await fetch(
`https://database.ishaan1013.workers.dev/api/user?id=${user.id}`
)
2024-04-18 15:25:20 -04:00
const userData = (await userRes.json()) as User
2024-05-01 02:49:25 -04:00
const sharedRes = await fetch(
`https://database.ishaan1013.workers.dev/api/sandbox/share?id=${user.id}`
2024-05-01 02:49:25 -04:00
)
const shared = (await sharedRes.json()) as {
id: string
name: string
type: "react" | "node"
author: string
sharedOn: Date
}[]
2024-04-16 16:25:21 -04:00
return (
<div className="w-screen h-screen flex flex-col overflow-hidden overscroll-none">
2024-04-18 15:25:20 -04:00
<Navbar userData={userData} />
2024-05-01 02:49:25 -04:00
<Dashboard sandboxes={userData.sandbox} shared={shared} />
2024-04-16 16:25:21 -04:00
</div>
)
}