From d1ee2d6f49aec6235541253079b970bf6e25cdf9 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Thu, 26 Oct 2023 11:23:09 -0700 Subject: [PATCH 1/2] fix: backend converstion for create school payload No longer breaks due to receiving a full DT string from the front end --- backend/src/components/edx/exchange.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/backend/src/components/edx/exchange.js b/backend/src/components/edx/exchange.js index 5f2a92e57..b58bc628a 100644 --- a/backend/src/components/edx/exchange.js +++ b/backend/src/components/edx/exchange.js @@ -6,10 +6,9 @@ const config = require('../../config'); const {getData, getCodeTable, putData} = require('../utils'); const utils = require('../utils'); const {FILTER_OPERATION, VALUE_TYPE, CACHE_KEYS} = require('../../util/constants'); -const {LocalDateTime, LocalDate, DateTimeFormatter, LocalTime, ChronoUnit} = require('@js-joda/core'); +const {LocalDateTime, DateTimeFormatter} = require('@js-joda/core'); const cacheService = require('../cache-service'); const log = require('../logger'); -const {omit, set} = require('lodash/fp'); async function claimAllExchanges(req, res) { try { @@ -1084,24 +1083,20 @@ async function createSchool(req, res) { }); } - const isEmptyString = str => typeof str === 'string' && str.trim() === ''; - const javaISOOpenedDateFrom = date => - LocalDateTime.of(LocalDate.parse(date), LocalTime.of(0,0,0,0).truncatedTo(ChronoUnit.SECONDS)) - .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); - - const {school, user} = req.body; + + const isEmptyString = str => typeof str === 'string' && str.trim() === ''; const userHasEmptyVals = Object.values(user) .reduce((result, currentValue) => result || isEmptyString(currentValue), false); const payload = { - school: set('districtId')(school.districtID)( - set('openedDate')(javaISOOpenedDateFrom(school.openedDate))( - omit('districtID')(school) - ) - ), + school: { + ...school, + districtId: school.districtID + }, initialEdxUser: userHasEmptyVals ? null : user }; + delete payload.school.districtID; const token = utils.getBackendToken(req); const userInfo = utils.getUser(req); From d491437dcc2f7f81948cb0c23159216169544876 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Thu, 26 Oct 2023 11:34:07 -0700 Subject: [PATCH 2/2] feat: better initial user label --- frontend/src/components/institute/NewSchoolPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/institute/NewSchoolPage.vue b/frontend/src/components/institute/NewSchoolPage.vue index a4c0b0b4c..14674abf8 100644 --- a/frontend/src/components/institute/NewSchoolPage.vue +++ b/frontend/src/components/institute/NewSchoolPage.vue @@ -463,7 +463,7 @@ -

Initial EDX User

+

Initial EDX Administrator