1
- import { redirect } from "next/navigation"
2
1
import { cache } from "react"
2
+ import { redirect } from "next/navigation"
3
+ import { User } from "@prisma/client"
3
4
5
+ import { authOptions } from "@/lib/auth"
4
6
import { db } from "@/lib/db"
5
7
import { getCurrentUser } from "@/lib/session"
6
- import { User } from "@prisma/client"
7
- import { authOptions } from "@/lib/auth"
8
- import { DashboardHeader } from "@/components/dashboard/header"
9
- import { PostCreateButton } from "@/components/dashboard/post-create-button"
10
- import { DashboardShell } from "@/components/dashboard/shell"
11
- import { PostItem } from "@/components/dashboard/post-item"
12
- import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder"
8
+ import { cn } from "@/lib/utils"
9
+ import { EmptyPlaceholder } from "@/components/empty-placeholder"
10
+ import { DashboardHeader } from "@/components/header"
11
+ import { PostCreateButton } from "@/components/post-create-button"
12
+ import { PostItem } from "@/components/post-item"
13
+ import { DashboardShell } from "@/components/shell"
14
+ import { buttonVariants } from "@/components/ui/button"
15
+
16
+ export const metadata = {
17
+ title : "Dashboard" ,
18
+ }
13
19
14
20
const getPostsForUser = cache ( async ( userId : User [ "id" ] ) => {
15
21
return await db . post . findMany ( {
@@ -32,7 +38,7 @@ export default async function DashboardPage() {
32
38
const user = await getCurrentUser ( )
33
39
34
40
if ( ! user ) {
35
- redirect ( authOptions . pages . signIn )
41
+ redirect ( authOptions ? .pages ? .signIn || "/login" )
36
42
}
37
43
38
44
const posts = await getPostsForUser ( user . id )
@@ -56,7 +62,12 @@ export default async function DashboardPage() {
56
62
< EmptyPlaceholder . Description >
57
63
You don't have any posts yet. Start creating content.
58
64
</ EmptyPlaceholder . Description >
59
- < PostCreateButton className = "border-slate-200 bg-white text-brand-900 hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-offset-2" />
65
+ < PostCreateButton
66
+ className = { cn (
67
+ buttonVariants ( { variant : "outline" } ) ,
68
+ "text-slate-900"
69
+ ) }
70
+ />
60
71
</ EmptyPlaceholder >
61
72
) }
62
73
</ div >
0 commit comments