Skip to content

Commit

Permalink
PYIC-7933: use config to get post office visit by days
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshuit914 committed Jan 24, 2025
1 parent 9f49073 commit 7b520bb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/app/development/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getAppStoreRedirectUrl } from "../shared/appDownloadHelper";
import PAGES from "../../constants/ipv-pages";
import { getIpvPageTemplatePath, getTemplatePath } from "../../lib/paths";
import { pagesAndContexts } from "../../test-utils/pages-and-contexts";
import config from "../../config/config";

interface RadioOption {
text: string;
Expand Down Expand Up @@ -113,12 +114,8 @@ export const templatesDisplayGet: RequestHandler = async (req, res) => {
validatePhoneType(phoneType);
renderOptions.appDownloadUrl = getAppStoreRedirectUrl(phoneType);
} else if (templateId === PAGES.PAGE_FACE_TO_FACE_HANDOFF) {
let today = new Date();
if (process.env.NODE_ENV === "local") {
today = new Date("2025-01-01");
}
renderOptions.postOfficeVisitByDate = new Date().setDate(
today.getDate() + 15,
new Date("2025-01-01").getDate() + config.POST_OFFICE_VISIT_BY_DAYS,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/ipv/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export const handleJourneyPageRequest = async (
renderOptions.appDownloadUrl = getAppStoreRedirectUrl(context);
} else if (pageId === PAGES.PAGE_FACE_TO_FACE_HANDOFF) {
renderOptions.postOfficeVisitByDate = new Date().setDate(
new Date().getDate() + 15,
new Date().getDate() + config.POST_OFFICE_VISIT_BY_DAYS,
);
} else if (req.session.currentPageStatusCode !== undefined) {
// Set this to avoid pino-http generating a new error in the request log
Expand Down
1 change: 1 addition & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export default {
process.env.DELETE_ACCOUNT_URL ??
"https://home.build.account.gov.uk/enter-password?type=deleteAccount",
SSM_PARAMETER_CACHE_TTL: process.env.SSM_PARAMETER_CACHE_TTL ?? "300000", // Cache duration in milliseconds (5 minutes)
POST_OFFICE_VISIT_BY_DAYS: 15,
};

0 comments on commit 7b520bb

Please sign in to comment.