Skip to content

Commit

Permalink
Merge branch 'dev' into feature/Choco-Express#4
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyeonjinn committed Sep 24, 2024
2 parents d4f3410 + 187283a commit c5de541
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pages/otherboxPage/otherboxPage.jsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
import * as S from "./styled";
import HeartBackG from "../../components/common/Heartbackground/heartBackG";
import { useNavigate, useLocation } from "react-router-dom";
import { BOXES } from "../../constants/Boxes/data";
import { useOtherBox } from "../../hooks/useOtherBox";
import Cookies from "js-cookie";
import { useNavigate, useLocation } from "react-router-dom";

export const OtherboxPage = () => {
const { otherData } = useOtherBox();
console.log("상대방 박스 조회 data:", otherData);
const navigate = useNavigate();
const location = useLocation();
const token = Cookies.get("access_token");
console.log("Token:", token);
const boxId = otherData ? otherData.boxId : null;

const MoveOnLetterP = () => {
if (!token) {
// 토큰이 없으면 로그인 페이지로 리다이렉트하고, 돌아올 페이지 정보를 함께 전달
sessionStorage.setItem(
"redirectURL",
"redirectUrl",
`https://choco-express.site/box/${boxId}/choco`
);
navigate("");
navigate("/");
} else {
// 토큰이 있으면 초콜릿 보내기 페이지로 이동

navigate(`/box/${boxId}/choco`, { state: { otherData } });
}
};

const MoveOnMainP = () => {
console.log("MoveOnMainP called");
if (!token) {
// 토큰이 없으면 로그인 페이지로 리다이렉트하고, 돌아올 페이지 정보를 함께 전달
sessionStorage.setItem(
"redirectURL",
"redirectUrl",
`https://choco-express.site/box/${boxId}/choco`
);
navigate("");
navigate("/");
} else {
// 토큰이 있으면 나만의 박스 조회 페이지로 이동
navigate(`/mypage`);
Expand Down

0 comments on commit c5de541

Please sign in to comment.