Skip to content

Commit

Permalink
Merge pull request #1630 from bcgov/fix/create-school
Browse files Browse the repository at this point in the history
Remove breaking time conversion in create school
  • Loading branch information
mightycox authored Oct 26, 2023
2 parents 8ebe696 + d491437 commit c26e8f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
21 changes: 8 additions & 13 deletions backend/src/components/edx/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/institute/NewSchoolPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
</v-row>
<v-row>
<v-col>
<h3>Initial EDX User</h3>
<h3>Initial EDX Administrator</h3>
</v-col>
</v-row>
<v-row>
Expand Down

0 comments on commit c26e8f0

Please sign in to comment.