From 549114ca369e2e46b96342651244aee74f07f8df Mon Sep 17 00:00:00 2001 From: tnagorra Date: Fri, 6 Sep 2024 23:18:00 +0545 Subject: [PATCH] Use remainingDaysToStart for upcoming events --- src/utils/types.ts | 1 - .../DailyStandup/DeadlineSection/index.tsx | 24 ++++--------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/utils/types.ts b/src/utils/types.ts index f9f0a07..ac969f7 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -52,7 +52,6 @@ export interface GeneralEvent { typeDisplay: string; icon: React.ReactNode; name: string; - date: string; remainingDays: number; } diff --git a/src/views/DailyStandup/DeadlineSection/index.tsx b/src/views/DailyStandup/DeadlineSection/index.tsx index 28f9303..c19027a 100644 --- a/src/views/DailyStandup/DeadlineSection/index.tsx +++ b/src/views/DailyStandup/DeadlineSection/index.tsx @@ -9,10 +9,7 @@ import { FcNightLandscape, FcSportsMode, } from 'react-icons/fc'; -import { - compareDate, - getDifferenceInDays, -} from '@togglecorp/fujs'; +import { compareNumber } from '@togglecorp/fujs'; import { gql, useQuery, @@ -50,19 +47,13 @@ const DEADLINES_AND_EVENTS = gql` id name remainingDays - endDate - totalDays - usedDays - projectId } } relativeEvents { id name - startDate + remainingDaysToStart typeDisplay - dates - endDate type } } @@ -112,7 +103,6 @@ function DeadlineSection(props: Props) { typeDisplay: 'Deadline', icon: iconsMap.DEADLINE, name: deadline.name, - date: deadline.endDate, remainingDays: deadline.remainingDays, })) ?? []), ...(events?.map((otherEvent) => ({ @@ -121,14 +111,10 @@ function DeadlineSection(props: Props) { icon: iconsMap[otherEvent.type], typeDisplay: otherEvent.typeDisplay, name: otherEvent.name, - date: otherEvent.startDate, - remainingDays: getDifferenceInDays( - otherEvent.startDate, - date, - ), + remainingDays: otherEvent.remainingDaysToStart, })) ?? []), - ].sort((a, b) => compareDate(a.date, b.date)); - }, [events, projects, date]); + ].sort((a, b) => compareNumber(a.remainingDays, b.remainingDays)); + }, [events, projects]); return (