Skip to content

feat: set scheduled start date for submission phase #1465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ workflows:
context : org-global
filters: &filters-dev
branches:
only: ['develop']
only: ['develop', 'PLAT-2111']

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
68 changes: 19 additions & 49 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,8 @@
},
"devDependencies": {
"standard": "^12.0.1"
},
"volta": {
"node": "10.15.3"
}
}
18 changes: 15 additions & 3 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,16 @@ class ChallengeEditor extends Component {
}

onUpdatePhaseDate (phase, index) {
console.log('onUpdatePhase', phase, index)
const { phases } = this.state.challenge
let newChallenge = _.cloneDeep(this.state.challenge)

if (phase.isBlur && newChallenge.phases[index]['name'] === 'Submission') {
newChallenge.phases[index]['duration'] = _.max([
newChallenge.phases[index - 1]['duration'],
phase.duration
])
newChallenge.phases[index]['scheduledStartDate'] = moment(phase.startDate).toISOString()
newChallenge.phases[index]['scheduledEndDate'] =
moment(newChallenge.phases[index]['scheduledStartDate'])
.add(newChallenge.phases[index]['duration'], 'hours')
Expand All @@ -872,8 +875,9 @@ class ChallengeEditor extends Component {

for (let phaseIndex = index + 1; phaseIndex < phases.length; ++phaseIndex) {
if (newChallenge.phases[phaseIndex]['name'] === 'Submission') {
newChallenge.phases[phaseIndex]['scheduledStartDate'] =
newChallenge.phases[phaseIndex - 1]['scheduledStartDate']
console.log('Setting submission phase scheduled start date', moment(phase.startDate).toISOString())
newChallenge.phases[index]['scheduledStartDate'] = moment(phase.startDate).toISOString()

newChallenge.phases[phaseIndex]['duration'] = _.max([
newChallenge.phases[phaseIndex - 1]['duration'],
newChallenge.phases[phaseIndex]['duration']
Expand All @@ -890,6 +894,8 @@ class ChallengeEditor extends Component {
if (!_.isEqual(newChallenge.phases[index], phases[index])) {
this.setState({ isPhaseChange: true })
}
console.log('Setting new state', newChallenge)
console.log('isPhaseChange', this.state.isPhaseChange)
this.setState({ challenge: newChallenge })

setTimeout(() => {
Expand Down Expand Up @@ -937,17 +943,23 @@ class ChallengeEditor extends Component {
if (this.state.challenge.id) {
challenge.attachmentIds = _.map(attachments, item => item.id)
}
console.log('Phase Data', challenge.phases)
challenge.phases = challenge.phases.map((p) => pick([
'duration',
'phaseId',
'scheduledStartDate',
'scheduledEndDate'
], p))

if (challenge.terms && challenge.terms.length === 0) delete challenge.terms
delete challenge.attachments
delete challenge.reviewType
if (!isPhaseChange) delete challenge.phases
return _.cloneDeep(challenge)

const cloned = _.cloneDeep(challenge)
console.log('CLONED', cloned)

return cloned
}

goToEdit (challengeID) {
Expand Down
3 changes: 2 additions & 1 deletion src/util/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export const updateChallengePhaseBeforeSendRequest = (challengeDetail) => {
// challengeDetailTmp.submissionEndDate = moment(challengeDetail.phases[1].scheduledEndDate)
challengeDetailTmp.phases = challengeDetailTmp.phases.map((p) => ({
duration: p.duration * hourToSecond,
phaseId: p.phaseId
phaseId: p.phaseId,
scheduledStartDate: p.scheduledStartDate
}))
return challengeDetailTmp
}
Expand Down