File tree 3 files changed +30
-33
lines changed
3 files changed +30
-33
lines changed Original file line number Diff line number Diff line change 1
- import Header from "@/components/header" ;
2
- import { Button } from "@/components/ui/button" ;
3
- import { LoginButton , LogoutButton } from "@/components/ui/buttons" ;
4
- import { getSession } from "@/lib/session" ;
5
- import { prisma } from "@/lib/prisma" ;
6
- import Image from "next/image" ;
7
-
8
1
export default async function Home ( ) {
9
- const users = await prisma . user . findMany ( ) ;
10
- const session = await getSession ( ) ;
11
-
12
2
return (
13
3
< >
14
- < main className = "flex min-h-screen flex-col items-center justify-between p-24" >
15
- < Button > Button</ Button >
16
- { session ? (
17
- < div className = "flex space-x-2 items-center" >
18
- < Image
19
- className = "rounded-full"
20
- src = { session ?. user ?. image ! }
21
- alt = "user avatar"
22
- height = { 40 }
23
- width = { 40 }
24
- />
25
- < p className = "text-gray-700 font-bold" > { session ?. user ?. name } </ p >
26
- < LogoutButton />
27
- </ div >
28
- ) : (
29
- < LoginButton />
30
- ) }
31
- </ main >
4
+ < main className = "flex min-h-screen flex-col items-center justify-between p-24" > </ main >
32
5
</ >
33
6
) ;
34
7
}
Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ import TypingCode from "./typingCode";
5
5
export default async function Race ( ) {
6
6
const user = await getCurrentUser ( ) ;
7
7
8
- console . log ( user ) ;
9
-
10
8
return (
11
9
< >
12
10
< main className = "flex min-h-screen flex-col items-center justify-between p-24" >
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import Link from "next/link";
5
5
import React , { useState } from "react" ;
6
6
7
7
import { Button } from "./ui/button" ;
8
+ import { SessionProvider , useSession } from "next-auth/react" ;
9
+ import { LoginButton , LogoutButton } from "./ui/buttons" ;
8
10
9
11
const Header = ( ) => {
10
12
const [ state , setState ] = useState ( false ) ;
@@ -15,6 +17,8 @@ const Header = () => {
15
17
{ title : "About" , path : "/" } ,
16
18
] ;
17
19
20
+ const session = useSession ( ) ;
21
+
18
22
return (
19
23
< div >
20
24
< nav className = "w-full border-b md:border-0 md:static" >
@@ -82,13 +86,35 @@ const Header = () => {
82
86
} ) }
83
87
</ ul >
84
88
</ div >
85
- < div className = "hidden md:inline-block" >
86
- < Button > Login</ Button >
89
+ < div className = "hidden md:flex gap-4 items-center" >
90
+ { session . status !== "authenticated" ? (
91
+ < LoginButton />
92
+ ) : (
93
+ < >
94
+ < Image
95
+ className = "rounded-full"
96
+ src = { session ?. data . user . image ?? "" }
97
+ alt = "user avatar"
98
+ height = { 40 }
99
+ width = { 40 }
100
+ />
101
+ < p className = "text-gray-700 font-bold" >
102
+ { session ?. data . user ?. name }
103
+ </ p >
104
+ < LogoutButton />
105
+ </ >
106
+ ) }
87
107
</ div >
88
108
</ div >
89
109
</ nav >
90
110
</ div >
91
111
) ;
92
112
} ;
93
113
94
- export default Header ;
114
+ export default function WrappedHeader ( ) {
115
+ return (
116
+ < SessionProvider >
117
+ < Header />
118
+ </ SessionProvider >
119
+ ) ;
120
+ }
You can’t perform that action at this time.
0 commit comments