diff --git a/components/cervix.js b/components/cervix.js
deleted file mode 100644
index 0d9eb36..0000000
--- a/components/cervix.js
+++ /dev/null
@@ -1,155 +0,0 @@
-import React, { Component } from 'react'
-import {
- View,
- Button,
- Text,
- Switch
-} from 'react-native'
-import RadioForm from 'react-native-simple-radio-button'
-import { saveCervix } from '../db'
-import styles from '../styles/index'
-import {
- cervixPosition as positionLabels,
- cervixConsistency as consistencyLabels
-} from '../labels/labels'
-import computeSensiplanValue from '../lib/sensiplan-cervix'
-
-export default class Cervix extends Component {
- constructor(props) {
- super(props)
- this.cycleDay = props.cycleDay
- this.showView = props.showView
-
- let currentPositionValue = this.cycleDay.cervix && this.cycleDay.cervix.position
- if (typeof currentPositionValue !== 'number') {
- currentPositionValue = -1
- }
- let currentConsistencyValue = this.cycleDay.cervix && this.cycleDay.cervix.consistency
- if (typeof currentConsistencyValue !== 'number') {
- currentConsistencyValue = -1
- }
-
- this.state = {
- currentPositionValue,
- currentConsistencyValue,
- computeSensiplanValue,
- exclude: this.cycleDay.cervix ? this.cycleDay.cervix.exclude : false
- }
-
- }
-
- render() {
- const cervixPositionRadioProps = [
- {label: positionLabels[0], value: 0 },
- {label: positionLabels[1], value: 1 },
- {label: positionLabels[2], value: 2 }
- ]
- const cervixConsistencyRadioProps = [
- {label: consistencyLabels[0], value: 0 },
- {label: consistencyLabels[1], value: 1 }
- ]
- return(
-
-
-
-
-
- Cervix
-
-
-
- Position
-
-
-
- {
- this.setState({currentPositionValue: itemValue})
- }}
- />
-
-
-
- Consistency
-
-
-
- {
- this.setState({currentConsistencyValue: itemValue})
- }}
- />
-
-
-
-
-
-
-
- Exclude
-
-
-
- {
- this.setState({exclude: val})
- }}
- value={this.state.exclude}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )
- }
-}
diff --git a/components/cycle-day/symptoms/cervix.js b/components/cycle-day/symptoms/cervix.js
index 2ba7aa4..59d9d8b 100644
--- a/components/cycle-day/symptoms/cervix.js
+++ b/components/cycle-day/symptoms/cervix.js
@@ -20,20 +20,16 @@ export default class Cervix extends Component {
this.makeActionButtons = props.makeActionButtons
this.state = {
exclude: this.cycleDay.cervix ? this.cycleDay.cervix.exclude : false
- }
+ };
- this.state.currentOpeningValue = this.cycleDay.cervix && this.cycleDay.cervix.opening
- if (typeof this.state.currentOpeningValue !== 'number') {
- this.state.currentOpeningValue = -1
- }
- this.state.currentFirmnessValue = this.cycleDay.cervix && this.cycleDay.cervix.firmness
- if (typeof this.state.currentFirmnessValue !== 'number') {
- this.state.currentFirmnessValue = -1
- }
- this.state.currentPositionValue = this.cycleDay.cervix && this.cycleDay.cervix.position
- if (typeof this.state.currentPositionValue !== 'number') {
- this.state.currentPositionValue = -1
- }
+ /* eslint-disable react/no-direct-mutation-state */
+ ['opening', 'firmness', 'position'].forEach(label => {
+ this.state[label] = this.cycleDay.cervix && this.cycleDay.cervix[label]
+ if (typeof this.state[label] !== 'number') {
+ this.state[label] = -1
+ }
+ })
+ /* eslint-enable react/no-direct-mutation-state */
}
render() {
@@ -58,12 +54,12 @@ export default class Cervix extends Component {
{
- this.setState({currentOpeningValue: itemValue})
+ this.setState({opening: itemValue})
}}
/>
@@ -71,12 +67,12 @@ export default class Cervix extends Component {
{
- this.setState({currentFirmnessValue: itemValue})
+ this.setState({firmness: itemValue})
}}
/>
@@ -84,12 +80,12 @@ export default class Cervix extends Component {
{
- this.setState({currentPositionValue: itemValue})
+ this.setState({position: itemValue})
}}
/>
@@ -109,13 +105,13 @@ export default class Cervix extends Component {
cycleDay: this.cycleDay,
saveAction: () => {
saveSymptom('cervix', this.cycleDay, {
- opening: this.state.currentOpeningValue,
- firmness: this.state.currentFirmnessValue,
- position: this.state.currentPositionValue,
+ opening: this.state.opening,
+ firmness: this.state.firmness,
+ position: this.state.position,
exclude: this.state.exclude
})
},
- saveDisabled: this.state.currentOpeningValue === -1 || this.state.currentFirmnessValue === -1
+ saveDisabled: this.state.opening === -1 || this.state.firmness === -1
}
)}
diff --git a/components/cycle-day/symptoms/mucus.js b/components/cycle-day/symptoms/mucus.js
index f94a656..4a090d2 100644
--- a/components/cycle-day/symptoms/mucus.js
+++ b/components/cycle-day/symptoms/mucus.js
@@ -21,17 +21,17 @@ export default class Mucus extends Component {
this.makeActionButtons = props.makeActionButtons
this.state = {
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false
- }
+ };
- this.state.currentFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling
- if (typeof this.state.currentFeelingValue !== 'number') {
- this.state.currentFeelingValue = -1
- }
+ /* eslint-disable react/no-direct-mutation-state */
+ ['feeling', 'texture'].forEach(label => {
+ this.state[label] = this.cycleDay.mucus && this.cycleDay.mucus[label]
+ if (typeof this.state[label] !== 'number') {
+ this.state[label] = -1
+ }
+ })
+ /* eslint-enable react/no-direct-mutation-state */
- this.state.currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture
- if (typeof this.state.currentTextureValue !== 'number') {
- this.state.currentTextureValue = -1
- }
}
render() {
@@ -53,12 +53,12 @@ export default class Mucus extends Component {
{
- this.setState({ currentFeelingValue: itemValue })
+ this.setState({feeling: itemValue })
}}
/>
@@ -66,12 +66,12 @@ export default class Mucus extends Component {
{
- this.setState({ currentTextureValue: itemValue })
+ this.setState({texture: itemValue })
}}
/>
@@ -92,13 +92,13 @@ export default class Mucus extends Component {
cycleDay: this.cycleDay,
saveAction: () => {
saveSymptom('mucus', this.cycleDay, {
- feeling: this.state.currentFeelingValue,
- texture: this.state.currentTextureValue,
- computedNfp: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue),
+ feeling: this.state.feeling,
+ texture: this.state.texture,
+ computedNfp: computeSensiplanValue(this.state.feeling, this.state.texture),
exclude: this.state.exclude
})
},
- saveDisabled: this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1
+ saveDisabled: this.state.feeling === -1 || this.state.texture === -1
}
)}