diff --git a/src/components/StudyCard/index.tsx b/src/components/StudyCard/index.tsx index 828bf17..8f7e720 100644 --- a/src/components/StudyCard/index.tsx +++ b/src/components/StudyCard/index.tsx @@ -1,4 +1,5 @@ -import { Card, CardHeader, CardBody, CardFooter, Text, Image, Progress, Link, Flex } from '@chakra-ui/react'; +import { Card, CardHeader, CardBody, CardFooter, Text, Image, Progress, Link, Flex, Badge } from '@chakra-ui/react'; +import dayjs from 'dayjs'; import CROP from '@/constants/crop'; @@ -15,6 +16,24 @@ const StudyCard = ({ studyProgressRatio, rank, }: StudyCardProps) => { + const currentDate = dayjs().format('YYYY-MM-DD'); + const isOngoing = + currentDate >= dayjs(startDate).format('YYYY-MM-DD') && + (currentDate <= dayjs(endDate).format('YYYY-MM-DD') || !endDate); + const isNotStarted = currentDate < dayjs(startDate).format('YYYY-MM-DD'); + + const getColorScheme = () => { + if (isNotStarted) return 'gray'; + if (isOngoing) return 'purple'; + return 'red'; + }; + + const getBadgeText = () => { + if (isNotStarted) return '진행 전'; + if (isOngoing) return '진행 중'; + return '종료'; + }; + return ( + + {getBadgeText()} +