From b66c33a66cf4ff2fdaffc0c7c93e137348b8bfe7 Mon Sep 17 00:00:00 2001 From: LSJ Date: Fri, 6 Sep 2024 17:22:36 +0900 Subject: [PATCH] perf: study minimum vote hour --- components/services/studyVote/MapBottomNav.tsx | 5 +++++ components/services/studyVote/StudyVoteDrawer.tsx | 7 ++++++- pageTemplates/vote/VoteTimeDrawer.tsx | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/components/services/studyVote/MapBottomNav.tsx b/components/services/studyVote/MapBottomNav.tsx index e8545c5d1..bea45f44a 100644 --- a/components/services/studyVote/MapBottomNav.tsx +++ b/components/services/studyVote/MapBottomNav.tsx @@ -123,6 +123,11 @@ function MapBottomNav({ morePlaces, myVote, voteScore, setMyVote }: IMapBottomNa }; const onSubmit = () => { + const diffHour = voteTime.end.diff(voteTime.start, "hour"); + if (diffHour < 2) { + toast("warning", "최소 2시간은 선택되어야 합니다."); + return; + } studyVote({ ...myVote, ...voteTime, diff --git a/components/services/studyVote/StudyVoteDrawer.tsx b/components/services/studyVote/StudyVoteDrawer.tsx index e715760b1..f965dacc7 100644 --- a/components/services/studyVote/StudyVoteDrawer.tsx +++ b/components/services/studyVote/StudyVoteDrawer.tsx @@ -1,6 +1,6 @@ import dayjs from "dayjs"; -import { useParams } from "next/navigation"; import { useSession } from "next-auth/react"; +import { useParams } from "next/navigation"; import { useEffect, useState } from "react"; import { useQueryClient } from "react-query"; import { useRecoilValue } from "recoil"; @@ -94,6 +94,11 @@ export default function StudyVoteDrawer({ setIsModal }: IStudyVoteDrawer) { }; const onSubmit = () => { + const diffHour = voteTime.end.diff(voteTime.start, "hour"); + if (diffHour < 2) { + toast("warning", "최소 2시간은 선택되어야 합니다."); + return; + } const temp = { ...myVote, place: myVote.place, diff --git a/pageTemplates/vote/VoteTimeDrawer.tsx b/pageTemplates/vote/VoteTimeDrawer.tsx index d5ee1e53f..559d031a7 100644 --- a/pageTemplates/vote/VoteTimeDrawer.tsx +++ b/pageTemplates/vote/VoteTimeDrawer.tsx @@ -9,8 +9,8 @@ import { IBottomDrawerLgOptions } from "../../components/organisms/drawer/Bottom import StudyVoteTimeRulletDrawer from "../../components/services/studyVote/StudyVoteTimeRulletDrawer"; import { STUDY_VOTE, STUDY_VOTE_CNT } from "../../constants/keys/queryKeys"; import { - POINT_SYSTEM_PLUS, PointSystemProp, + POINT_SYSTEM_PLUS, } from "../../constants/serviceConstants/pointSystemConstants"; import { useToast } from "../../hooks/custom/CustomToast"; import { useStudyParticipationMutation } from "../../hooks/study/mutations"; @@ -108,6 +108,12 @@ function VoteTimeDrawer({ myVote, voterCnt, actionType, setActionType }: IVoteTi }; const onSubmit = () => { + const diffHour = voteTime.end.diff(voteTime.start, "hour"); + + if (diffHour < 2) { + toast("warning", "최소 2시간은 선택되어야 합니다."); + return; + } studyVote({ ...myVote, ...voteTime,