From 715cfcbafb2c585656e456f8de74c09fdad58d27 Mon Sep 17 00:00:00 2001 From: jhkang0516 <jhkang0516@ajou.ac.kr> Date: Sun, 10 Dec 2023 21:37:48 +0900 Subject: [PATCH] =?UTF-8?q?[EDIT]=20/result=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EB=82=A8=EC=9D=80=20=EC=8B=9C=EA=B0=84=20=EA=B3=84=EC=82=B0?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ResultMakeForm.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/react-whenMeet/src/components/ResultMakeForm.js b/react-whenMeet/src/components/ResultMakeForm.js index 4041fed..52c088a 100644 --- a/react-whenMeet/src/components/ResultMakeForm.js +++ b/react-whenMeet/src/components/ResultMakeForm.js @@ -108,22 +108,20 @@ function ResultMakeForm() { } const voteExpiresKST = new Date(meetingData.voteExpiresAt); - const now = new Date(); - const nowKST = new Date(now.getTime() + 9 * 60 * 60 * 1000); // UTC 시간에 9시간을 더해 KST로 조정 - + const nowKST = new Date(now.getTime()); // UTC 시간에 9시간을 더해 KST로 조정 const difference = voteExpiresKST - nowKST; - - if (difference > 0) { - return { - days: Math.floor(difference / (1000 * 60 * 60 * 24)), - hours: Math.floor((difference / (1000 * 60 * 60)) % 24), - minutes: Math.floor((difference / 1000 / 60) % 60), - seconds: Math.floor((difference / 1000) % 60), - }; - } else { + if (difference <= 0) { + navigate(`/resultend/${meeting_id}`); return { days: 0, hours: 0, minutes: 0, seconds: 0 }; } + + return { + days: Math.floor(difference / (1000 * 60 * 60 * 24)), + hours: Math.floor((difference / (1000 * 60 * 60)) % 24), + minutes: Math.floor((difference / 1000 / 60) % 60), + seconds: Math.floor((difference / 1000) % 60), + }; }; const updateTimer = () => { @@ -138,7 +136,7 @@ function ResultMakeForm() { const timerId = setInterval(updateTimer, 1000); return () => clearInterval(timerId); - }, [meetingData]); + }, [meetingData, navigate, meeting_id]); const handleEdit = async () => { try { -- GitLab