mirror of
https://github.com/makeplane/plane.git
synced 2025-12-24 15:49:36 +01:00
- Enhanced ESLint configuration by adding new rules for import consistency and type imports. - Refactored multiple files to replace regular imports with type imports for better clarity and performance. - Ensured consistent use of type imports across the application to align with TypeScript best practices. Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
30 lines
977 B
TypeScript
30 lines
977 B
TypeScript
import { differenceInCalendarDays } from "date-fns/differenceInCalendarDays";
|
|
// plane internal
|
|
import { STATE_GROUPS } from "@plane/constants";
|
|
import type { TStateGroups } from "@plane/types";
|
|
// helpers
|
|
import { getDate } from "@/helpers/date-time.helper";
|
|
|
|
/**
|
|
* @description check if the issue due date should be highlighted
|
|
* @param date
|
|
* @param stateGroup
|
|
* @returns boolean
|
|
*/
|
|
export const shouldHighlightIssueDueDate = (
|
|
date: string | Date | null,
|
|
stateGroup: TStateGroups | undefined
|
|
): boolean => {
|
|
if (!date || !stateGroup) return false;
|
|
// if the issue is completed or cancelled, don't highlight the due date
|
|
if ([STATE_GROUPS.completed.key, STATE_GROUPS.cancelled.key].includes(stateGroup)) return false;
|
|
|
|
const parsedDate = getDate(date);
|
|
if (!parsedDate) return false;
|
|
|
|
const targetDateDistance = differenceInCalendarDays(parsedDate, new Date());
|
|
|
|
// if the issue is overdue, highlight the due date
|
|
return targetDateDistance <= 0;
|
|
};
|