Skip to content

Commit 1c412af

Browse files
committed
Workaround for challenge API not returning scheduledStartDate for checkpoint submission
1 parent a5220d8 commit 1c412af

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/components/PhaseInput/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import moment from 'moment'
2-
import React from 'react'
2+
import React, { useEffect } from 'react'
33
import PropTypes from 'prop-types'
44
import styles from './PhaseInput.module.scss'
55
import cn from 'classnames'
@@ -31,6 +31,18 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex }) => {
3131
})
3232
}
3333

34+
useEffect(() => {
35+
if (!startDate) {
36+
let startDate = moment().format(dateFormat)
37+
let endDate = getEndDate(startDate, duration)
38+
onUpdatePhase({
39+
startDate,
40+
endDate,
41+
duration
42+
})
43+
}
44+
}, [startDate])
45+
3446
const onDurationChange = (e, isBlur = false) => {
3547
if (e.length > MAX_LENGTH) return null
3648

0 commit comments

Comments
 (0)