Skip to content

Commit

Permalink
#2806 created getUpcomingWorkPackages util
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalen Wu authored and Jalen Wu committed Sep 19, 2024
1 parent 3d4bd95 commit 0f95561
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 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, wbsPipe, WorkPackage } from 'shared';
import { WPFormType } from './form';

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

export const getUpcomingWorkPackages = (workPackages: WorkPackage[]): WorkPackage[] => {
const currentTime = new Date();
const twoWeeks = new Date();
twoWeeks.setDate(currentTime.getDate() + 14);
return workPackages.filter(({startDate}) => currentTime <= startDate && startDate <= twoWeeks);
}

0 comments on commit 0f95561

Please sign in to comment.