Skip to content

fix 1328 #1333

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 1 commit into from
Mar 10, 2022
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
25 changes: 22 additions & 3 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,28 @@ class ChallengeEditor extends Component {
}

onUpdatePhaseDate (phase, index) {
const { phases } = this.state.challenge
let newChallenge = _.cloneDeep(this.state.challenge)
newChallenge.phases[index]['duration'] = phase.duration
newChallenge.phases[index]['scheduledStartDate'] = phase.scheduledStartDate
newChallenge.phases[index]['scheduledEndDate'] = phase.scheduledEndDate
newChallenge.phases[index]['scheduledStartDate'] = phase.startDate
newChallenge.phases[index]['scheduledEndDate'] = phase.endDate

let lastDate = phase.endDate
for (let phaseIndex = index + 1; phaseIndex < phases.length; phaseIndex++) {
if (moment(phases[phaseIndex]['scheduledStartDate']).isBefore(lastDate)) {
lastDate = moment(lastDate).add('1', 'hour').format('MM/DD/YYYY HH:mm')
newChallenge.phases[phaseIndex]['scheduledStartDate'] = lastDate

if (moment(phases[phaseIndex]['scheduledEndDate']).isBefore(lastDate)) {
lastDate = moment(lastDate).add('1', 'hour').format('MM/DD/YYYY HH:mm')
newChallenge.phases[phaseIndex]['scheduledEndDate'] = lastDate
}

newChallenge.phases[phaseIndex]['duration'] =
moment(newChallenge.phases[phaseIndex]['scheduledEndDate']).diff(newChallenge.phases[phaseIndex]['scheduledStartDate'], 'hours')
}
}

this.setState({ challenge: newChallenge })
}

Expand Down Expand Up @@ -1594,7 +1612,8 @@ class ChallengeEditor extends Component {
phase={phase}
phaseIndex={uuidv4()}
readOnly={false}
isActive={this.isPhaseEditable(index)}
// isActive={this.isPhaseEditable(index)}
isActive
onUpdatePhase={(item) => {
if ((item.startDate && !moment(item.startDate).isSame(phase.scheduledStartDate)) ||
(item.endDate && !moment(item.endDate).isSame(phase.scheduledEndDate))
Expand Down
2 changes: 1 addition & 1 deletion src/components/PhaseInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
setEndDate(phase.scheduledEndDate)
setDuration(moment(phase.scheduledEndDate).diff(phase.scheduledStartDate, 'hours'))
}
}, [])
}, [phase])

useEffect(() => {
if (!readOnly) {
Expand Down