Skip to content

Commit

Permalink
fix: create newEndsOn from current date when deadline has missed
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajjs committed Dec 28, 2024
1 parent b9145af commit 24310e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/onboardingExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const createOnboardingExtensionRequestController = async (req: Onboarding
let requestNumber: number;
let oldEndsOn: number;
let newEndsOn: number;
const currentDate = Date.now();

if(!latestExtensionRequest){
requestNumber = 1;
Expand All @@ -61,7 +62,12 @@ export const createOnboardingExtensionRequestController = async (req: Onboarding
oldEndsOn = latestExtensionRequest.newEndsOn;
}

newEndsOn = oldEndsOn + numberOfDaysInMillisecond;
if(currentDate > oldEndsOn){
newEndsOn = currentDate + numberOfDaysInMillisecond;
}
else {
newEndsOn = oldEndsOn + numberOfDaysInMillisecond;
}

const onboardingExtension = await createRequest({
type: REQUEST_TYPE.ONBOARDING,
Expand Down

0 comments on commit 24310e2

Please sign in to comment.