30c9da559f
- added user avatars for each user - it will fetch user images from github or google and if there is no image then it will show initials
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import Dashboard from "@/components/dashboard"
|
|
import Navbar from "@/components/dashboard/navbar"
|
|
import { User } from "@/lib/types"
|
|
import { currentUser } from "@clerk/nextjs"
|
|
import { redirect } from "next/navigation"
|
|
|
|
export default async function DashboardPage() {
|
|
const user = await currentUser()
|
|
|
|
if (!user) {
|
|
redirect("/")
|
|
}
|
|
|
|
const userRes = await fetch(
|
|
`${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/user?id=${user.id}`,
|
|
{
|
|
headers: {
|
|
Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`,
|
|
},
|
|
}
|
|
)
|
|
const userData = (await userRes.json()) as User
|
|
|
|
const sharedRes = await fetch(
|
|
`${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/sandbox/share?id=${user.id}`,
|
|
{
|
|
headers: {
|
|
Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`,
|
|
},
|
|
}
|
|
)
|
|
const shared = (await sharedRes.json()) as {
|
|
id: string
|
|
name: string
|
|
type: "react" | "node"
|
|
author: string
|
|
sharedOn: Date
|
|
authorAvatarUrl: string
|
|
}[]
|
|
|
|
return (
|
|
<div className="w-screen h-screen flex flex-col overflow-hidden overscroll-none">
|
|
<Navbar userData={userData} />
|
|
<Dashboard sandboxes={userData.sandbox} shared={shared} />
|
|
</div>
|
|
)
|
|
}
|