chore: copy helper functions from admin and space into @plane/utils (#6256)
* chore: copy helper functions from space to @plane/utils Co-Authored-By: sriram@plane.so <sriram@plane.so> * refactor: move enums from utils/auth.ts to @plane/constants/auth.ts Co-Authored-By: sriram@plane.so <sriram@plane.so> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: sriram@plane.so <sriram@plane.so>
This commit is contained in:
parent
043f4eaa5e
commit
9f5def3a6a
11 changed files with 651 additions and 3 deletions
|
|
@ -1,4 +1,12 @@
|
|||
import { ISSUE_PRIORITY_FILTERS, TIssuePriorities, TIssueFilterPriorityObject } from "@plane/constants";
|
||||
import { differenceInCalendarDays } from "date-fns";
|
||||
import {
|
||||
ISSUE_PRIORITY_FILTERS,
|
||||
STATE_GROUPS,
|
||||
TIssuePriorities,
|
||||
TIssueFilterPriorityObject
|
||||
} from "@plane/constants";
|
||||
import { TStateGroups } from "@plane/types";
|
||||
import { getDate } from "./datetime";
|
||||
|
||||
export const getIssuePriorityFilters = (priorityKey: TIssuePriorities): TIssueFilterPriorityObject | undefined => {
|
||||
const currentIssuePriority: TIssueFilterPriorityObject | undefined =
|
||||
|
|
@ -9,3 +17,26 @@ export const getIssuePriorityFilters = (priorityKey: TIssuePriorities): TIssueFi
|
|||
if (currentIssuePriority) return currentIssuePriority;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* @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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue