Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
37cfe93b
Commit
37cfe93b
authored
Jul 08, 2022
by
Yoon, Daeki
😅
Browse files
프로필, 로그인 상태에 따라 헤더 표시 변경
parent
aa821332
Changes
1
Show whitespace changes
Inline
Side-by-side
frontend/src/commons/Header.tsx
View file @
37cfe93b
import
React
from
"
react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
,
useLocation
}
from
"
react-router-dom
"
;
import
{
useAuth
}
from
"
../auth/auth.context
"
;
export
const
Header
=
()
=>
{
const
{
user
,
logout
}
=
useAuth
();
const
location
=
useLocation
();
return
(
<
div
className
=
"bg-white border-b-2 border-b-themeColor px-2 sm:px-4 py-2.5"
>
...
...
@@ -13,23 +14,41 @@ export const Header = () => {
</
Link
>
<
div
className
=
"md:flex items-center justify-end md:flex-1 lg:w-0"
>
{
user
.
isLoggedIn
?
(
<
button
onClick
=
{
()
=>
logout
()
}
>
Logout
</
button
>
<
div
className
=
""
>
<
button
onClick
=
{
()
=>
logout
()
}
className
=
"whitespace-nowrap font-bold text-gray-600 hover:text-themeColor mx-1 py-2 px-3 rounded-md"
>
로그아웃
</
button
>
{
location
.
pathname
===
"
/profile
"
?
(
""
)
:
(
<
Link
to
=
"/
login
"
to
=
"/
profile
"
className
=
"whitespace-nowrap font-bold text-gray-600 hover:text-themeColor mx-1 py-2 px-3 rounded-md"
>
Login
프로필
</
Link
>
)
}
</
div
>
)
:
(
<
div
>
<
Link
to
=
"/login"
className
=
"whitespace-nowrap font-bold text-gray-600 hover:text-themeColor mx-1 py-2 px-3 rounded-md"
>
로그인
</
Link
>
<
Link
to
=
"/signup"
className
=
"whitespace-nowrap font-bold text-white hover:bg-blue-500 mx-1 py-2 px-3 bg-themeColor rounded-md "
>
Sign Up
회원가입
</
Link
>
</
div
>
)
}
</
div
>
</
div
>
</
div
>
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment