Replace getOrCreateCycleDay
This commit is contained in:
@@ -11,43 +11,17 @@ import SelectBoxGroup from '../select-box-group'
|
||||
import SymptomSection from './symptom-section'
|
||||
import styles from '../../../styles'
|
||||
|
||||
const categories = labels.categories
|
||||
const boxes = [{
|
||||
label: categories.cramps,
|
||||
stateKey: 'cramps'
|
||||
}, {
|
||||
label: categories.ovulationPain,
|
||||
stateKey: 'ovulationPain'
|
||||
}, {
|
||||
label: categories.headache,
|
||||
stateKey: 'headache'
|
||||
}, {
|
||||
label: categories.backache,
|
||||
stateKey: 'backache'
|
||||
}, {
|
||||
label: categories.nausea,
|
||||
stateKey: 'nausea'
|
||||
}, {
|
||||
label: categories.tenderBreasts,
|
||||
stateKey: 'tenderBreasts'
|
||||
}, {
|
||||
label: categories.migraine,
|
||||
stateKey: 'migraine'
|
||||
}, {
|
||||
label: categories.other,
|
||||
stateKey: 'other'
|
||||
}]
|
||||
|
||||
export default class Pain extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.cycleDay = props.cycleDay
|
||||
this.state = {}
|
||||
if (this.cycleDay.pain !== null ) {
|
||||
Object.assign(this.state, this.cycleDay.pain)
|
||||
if (this.cycleDay.pain && this.cycleDay.pain.note) {
|
||||
this.state.other = true
|
||||
}
|
||||
const cycleDay = props.cycleDay
|
||||
if (cycleDay && cycleDay.pain) {
|
||||
this.state = Object.assign({}, cycleDay.pain)
|
||||
} else {
|
||||
this.state = {}
|
||||
}
|
||||
if (this.state.note) {
|
||||
this.state.other = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +41,7 @@ export default class Pain extends Component {
|
||||
explainer={labels.explainer}
|
||||
>
|
||||
<SelectBoxGroup
|
||||
data={boxes}
|
||||
labels={labels.categories}
|
||||
onSelect={this.toggleState}
|
||||
optionsState={this.state}
|
||||
/>
|
||||
@@ -86,13 +60,14 @@ export default class Pain extends Component {
|
||||
</ScrollView>
|
||||
<ActionButtonFooter
|
||||
symptom='pain'
|
||||
cycleDay={this.cycleDay}
|
||||
date={this.props.date}
|
||||
currentSymptomValue={this.state}
|
||||
saveAction={() => {
|
||||
const copyOfState = Object.assign({}, this.state)
|
||||
if (!copyOfState.other) {
|
||||
copyOfState.note = null
|
||||
}
|
||||
saveSymptom('pain', this.cycleDay, copyOfState)
|
||||
saveSymptom('pain', this.props.date, copyOfState)
|
||||
}}
|
||||
saveDisabled={Object.values(this.state).every(value => !value)}
|
||||
navigate={this.props.navigate}
|
||||
|
||||
Reference in New Issue
Block a user