-
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
Showing
12 changed files
with
269 additions
and
133 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
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,53 +1,137 @@ | ||
/* eslint-disable react-hooks/exhaustive-deps */ | ||
"use client"; | ||
import userStore from "@/app/store/homePageStore/useUserRoleSetting"; | ||
/** @jsxImportSource @emotion/react */ | ||
|
||
import { | ||
titleAndMenuStyle, | ||
titleAndMenuStylePalette, | ||
homeTitleStyle, | ||
homeMenuStyle, | ||
} from "@/app/styleComponents/homePageStyles/HomePageStyles"; | ||
HomePageBtnStyles, | ||
navStyles, | ||
paletteStyle, | ||
} from "@/app/styleComponents/newHomePageStyles/navStyles"; | ||
import Link from "next/link"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect, useState } from "react"; | ||
import { useCookies } from "react-cookie"; | ||
|
||
const ProjectMenu = () => { | ||
const [cookies] = useCookies(["accessToken", "role"]); | ||
const [isCookieThere, setIsCookieThere] = useState(false); | ||
const { userRole } = userStore(); | ||
const NavBar = () => { | ||
const router = useRouter(); | ||
|
||
const [cookies, , removeCookie] = useCookies([ | ||
"email", | ||
"nickname", | ||
"accessToken", | ||
"refreshToken", | ||
"role", | ||
]); | ||
|
||
const [isCookiesThere, setIsCookiesThere] = useState<boolean>(); | ||
const [isItBasic, setIsItBasic] = useState<boolean>(false); | ||
const [isItPro, setIsItPro] = useState<boolean>(false); | ||
const [cookieNickname, setCookieNickname] = useState(""); | ||
|
||
useEffect(() => { | ||
setCookieNickname(cookies.nickname); | ||
if (cookies.accessToken) { | ||
setIsCookieThere(true); | ||
setIsCookiesThere(true); | ||
} | ||
if (cookies.role === "BASIC") { | ||
setIsItBasic(true); | ||
} else { | ||
setIsItBasic(false); | ||
} | ||
}, []); | ||
if (cookies.role === "COMPANY_PRO") { | ||
setIsItPro(true); | ||
} else { | ||
setIsItPro(false); | ||
} | ||
}, [cookies]); | ||
|
||
const removeCookies = async () => { | ||
removeCookie("email", { path: "/" }); | ||
removeCookie("nickname", { path: "/" }); | ||
removeCookie("accessToken", { path: "/" }); | ||
removeCookie("refreshToken", { path: "/" }); | ||
removeCookie("role", { path: "/" }); | ||
window.location.reload(); | ||
}; | ||
|
||
return ( | ||
<div css={titleAndMenuStyle}> | ||
<div css={titleAndMenuStylePalette}> | ||
<Link href={"/"}> | ||
<p css={homeTitleStyle}>Palette*</p> | ||
<nav css={navStyles.containerStyle}> | ||
<div css={[navStyles.leftStyle]}> | ||
<Link href={"/"} css={[paletteStyle]}> | ||
{isItPro ? "PalettePro*" : "Palette*"} | ||
</Link> | ||
{isItBasic ? ( | ||
<> | ||
<Link href={"/pages/workspacePage"} css={navStyles.LinkTextStyle}> | ||
워크스페이스 | ||
</Link> | ||
<Link href={"/pages/reviewRequestPage"} css={navStyles.LinkTextStyle}> | ||
평판 | ||
</Link> | ||
</> | ||
) : ( | ||
<Link | ||
href={"/pages/ticketPage"} | ||
css={navStyles.LinkTextStyle} | ||
onClick={(e) => { | ||
if (!cookies.accessToken) { | ||
e.preventDefault(); | ||
if (confirm("로그인 후 이용하실 수 있습니다.")) { | ||
router.push("/pages/loginPage"); | ||
} | ||
} | ||
}} | ||
> | ||
{isItPro ? "구독중✓" : "구독"} | ||
</Link> | ||
)} | ||
<Link | ||
href={"/pages/chattingPage"} | ||
css={navStyles.LinkTextStyle} | ||
onClick={(e) => { | ||
if (!cookies.accessToken) { | ||
e.preventDefault(); | ||
if (confirm("로그인 후 이용하실 수 있습니다.")) { | ||
router.push("/pages/loginPage"); | ||
} | ||
} | ||
}} | ||
> | ||
채팅 | ||
</Link> | ||
</div> | ||
<nav css={homeMenuStyle}> | ||
<span> | ||
{cookies.role === "COMPANY" ? ( | ||
<Link href="/pages/ticketPage">티켓 구독</Link> | ||
) : isCookieThere ? ( | ||
<Link href="/pages/workspacePage">워크스페이스</Link> | ||
) : ( | ||
<Link href="/pages/loginPage">워크스페이스</Link> | ||
<div css={[navStyles.rightStyle]}> | ||
<p css={[`margin-right: 30px; @media (max-width: 975px) {display: none;}`]}> | ||
{isCookiesThere && ( | ||
<> | ||
좋은 하루 되세요, <strong>{cookieNickname}</strong>님 | ||
</> | ||
)} | ||
</span> | ||
|
||
<Link href={"/pages/chattingPage"}> | ||
<span>채팅</span> | ||
</Link> | ||
</nav> | ||
</div> | ||
</p> | ||
{isCookiesThere ? ( | ||
<> | ||
<button | ||
css={[HomePageBtnStyles.style1, `width: 100px; &:hover{width: 105px;}`]} | ||
onClick={() => router.push("/pages/myPage")} | ||
> | ||
마이페이지 | ||
</button> | ||
<button css={HomePageBtnStyles.style2} onClick={() => removeCookies()}> | ||
로그아웃 | ||
</button> | ||
</> | ||
) : ( | ||
<> | ||
<button css={HomePageBtnStyles.style1} onClick={() => router.push("/pages/loginPage")}> | ||
로그인 | ||
</button> | ||
<button css={HomePageBtnStyles.style2} onClick={() => router.push("/pages/signUpPage")}> | ||
회원가입 | ||
</button> | ||
</> | ||
)} | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default ProjectMenu; | ||
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
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
Oops, something went wrong.