From 24310e2c115906bbc047332b50fbb8f583fcb9f9 Mon Sep 17 00:00:00 2001 From: Pankaj Sha Date: Sat, 28 Dec 2024 14:58:53 +0530 Subject: [PATCH] fix: create newEndsOn from current date when deadline has missed --- controllers/onboardingExtension.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controllers/onboardingExtension.ts b/controllers/onboardingExtension.ts index 2ca42e046..57fc524db 100644 --- a/controllers/onboardingExtension.ts +++ b/controllers/onboardingExtension.ts @@ -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; @@ -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,