Skip to content

Commit

Permalink
#2808: Added a function in work-package.utils to get overdue work pac…
Browse files Browse the repository at this point in the history
…kages
  • Loading branch information
Jalen Wu authored and Jalen Wu committed Sep 19, 2024
1 parent 3d4bd95 commit eef96e2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/frontend/src/utils/work-package.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WbsElement, wbsPipe } from 'shared';
import { WbsElement, WbsElementStatus, wbsPipe, WorkPackage } from 'shared';
import { WPFormType } from './form';

export const getTitleFromFormType = (formType: WPFormType, wbsElement: WbsElement): string => {
Expand All @@ -11,3 +11,23 @@ export const getTitleFromFormType = (formType: WPFormType, wbsElement: WbsElemen
return `${wbsPipe(wbsElement.wbsNum)} - ${wbsElement.name}`;
}
};

/**
* Given a list of work packages, return the work packages that are overdue.
* @param wpList a list of work packages.
* @returns a list of work packages that are overdue.
*/
export const getOverdueWorkPackages = (wpList : WorkPackage[]) : WorkPackage[] => {
const overdueWorkPackages : WorkPackage[] = [];

for(let i = 0; i < wpList.length ; i++){
const curr = wpList[i];

// if the work package is anything but complete and the end date is before today, it is overdue.
if(curr.status !== WbsElementStatus.Complete && curr.endDate < new Date()){
overdueWorkPackages.push(curr);
}
}

return overdueWorkPackages;
};

0 comments on commit eef96e2

Please sign in to comment.