File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use client' ;
22
33import Link from 'next/link' ;
4- import { usePathname } from 'next/navigation' ;
4+ import { usePathname , useRouter } from 'next/navigation' ;
55import {
66 Home ,
77 ClipboardList ,
88 CalendarPlus ,
99 CopyPlus ,
1010 LogOut ,
1111} from 'lucide-react' ;
12+ import { signOut } from 'firebase/auth' ;
13+ import { auth } from '@/lib/firebase' ;
1214
1315const navItems = [
1416 { label : '홈' , href : '/' , icon : Home } ,
@@ -19,6 +21,18 @@ const navItems = [
1921
2022const Sidebar = ( ) => {
2123 const pathname = usePathname ( ) ;
24+ const router = useRouter ( ) ;
25+
26+ const handleLogout = async ( ) : Promise < void > => {
27+ try {
28+ await signOut ( auth ) ;
29+ router . replace ( '/landing' ) ;
30+ router . refresh ( ) ; // 서버 컴포넌트/세션 UI 갱신
31+ } catch ( err ) {
32+ console . error ( '로그아웃 실패:' , err ) ;
33+ alert ( '로그아웃에 실패했습니다.' ) ;
34+ }
35+ } ;
2236
2337 return (
2438 < div className = "fixed flex h-screen w-48 flex-col bg-white" >
@@ -57,7 +71,10 @@ const Sidebar = () => {
5771 </ ul >
5872 </ nav >
5973 < div className = "absolute bottom-0 w-full border-t border-slate-200 p-4" >
60- < button className = "flex items-center gap-3 rounded-lg px-4 py-3 text-sm font-medium text-slate-700 hover:bg-slate-100" >
74+ < button
75+ className = "flex items-center gap-3 rounded-lg px-4 py-3 text-sm font-medium text-slate-700 hover:bg-slate-100"
76+ onClick = { handleLogout }
77+ >
6178 < LogOut className = "h-5 w-5 text-slate-600" />
6279 로그아웃
6380 </ button >
You can’t perform that action at this time.
0 commit comments