-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from soohwanpak/next-박수환-sprint9
[박수환] sprint9
- Loading branch information
Showing
40 changed files
with
1,203 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/versions | ||
|
||
/test.http | ||
# testing | ||
/coverage | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,69 @@ | ||
import { useState, useEffect } from 'react'; | ||
import Image from 'next/image'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
import styles from '@/css/Header.module.css'; | ||
|
||
export default function Header() { | ||
const [nickname, setNickname] = useState(null); | ||
|
||
useEffect(() => { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
const user = localStorage.getItem('user'); | ||
|
||
// 'accessToken'과 'user'가 존재하면 로그인된 상태로 처리 | ||
if (accessToken && user) { | ||
const parsedUser = JSON.parse(user); | ||
setNickname(parsedUser.nickname); // 사용자 닉네임 상태 설정 | ||
} else { | ||
setNickname(null); | ||
} | ||
}, []); | ||
|
||
const handleLogout = () => { | ||
localStorage.removeItem('accessToken'); // accessToken 삭제 | ||
localStorage.removeItem('user'); // 사용자 정보 삭제 | ||
setNickname(null); // 상태 초기화 | ||
window.location.reload(); // 페이지 새로고침 | ||
}; | ||
|
||
return ( | ||
<div className={styles.headerContain}> | ||
<div className={styles.header1}> | ||
<div className={styles.header2}> | ||
<Link href="/" ><Image | ||
width={153} | ||
height={51} | ||
src="/images/PandaLogo.png" alt="Panda Market Logo" /></Link> | ||
<Link href="/"> | ||
<Image | ||
width={153} | ||
height={51} | ||
src="/images/PandaLogo.png" | ||
alt="Panda Market Logo" | ||
/> | ||
</Link> | ||
|
||
<div className={styles.headerText}> | ||
<p><Link href="/" className={styles.headerText1}>자유게시판</Link></p> | ||
<p><Link href="#" className={styles.headerText2}>중고마켓</Link></p> | ||
</div> | ||
|
||
<Link href='#' className={styles.button}>로그인</Link> | ||
{nickname ? ( | ||
<div className={styles.userContainer}> | ||
<div className={styles.userArea}> | ||
<Image | ||
width={40} | ||
height={40} | ||
src="/images/userIcon.png" | ||
alt="userIcon" | ||
/> | ||
<div className={styles.nickname}>{nickname} 님</div> | ||
</div> | ||
<div onClick={handleLogout} className={styles.logoutButton}> | ||
로그아웃 | ||
</div> | ||
</div> | ||
) : ( | ||
<Link href='/login' className={styles.button}>로그인</Link> | ||
)} | ||
</div> | ||
</div> | ||
</div > | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.