Skip to content

Commit

Permalink
Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
sayyyho authored Nov 13, 2024
2 parents 1a8835c + 2e92cba commit b2fec0d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
15 changes: 15 additions & 0 deletions src/apis/nuguTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { instance } from "./instance";

export const getNuguTestStatus = async () => {
try {
const response = await instance.get("/tests/status");
console.log(response);
if (response.data.hasTest) {
// TODO 수행한 인원 및 기타 작업
return true;
}
return false;
} catch (err) {
throw err;
}
};
17 changes: 7 additions & 10 deletions src/components/common/navigateBar/NavigateBar.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as S from "./styled";
import { useNavigate, useLocation } from "react-router-dom";
import { NAVIGATE_TITLE } from "@constants/navigatebar";
import Cookies from "js-cookie";

export const NavigateBar = () => {
const navigate = useNavigate();
const location = useLocation();
const isTokenAvailable = true;
const isTokenAvailable = Cookies.get("access_token") ? true : false;
const handleMovePage = (value) => {
let path;
switch (value) {
case 1:
path = isTokenAvailable ? "/login" : "/login";
path = `/nugu/${Cookies.get("uuid")}`;
break;
case 2:
path = "/intro";
path = `/intro/${Cookies.get("uuid")}`;
break;
case 3:
path = isTokenAvailable ? "/test" : "/challenge";
Expand All @@ -24,7 +26,6 @@ export const NavigateBar = () => {
navigate(path);
};
const isActive = (path) => location.pathname === path;
console.log(isActive);
return (
<S.Container>
{NAVIGATE_TITLE.map((item) => (
Expand All @@ -33,13 +34,9 @@ export const NavigateBar = () => {
className={
isActive(
item.value === 1
? isTokenAvailable
? "/dashboard"
: "/login"
? `/nugu/${Cookies.get("uuid")}`
: item.value === 2
? isTokenAvailable
? "/intro"
: "/intro"
? `/intro/${Cookies.get("uuid")}`
: isTokenAvailable
? "/test"
: "/challenge"
Expand Down
9 changes: 7 additions & 2 deletions src/pages/nugu/_hooks/useNuguInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export const useNuguInfo = (uuid) => {
const [isAdmin, setIsAdmin] = useState(false);

useEffect(() => {
if (!uuid) return;
if (!Cookies.get("uuid")) {
Cookies.set("uuid", uuid);
}

if (Cookies.get("access_token")) {
setIsAdmin(true);
}
Expand All @@ -33,7 +36,9 @@ export const useNuguInfo = (uuid) => {
keyword2,
keyword3,
} = response;

if (!Cookies.get("nickname")) {
Cookies.set("nickname", nickname);
}
setData({
nickname,
mbti,
Expand Down
10 changes: 7 additions & 3 deletions src/pages/nuguTest/NuguTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { Button } from "@components/common/button/Button";
import { NuguTestTrue } from "@components/nuguTest/NuguTestTrue";
import { isMakeTestOwner } from "@atoms/nuguTestState";
import { useRecoilState } from "recoil";

import { getNuguTestStatus } from "@apis/nuguTest";
import Cookies from "js-cookie";

//토큰 여부로 워딩 다르게 표현
export const NuguTestPage = () => {
const [isMakeTest, setIsMakeTest] = useRecoilState(isMakeTestOwner);
Expand All @@ -18,7 +22,7 @@ export const NuguTestPage = () => {
useEffect(() => {
const fetchTestStatus = async () => {
try {
const hasTest = false;
const hasTest = await getNuguTestStatus();
//누구 테스트 사용자-get
setIsMakeTest(hasTest);
} catch (error) {
Expand Down Expand Up @@ -62,11 +66,11 @@ export const NuguTestPage = () => {
array.length === 0 ? (
<NuguTestNone isTestOwner={true} />
) : (
<NuguTestTrue username={"하채민"} ranking={array} />
<NuguTestTrue username={Cookies.get("nickname")} ranking={array} />
)
) : (
<>
<NuguTestHome username={"하채민"} isOwner={true} />
<NuguTestHome username={Cookies.get("nickname")} isOwner={true} />
<Button disabled={false} onClick={() => moveOnTest()}>
누구테스트 만들러 가기
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ const router = createBrowserRouter([
},
{
//접속자뷰 누구테스트홈
path: "/challenge",
path: "/challenge/:uuid",
element: <NuguChallenge />,
},
{
//
path: "/challenge/test",
path: "/challenge/test/:uuid",
element: <ChallengerTest />,
},
{
Expand Down

0 comments on commit b2fec0d

Please sign in to comment.