From 6476fa883f3760b93f1caa265643dbd7ff27de28 Mon Sep 17 00:00:00 2001 From: yoonc01 Date: Fri, 23 Aug 2024 00:19:40 +0900 Subject: [PATCH 1/2] edit miniQuizComponent --- service/src/pages/joinEvent/MiniQuiz.jsx | 26 ++++++++++++------------ service/src/utils/miniQuizUtils.js | 13 +++++++++--- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/service/src/pages/joinEvent/MiniQuiz.jsx b/service/src/pages/joinEvent/MiniQuiz.jsx index 972be49..2d28df3 100644 --- a/service/src/pages/joinEvent/MiniQuiz.jsx +++ b/service/src/pages/joinEvent/MiniQuiz.jsx @@ -6,27 +6,26 @@ import miniQuizIntro3 from '@/assets/images/miniQuizIntro3.svg'; import { getMillisecondsUntilNextSecond, getMillisecondsUntilNextHour, - getSecondsUntilNextHourFromNoon, + getSecondsUntilNextQuiz, } from '@/utils/miniQuizUtils'; import { useNavigate } from 'react-router-dom'; function MiniQuiz() { const navigate = useNavigate(); - const [seconds, setSeconds] = useState(() => - getSecondsUntilNextHourFromNoon(), - ); + const [seconds, setSeconds] = useState(() => getSecondsUntilNextQuiz()); const [countDownStart, setCountDownStart] = useState(false); useEffect(() => { const checkTime = () => { - const remainingTime = getSecondsUntilNextHourFromNoon(); + const remainingTime = getSecondsUntilNextQuiz(); //12시까지 몇 초 남았는지 계산 if (remainingTime !== -1) { + //-1이 아니면 12시와 13시 사이라는 의미로 카운트 다운 시작 setCountDownStart(true); } - const sleepTime = getMillisecondsUntilNextHour(); - const timeoutId = setTimeout(checkTime, sleepTime); + const sleepTime = getMillisecondsUntilNextHour(); //다음 정각까지 남은 시간 계산 + const timeoutId = setTimeout(checkTime, sleepTime); //다음 정각에 checkTime 함수 호출 return () => clearTimeout(timeoutId); }; @@ -36,14 +35,15 @@ function MiniQuiz() { useEffect(() => { if (countDownStart) { const tick = () => { - const remainingTime = getSecondsUntilNextHourFromNoon(); + const remainingTime = getSecondsUntilNextQuiz(); //퀴즈 시간까지 남은 초 확인 setSeconds(remainingTime); if (remainingTime !== -1) { - const timeoutId = setTimeout(tick, getMillisecondsUntilNextSecond()); + //12시와 13시 사이 + const timeoutId = setTimeout(tick, getMillisecondsUntilNextSecond()); //다음 초에 tick 함수 재호출로 남은 시간 재설정 return () => clearTimeout(timeoutId); } else { - setCountDownStart(false); + setCountDownStart(false); //12시와 13시 사이가 아니면 카운트 다운을 종료 } }; @@ -66,9 +66,9 @@ function MiniQuiz() { )}
- miniQuizIntro1 - miniQuizIntro2 - miniQuizIntro3 + miniQuizIntro1 + miniQuizIntro2 + miniQuizIntro3
diff --git a/service/src/utils/miniQuizUtils.js b/service/src/utils/miniQuizUtils.js index 84c6835..1f2250e 100644 --- a/service/src/utils/miniQuizUtils.js +++ b/service/src/utils/miniQuizUtils.js @@ -1,8 +1,14 @@ +/* + * 현재 시간에서 다음 초까지의 시간 계산(정확성을 위한 수단) + */ export function getMillisecondsUntilNextSecond() { const now = new Date(); return 1000 - now.getMilliseconds(); } +/* + * 다음 정각까지 남은 milli초 계산(정각마다 퀴즈 시작 1시간 전인지 확인을 하기에) + */ export function getMillisecondsUntilNextHour() { const now = new Date(); const millisecondsUntilNextHour = @@ -12,11 +18,12 @@ export function getMillisecondsUntilNextHour() { return millisecondsUntilNextHour; } -export function getSecondsUntilNextHourFromNoon() { +export function getSecondsUntilNextQuiz(hour = 13) { + //퀴즈 시간 변동 가능성에 따른 인자 전달 const now = new Date(); const currentHours = now.getHours(); - if (currentHours !== 12) { - return -1; + if (currentHours !== hour - 1) { + return -1; // 12시와 13시 사이(퀴즈 시작 1시간 이내)가 아니면 -1 반환 } return (60 - now.getMinutes()) * 60 - now.getSeconds(); } From 7babcb6c64bf9c609e26f185c3d6cb3f52e7f89e Mon Sep 17 00:00:00 2001 From: yoonc01 Date: Fri, 23 Aug 2024 10:34:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?layout=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/joinEvent/JoinEventIntroMain.jsx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/service/src/pages/joinEvent/JoinEventIntroMain.jsx b/service/src/pages/joinEvent/JoinEventIntroMain.jsx index 9b09b54..376fd60 100644 --- a/service/src/pages/joinEvent/JoinEventIntroMain.jsx +++ b/service/src/pages/joinEvent/JoinEventIntroMain.jsx @@ -68,33 +68,35 @@ function JoinEventIntroMain() {
-
+
캐스퍼 EV와 떠나기
-
- Day {day} +
+

+ Day {day} +

{scenario}
-
+
+ {isRewardButtonDisabled && ( + <> +
+
+ 이벤트에 참여해서 추첨을 위한 아이템을 모아보아요! +
+ + )}
- {isRewardButtonDisabled && ( - <> -
-
- 이벤트에 참여해서 추첨을 위한 아이템을 모아보아요! -
- - )}