diff --git a/src/app/(main)/dashboard/components/voyage-dashboard/CheckInWidget.tsx b/src/app/(main)/dashboard/components/voyage-dashboard/CheckInWidget.tsx index 56304a72..ff0ca1aa 100644 --- a/src/app/(main)/dashboard/components/voyage-dashboard/CheckInWidget.tsx +++ b/src/app/(main)/dashboard/components/voyage-dashboard/CheckInWidget.tsx @@ -4,13 +4,14 @@ import { ArrowRightIcon, DocumentCheckIcon } from "@heroicons/react/24/outline"; import { CheckCircleIcon } from "@heroicons/react/24/solid"; import React from "react"; import Link from "next/link"; -import { getDay } from "date-fns"; +import { isSameDay, sub } from "date-fns"; import Button from "@/components/Button"; import Badge from "@/components/badge/Badge"; import routePaths from "@/utils/routePaths"; import { getSprintCheckinIsStatus } from "@/utils/getFormStatus"; import type { User } from "@/store/features/user/userSlice"; -import { useUser } from "@/store/hooks"; +import { useSprint, useUser } from "@/store/hooks"; +import convertStringToDate from "@/utils/convertStringToDate"; interface CheckInWidgetProps { user: User | null; @@ -22,7 +23,8 @@ function CheckInWidget({ currentSprintNumber, teamId, }: CheckInWidgetProps) { - const { currentDate } = useUser(); + const { timezone, currentDate } = useUser(); + const sprintsData = useSprint(); const userDate = currentDate ?? new Date(); const sprintCheckinIsSubmitted = getSprintCheckinIsStatus( @@ -55,14 +57,26 @@ function CheckInWidget({ } const getBadgeValue = (userDate: Date): string => { - const dayOfWeek = getDay(userDate); + const currentSprintEndDate = sprintsData.voyage.sprints.find( + (sprint) => sprint.number === currentSprintNumber, + )?.endDate; - if (dayOfWeek >= 2 && dayOfWeek <= 6) { - return ""; - } else if (dayOfWeek === 0) { - return "Pending Submission"; - } else if (dayOfWeek === 1) { - return "Due today"; + if (currentSprintEndDate) { + const currentSprintEndDateInUserTimezone = convertStringToDate( + currentSprintEndDate, + timezone, + ); + + if (isSameDay(userDate, currentSprintEndDateInUserTimezone)) { + return "Due today"; + } else if ( + isSameDay( + userDate, + sub(currentSprintEndDateInUserTimezone, { days: 1 }), + ) + ) { + return "Pending Submission"; + } } return ""; diff --git a/src/app/(main)/my-voyage/[teamId]/ideation/components/IdeationForm.tsx b/src/app/(main)/my-voyage/[teamId]/ideation/components/IdeationForm.tsx index cc2f2624..12e46f4c 100644 --- a/src/app/(main)/my-voyage/[teamId]/ideation/components/IdeationForm.tsx +++ b/src/app/(main)/my-voyage/[teamId]/ideation/components/IdeationForm.tsx @@ -28,7 +28,7 @@ const validationSchema = z.object({ title: validateTextInput({ inputName: "Title", required: true, - minLen: 10, + minLen: 3, maxLen: 50, }), description: validateTextInput({ @@ -315,7 +315,7 @@ export default function IdeationForm() {