Only activate save button when time is a valid one
This commit is contained in:
@@ -80,16 +80,21 @@ export default class Temp extends Component {
|
|||||||
exclude: this.state.exclude,
|
exclude: this.state.exclude,
|
||||||
time: this.state.time
|
time: this.state.time
|
||||||
}
|
}
|
||||||
if (!cycleDay.temperature || cycleDay.temperature && !cycleDay.temperature.time) {
|
|
||||||
const now = LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString()
|
|
||||||
dataToSave.time = now
|
|
||||||
}
|
|
||||||
saveSymptom('temperature', cycleDay, dataToSave)
|
saveSymptom('temperature', cycleDay, dataToSave)
|
||||||
},
|
},
|
||||||
saveDisabled: this.state.currentValue === ''
|
saveDisabled: this.state.currentValue === '' || isInvalidTime(this.state.time)
|
||||||
})}
|
})}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isInvalidTime(timeString) {
|
||||||
|
try {
|
||||||
|
LocalTime.parse(timeString)
|
||||||
|
} catch (err) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user