import React, { Component } from 'react' import { View, Text, Switch } from 'react-native' import RadioForm from 'react-native-simple-radio-button' import styles from '../../../styles' import { saveSymptom } from '../../../db' import { mucusFeeling as feelingLabels, mucusTexture as textureLabels } from '../labels/labels' import computeSensiplanValue from '../../../lib/sensiplan-mucus' export default class Mucus extends Component { constructor(props) { super(props) this.cycleDay = props.cycleDay 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 } this.state.currentTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture if (typeof this.state.currentTextureValue !== 'number') { this.state.currentTextureValue = -1 } } render() { const mucusFeelingRadioProps = [ {label: feelingLabels[0], value: 0 }, {label: feelingLabels[1], value: 1 }, {label: feelingLabels[2], value: 2 }, {label: feelingLabels[3], value: 3 } ] const mucusTextureRadioProps = [ {label: textureLabels[0], value: 0 }, {label: textureLabels[1], value: 1 }, {label: textureLabels[2], value: 2 } ] return( Mucus Feeling { this.setState({ currentFeelingValue: itemValue }) }} /> Texture { this.setState({ currentTextureValue: itemValue }) }} /> Exclude { this.setState({ exclude: val }) }} value={this.state.exclude} /> {this.makeActionButtons( { symptom: 'mucus', cycleDay: this.cycleDay, saveAction: () => { saveSymptom('mucus', this.cycleDay, { feeling: this.state.currentFeelingValue, texture: this.state.currentTextureValue, value: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue), exclude: this.state.exclude }) }, saveDisabled: this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1 } )} ) } }