-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
019cbbe
commit 53ff337
Showing
9 changed files
with
217 additions
and
146 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { useEffect, useState } from "react"; | ||
import { | ||
Flex, | ||
Text, | ||
Menu, | ||
MenuButton, | ||
MenuList, | ||
MenuItem, | ||
IconButton, | ||
} from "@chakra-ui/react"; | ||
import { HamburgerIcon } from "@chakra-ui/icons"; | ||
import api from "../../api/interceptor"; | ||
|
||
interface NavBarProps { | ||
activeTab: string; | ||
setActiveTab: (tab: string) => void; | ||
handleLogout: () => void; | ||
} | ||
|
||
const NavBar = ({ | ||
activeTab, | ||
setActiveTab, | ||
handleLogout, | ||
}: NavBarProps): JSX.Element => { | ||
const [userName, setUserName] = useState<string>(""); | ||
|
||
useEffect(() => { | ||
const fetchUserName = async () => { | ||
try { | ||
const response = await api.get("/api/members/info"); | ||
const name = response.data.name; | ||
setUserName(name); | ||
} catch (error) { | ||
console.error("사용자 정보를 가져오는 중 오류 발생:", error); | ||
} | ||
}; | ||
|
||
fetchUserName(); | ||
}, []); | ||
|
||
return ( | ||
<Flex | ||
as="nav" | ||
justify="space-between" | ||
align="center" | ||
padding="1rem" | ||
bg="white" | ||
boxShadow="md" | ||
position="fixed" | ||
top="0" | ||
width="100%" | ||
zIndex="1000" | ||
> | ||
<Flex align="center" gap="2rem"> | ||
<Text | ||
cursor="pointer" | ||
fontSize={["sm", "md", "lg"]} | ||
fontWeight="bold" | ||
color={activeTab === "추천 콘텐츠" ? "black" : "teal.500"} | ||
borderBottom={activeTab === "추천 콘텐츠" ? "2px solid teal" : "none"} | ||
onClick={() => setActiveTab("추천 콘텐츠")} | ||
> | ||
추천 콘텐츠 | ||
</Text> | ||
<Text | ||
cursor="pointer" | ||
fontSize={["sm", "md", "lg"]} | ||
fontWeight="bold" | ||
color={activeTab === "랜덤 콘텐츠" ? "black" : "teal.500"} | ||
borderBottom={activeTab === "랜덤 콘텐츠" ? "2px solid teal" : "none"} | ||
onClick={() => setActiveTab("랜덤 콘텐츠")} | ||
> | ||
랜덤 콘텐츠 | ||
</Text> | ||
<Text | ||
cursor="pointer" | ||
fontSize={["sm", "md", "lg"]} | ||
fontWeight="bold" | ||
color={activeTab === "검색" ? "black" : "teal.500"} | ||
borderBottom={activeTab === "검색" ? "2px solid teal" : "none"} | ||
onClick={() => setActiveTab("검색")} | ||
> | ||
검색 | ||
</Text> | ||
</Flex> | ||
<Menu> | ||
<MenuButton | ||
as={IconButton} | ||
aria-label="Options" | ||
icon={<HamburgerIcon />} | ||
variant="outline" | ||
/> | ||
<MenuList> | ||
{/* 사용자 이름 표시 */} | ||
<MenuItem>{userName ? `${userName} 님` : "사용자 님"}</MenuItem> | ||
<MenuItem onClick={handleLogout}>로그아웃</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default NavBar; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function RandomContents(): JSX.Element { | ||
return <div>랜덤 콘텐츠 컴포넌트 내용</div>; | ||
} | ||
|
||
export default RandomContents; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function RecommendedContents(): JSX.Element { | ||
return <div>추천 콘텐츠 컴포넌트 내용</div>; | ||
} | ||
|
||
export default RecommendedContents; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function SearchContents(): JSX.Element { | ||
return <div>검색 콘텐츠 컴포넌트 내용</div>; | ||
} | ||
|
||
export default SearchContents; |
Oops, something went wrong.