fix: cycle status bug fix (#656)

This commit is contained in:
Anmol Singh Bhatia 2023-03-31 17:52:20 +05:30 committed by GitHub
parent f074f9f003
commit afd7741d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,16 +92,17 @@ export const timeAgo = (time: any) => {
export const getDateRangeStatus = (startDate: string | null, endDate: string | null) => {
if (!startDate || !endDate) return "draft";
const now = new Date();
const today = renderDateFormat(new Date());
const now = new Date(today);
const start = new Date(startDate);
const end = new Date(endDate);
if (end < now) {
return "completed";
} else if (start <= now && end >= now) {
if (start <= now && end >= now) {
return "current";
} else {
} else if (start > now) {
return "upcoming";
} else {
return "completed";
}
};
@ -170,4 +171,5 @@ export const renderShortTime = (date: string | Date) => {
return hours + ":" + minutes;
};
export const isDateRangeValid = (startDate: string, endDate: string)=> new Date(startDate) < new Date(endDate);
export const isDateRangeValid = (startDate: string, endDate: string) =>
new Date(startDate) < new Date(endDate);