22
33import Link from "next/link"
44import { useState } from "react"
5+ import { useRouter } from "next/navigation"
56import { Sparkles } from "lucide-react"
67import { Button } from "@/components/ui/Button"
8+ import { useAuth } from "@/hooks/auth/useAuth"
79
810export default function Header ( ) {
911 const [ isLoggedIn , setIsLoggedIn ] = useState ( false )
12+ const router = useRouter ( )
13+ const { isAuthed } = useAuth ( )
14+
15+ const guardNav = ( path : string ) => ( ) => {
16+ if ( ! isAuthed ) {
17+ alert ( "로그인해주세요" )
18+ return
19+ }
20+ router . push ( path )
21+ }
1022
1123 return (
1224 < nav className = "border-b border-gray-200 bg-background/80 backdrop-blur-xl" >
@@ -28,15 +40,15 @@ export default function Header() {
2840 < div className = "flex items-center gap-6" >
2941 { isLoggedIn ? (
3042 < >
31- < Link href = "/history" className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
43+ < button onClick = { guardNav ( "/history" ) } className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
3244 히스토리
33- </ Link >
34- < Link href = "/community" className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
45+ </ button >
46+ < button onClick = { guardNav ( "/community" ) } className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
3547 커뮤니티
36- </ Link >
37- < Link href = "/settings" className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
48+ </ button >
49+ < button onClick = { guardNav ( "/settings" ) } className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
3850 마이페이지
39- </ Link >
51+ </ button >
4052 { /* 로그아웃 구현 필요요 */ }
4153 < Button
4254 variant = "ghost"
@@ -49,20 +61,18 @@ export default function Header() {
4961 </ >
5062 ) : (
5163 < >
52- < Link href = "/community" className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
64+ < button onClick = { guardNav ( "/community" ) } className = "text-sm text-muted-foreground hover:text-foreground transition-colors" >
5365 커뮤니티
54- </ Link >
66+ </ button >
5567
5668 < div className = "flex items-center gap-3" >
5769 { /* 현재는 로그인 누르면 바로 로그인 상태로 변경 중 */ }
5870 { /* 로그인 누르면 로그인 화면으로, 시작하기 누르면 회원가입으로 넘어가야 함함 */ }
5971 < Button variant = "ghost" size = "sm" onClick = { ( ) => setIsLoggedIn ( true ) } >
6072 로그인
6173 </ Button >
62- < Button size = "sm" className = "bg-primary text-primary-foreground hover:bg-primary/90" asChild >
63- < Link href = "/signup" >
64- 시작하기
65- </ Link >
74+ < Button size = "sm" className = "bg-primary text-primary-foreground hover:bg-primary/90" onClick = { guardNav ( "/signup" ) } >
75+ 시작하기
6676 </ Button >
6777 </ div >
6878 </ >
0 commit comments