import React, { Component } from 'react' import { CheckBox, ScrollView, Text, TextInput, View } from 'react-native' import styles from '../../../styles' import { saveSymptom } from '../../../db' import { pain as painLabels } from '../labels/labels' import ActionButtonFooter from './action-button-footer' 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 } } } render() { return ( {painLabels.cramps} { this.setState({cramps: val}) }} /> {painLabels.ovulationPain} { this.setState({ovulationPain: val}) }} /> {painLabels.headache} { this.setState({headache: val}) }} /> {painLabels.backache} { this.setState({backache: val}) }} /> {painLabels.nausea} { this.setState({nausea: val}) }} /> {painLabels.tenderBreasts} { this.setState({tenderBreasts: val}) }} /> {painLabels.migraine} { this.setState({migraine: val}) }} /> {painLabels.other} { this.setState({ other: val, focusTextArea: true }) }} /> { this.state.other && { this.setState({note: val}) }} /> } { const copyOfState = Object.assign({}, this.state) if (!copyOfState.other) { copyOfState.note = null } saveSymptom('pain', this.cycleDay, copyOfState) }} saveDisabled={Object.values(this.state).every(value => !value)} navigate={this.props.navigate} /> ) } }