From 50df9fefd8665ff42e53d17812cda711926def27 Mon Sep 17 00:00:00 2001 From: keeganbcgov Date: Mon, 29 Jan 2024 16:38:33 -0800 Subject: [PATCH] EDX-2170: enabled authorities opening on the current date to be displayed as an active authority. --- backend/src/routes/cache-router.js | 38 +++++++++++++++--------------- frontend/src/utils/common.js | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/backend/src/routes/cache-router.js b/backend/src/routes/cache-router.js index 95c166126..daeffe678 100644 --- a/backend/src/routes/cache-router.js +++ b/backend/src/routes/cache-router.js @@ -8,42 +8,42 @@ const constants = require('../util/constants'); const extendSession = utils.extendSession(); -router.get('/district/:districtId', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedDistrictByDistrictId); +router.get('/district/:districtId', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedDistrictByDistrictId); -router.get('/district', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedDistricts); +router.get('/district', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedDistricts); -router.get('/school', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedSchools); +router.get('/school', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedSchools); -router.get('/school/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedSchoolBySchoolID); +router.get('/school/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedSchoolBySchoolID); -router.get('/authority', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedAuthorities); +router.get('/authority', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedAuthorities); -router.get('/authority/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedAuthorityByAuthorityID); +router.get('/authority/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedAuthorityByAuthorityID); -router.get('/school-category-facility-type', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedSchoolCategoryFacilityTypes); +router.get('/school-category-facility-type', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedSchoolCategoryFacilityTypes); -router.get('/facility-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.FACILITY_TYPES,'server:institute:facilityTypeURL')); +router.get('/facility-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.FACILITY_TYPES,'server:institute:facilityTypeURL')); -router.get('/district-contact-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.DISTRICT_CONTACT_TYPE_CODES,'server:institute:facilityTypeURL')); +router.get('/district-contact-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.DISTRICT_CONTACT_TYPE_CODES,'server:institute:facilityTypeURL')); -router.get('/facility-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.FACILITY_TYPES,'server:institute:facilityTypeURL')); +router.get('/facility-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.FACILITY_TYPES,'server:institute:facilityTypeURL')); -router.get('/school-category-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_CATEGORY_TYPES,'server:institute:categoryCodesURL')); +router.get('/school-category-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_CATEGORY_TYPES,'server:institute:categoryCodesURL')); -router.get('/school-organization-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_ORGANIZATION_TYPES,'server:institute:organizationCodeURL')); +router.get('/school-organization-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_ORGANIZATION_TYPES,'server:institute:organizationCodeURL')); -router.get('/school-neighborhood-learning-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_NEIGHBOURHOOD_LEARNING_TYPES,'server:institute:neighbourhoodLearningURL')); +router.get('/school-neighborhood-learning-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_NEIGHBOURHOOD_LEARNING_TYPES,'server:institute:neighbourhoodLearningURL')); -router.get('/authority-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.AUTHORITY_TYPES,'server:institute:authorityTypeCodesURL')); +router.get('/authority-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.AUTHORITY_TYPES,'server:institute:authorityTypeCodesURL')); -router.get('/grade-codes', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.GRADE_CODES,'server:institute:gradeCodeURL')); +router.get('/grade-codes', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.GRADE_CODES,'server:institute:gradeCodeURL')); -router.get('/province-codes', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.PROVINCE_CODES,'server:institute:provinceCodesURL')); +router.get('/province-codes', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.PROVINCE_CODES,'server:institute:provinceCodesURL')); -router.get('/country-codes', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.COUNTRY_CODES,'server:institute:countryCodesURL')); +router.get('/country-codes', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.COUNTRY_CODES,'server:institute:countryCodesURL')); -router.get('/school-contact-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_CONTACT_TYPES,'server:institute:schoolContactTypeCodesURL')); +router.get('/school-contact-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.SCHOOL_CONTACT_TYPES,'server:institute:schoolContactTypeCodesURL')); -router.get('/authority-contact-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, utils.cacheMiddleware(), getCachedInstituteData(constants.CACHE_KEYS.AUTHORITY_CONTACT_TYPES,'server:institute:authorityContactTypeCodesURL')); +router.get('/authority-contact-types', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getCachedInstituteData(constants.CACHE_KEYS.AUTHORITY_CONTACT_TYPES,'server:institute:authorityContactTypeCodesURL')); module.exports = router; diff --git a/frontend/src/utils/common.js b/frontend/src/utils/common.js index fcd501fea..f628840d1 100644 --- a/frontend/src/utils/common.js +++ b/frontend/src/utils/common.js @@ -262,7 +262,7 @@ export function isOpenNotClosingAuthority(authority) { const currentTime = LocalDate.now(); const openedDate = authority?.openedDate; const closedDate = authority?.closedDate; - return authority?.name && openedDate && currentTime.isAfter(LocalDate.parse(openedDate, DateTimeFormatter.ISO_LOCAL_DATE_TIME)) && !closedDate; + return authority?.name && openedDate && !LocalDate.parse(openedDate, DateTimeFormatter.ISO_LOCAL_DATE_TIME).isAfter(currentTime) && !closedDate; } export function getRequestStore(requestType) {