diff --git a/components/molecules/cards/PostThumbnailCard.tsx b/components/molecules/cards/PostThumbnailCard.tsx index c1f564d77..6f582fcca 100644 --- a/components/molecules/cards/PostThumbnailCard.tsx +++ b/components/molecules/cards/PostThumbnailCard.tsx @@ -167,9 +167,12 @@ export function PostThumbnailCard({ - - {badge && } - + {badge ? ( + + ) : ( + + )} + {participants && ( { if (studyVoteData) { setStudyPairArr(studyVoteData); diff --git a/pageTemplates/home/study/HomeStudyCol.tsx b/pageTemplates/home/study/HomeStudyCol.tsx index 77936af5e..51c378e02 100644 --- a/pageTemplates/home/study/HomeStudyCol.tsx +++ b/pageTemplates/home/study/HomeStudyCol.tsx @@ -1,7 +1,7 @@ import { ThemeTypings } from "@chakra-ui/react"; import dayjs from "dayjs"; -import { useSession } from "next-auth/react"; import { useSearchParams } from "next/navigation"; +import { useSession } from "next-auth/react"; import { useEffect, useState } from "react"; import { useRecoilValue } from "recoil"; @@ -17,6 +17,8 @@ import { STUDY_DATE_START_HOUR, STUDY_RESULT_HOUR, } from "../../../constants/serviceConstants/studyConstants/studyTimeConstant"; +import { useStudyResultDecideMutation } from "../../../hooks/study/mutations"; +import { getStudyConfimCondition } from "../../../libs/study/getStudyConfimCondition"; import StudyOpenCheckModal from "../../../modals/study/StudyOpenCheckModal"; import { studyDateStatusState } from "../../../recoils/studyRecoils"; import { IParticipation, StudyStatus } from "../../../types/models/studyTypes/studyDetails"; @@ -48,6 +50,8 @@ function HomeStudyCol({ studyVoteData, isLoading, date, isShort }: HomeStudyColP const [studyCardColData, setStudyCardColData] = useState(); const [dismissedStudy, setDismissedStudy] = useState(); + const { mutate: decideStudyResult } = useStudyResultDecideMutation(date); + useEffect(() => { if (!studyVoteData || !studyVoteData.length || !session?.user || !studyDateStatus) { setStudyCardColData(null); @@ -97,6 +101,10 @@ function HomeStudyCol({ studyVoteData, isLoading, date, isShort }: HomeStudyColP localStorage.setItem(STUDY_VOTING_TABLE, JSON.stringify(updatedTable)); } + + if (getStudyConfimCondition(studyDateStatus, studyVoteData[1].status)) { + decideStudyResult(); + } }, [studyDateStatus, studyVoteData]); return (