From b83f65e00be4a3a3316fe716bb07df2e582f97ba Mon Sep 17 00:00:00 2001 From: kyr4601 Date: Mon, 19 May 2025 17:26:46 +0900 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20401=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=B2=98=EB=A6=AC=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/apis/axios.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/client/src/apis/axios.ts b/apps/client/src/apis/axios.ts index 3d6e249..ba13f43 100644 --- a/apps/client/src/apis/axios.ts +++ b/apps/client/src/apis/axios.ts @@ -1,4 +1,4 @@ -import axios, { AxiosError } from 'axios'; +import axios, { AxiosError } from "axios"; const axiosInstance = axios.create({ baseURL: process.env.SERVER_URL, @@ -6,26 +6,29 @@ const axiosInstance = axios.create({ }); axiosInstance.interceptors.response.use( - response => { + (response) => { return response; }, - async error => { + async (error) => { const customError = error as AxiosError; const axiosError = customError.response?.status as number; - // 401 에러 응답 (인가 미들웨어에서 모든 토큰이 만료되었을때 401 리턴 -> 로그인 유도) - if ((axiosError === 401) && (window.location.pathname !== '/')) { - if (/^\/cake\/[^/]+$/.test(window.location.pathname)) { + if (axiosError === 401 && window.location.pathname !== "/") { + if ( + /^\/cake\/[^/]+$/.test(window.location.pathname) || + /^\/letter\/choose\/[^/]+$/.test(window.location.pathname) || + /^\/letter\/create\/[^/]+$/.test(window.location.pathname) + ) { return Promise.reject(error); } - window.location.replace('/'); + window.location.replace("/"); return Promise.reject(error); } // 500 에러 응답 if (axiosError === 500) { - console.log('서버 오류'); + console.log("서버 오류"); return Promise.reject(error); } @@ -35,8 +38,7 @@ axiosInstance.interceptors.response.use( } return Promise.reject(error); - }, + } ); - export default axiosInstance; From c4265af66cc48f409cc5c5cfdc75c74b3b4c534f Mon Sep 17 00:00:00 2001 From: kyr4601 Date: Mon, 19 May 2025 17:53:54 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Refactor:=20=EB=AA=A8=EB=8B=AC=20=EC=9B=B9?= =?UTF-8?q?=20=EC=A0=91=EA=B7=BC=EC=84=B1=20=EA=B0=95=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/components/modal/Modal.tsx | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/client/src/components/modal/Modal.tsx b/apps/client/src/components/modal/Modal.tsx index ecb1208..e3d4bee 100644 --- a/apps/client/src/components/modal/Modal.tsx +++ b/apps/client/src/components/modal/Modal.tsx @@ -1,18 +1,46 @@ -import React from 'react'; +import React, { useEffect, useRef } from 'react'; import styled from 'styled-components'; import { ModalPortal } from '../../ModalPortal'; const Modal = ({ open, + onClose, children, }: { open: boolean; + onClose: () => void; children: React.ReactNode; }) => { + const modalRef = useRef(null); + + useEffect(() => { + const handleKey = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + onClose(); + } + }; + + if (open) { + document.addEventListener('keydown', handleKey); + } + + return () => { + document.removeEventListener('keydown', handleKey); + }; + }, [open, onClose]); + return ( - {children} + + {children} + ); From 3f069df5bf8df737d0201bd6103179772ba106f1 Mon Sep 17 00:00:00 2001 From: kyr4601 Date: Mon, 19 May 2025 17:54:57 +0900 Subject: [PATCH 3/5] =?UTF-8?q?Chore:=20=EB=AA=A8=EB=8B=AC=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EB=B3=80=EA=B2=BD=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20prop=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/components/cake/CakeInfo.tsx | 16 ++++++--- apps/client/src/components/cake/GridInfo.tsx | 34 +++++++++++++------ .../client/src/components/cake/SharedCake.tsx | 18 ++++------ .../src/components/modal/LoginModal.tsx | 2 +- .../src/components/modal/ShareUrlModal.tsx | 8 ++--- apps/client/src/pages/ChooseCandle.tsx | 18 +++++----- 6 files changed, 54 insertions(+), 42 deletions(-) diff --git a/apps/client/src/components/cake/CakeInfo.tsx b/apps/client/src/components/cake/CakeInfo.tsx index cc07ced..8a091a8 100644 --- a/apps/client/src/components/cake/CakeInfo.tsx +++ b/apps/client/src/components/cake/CakeInfo.tsx @@ -21,7 +21,6 @@ import { useQueryClient } from '@tanstack/react-query'; import { useGetCakeLetters } from '#apis/cake/useGetCakeLetters.tsx'; import { useGetLetter } from '#apis/letter/useGetLetter.tsx'; - interface CakeInfoProps { year: string; sheetColor: CakeColorType | null; @@ -55,7 +54,11 @@ const CakeInfo: React.FC = ({ totalPage: 1, }); const queryClient = useQueryClient(); - const { data: cakeLettersData } = useGetCakeLetters(ownerId!, year, pageData.currentPage); + const { data: cakeLettersData } = useGetCakeLetters( + ownerId!, + year, + pageData.currentPage + ); const { data: letterData } = useGetLetter(selectedLetterId!); useEffect(() => { @@ -68,7 +71,8 @@ const CakeInfo: React.FC = ({ setCakeData(result.data); setPageData({ currentPage: result.currentPage, - totalPage: result.totalPage === 0 ? result.totalPage + 1 : result.totalPage, + totalPage: + result.totalPage === 0 ? result.totalPage + 1 : result.totalPage, }); } }, [cakeLettersData]); @@ -128,8 +132,10 @@ const CakeInfo: React.FC = ({ keyword={selectedItem?.keyword ?? ''} /> )} - - 편지 내용은 생일 이후에 확인할 수 있어요!{'\n'}두근두근...👉👈 + setOpen(false)}> + + 편지 내용은 생일 이후에 확인할 수 있어요!{'\n'}두근두근...👉👈 + - - - 편지를 작성하면 포인트를 얻을 수 있어요.{'\n'}로그인 하시겠어요? + setOpen(false)}> + + 편지를 작성하면 포인트를 얻을 수 있어요.{'\n'}로그인 하시겠어요? + @@ -87,4 +87,4 @@ const ShareBox = styled.div` justify-content: center; align-items: center; gap: 24px; -` +`; diff --git a/apps/client/src/pages/ChooseCandle.tsx b/apps/client/src/pages/ChooseCandle.tsx index 395ee3c..5c138e8 100644 --- a/apps/client/src/pages/ChooseCandle.tsx +++ b/apps/client/src/pages/ChooseCandle.tsx @@ -48,7 +48,7 @@ const ChooseCandle = () => { try { // 선택한 장식초 정보 가져오기 const candleResponse = await axiosInstance.get( - `/candle/${candleId}`, + `/candle/${candleId}` ); if (candleResponse.status === 200) { const data = CandleType.parse(candleResponse.data); @@ -118,7 +118,7 @@ const ChooseCandle = () => { if (candle.point === 0) { // 무료 장식초: 편지 페이지로 이동 navigate( - `/letter/create/${ownerId}?candleId=${candle.candleId}`, + `/letter/create/${ownerId}?candleId=${candle.candleId}` ); } else { // 유료 장식초: 결제 혹은 로그인 유도 모달 띄우기 @@ -135,7 +135,7 @@ const ChooseCandle = () => { ))} - + { gap: '1rem', }} > - - + setOpenSuccess(false)}> { setOpen(false)}> - + 편지를 작성하면 포인트를 얻을 수 있어요.{'\n'}로그인 하시겠어요?