diff --git a/components/app.js b/components/app.js index 4953678d908f9a0003f18402b89e0597d50e993c..6ae3e8602c78007f653be12c83f2274e24f98ba6 100644 --- a/components/app.js +++ b/components/app.js @@ -63,7 +63,6 @@ class App extends Component { const pageProps = { cycleDay: date && getCycleDay(date), date, - handleBackButtonPress: goBack, } return ( diff --git a/components/cycle-day/symptoms/bleeding.js b/components/cycle-day/symptoms/bleeding.js index a8ae709316dd8eb9edd65e296dc7f462dcc786e6..f0579c17ab7db31dd9c7e9b4986a5435307c3c31 100644 --- a/components/cycle-day/symptoms/bleeding.js +++ b/components/cycle-day/symptoms/bleeding.js @@ -14,7 +14,6 @@ class Bleeding extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -54,7 +53,6 @@ class Bleeding extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/cervix.js b/components/cycle-day/symptoms/cervix.js index 18513c6e255540112e5e0b19fe7bbd6a5b05d543..9966d71f25bf1bba868389728efe57fb1750503a 100644 --- a/components/cycle-day/symptoms/cervix.js +++ b/components/cycle-day/symptoms/cervix.js @@ -14,7 +14,6 @@ class Cervix extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -62,7 +61,6 @@ class Cervix extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/desire.js b/components/cycle-day/symptoms/desire.js index b6567dc244c8cb02b9ac4d7d14d113e103b54444..189836694f8a9850e419c0ec4b7aad9bb11bfa4a 100644 --- a/components/cycle-day/symptoms/desire.js +++ b/components/cycle-day/symptoms/desire.js @@ -13,7 +13,6 @@ class Desire extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -50,7 +49,6 @@ class Desire extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/mood.js b/components/cycle-day/symptoms/mood.js index 6bd34da2b0bb36dd68cc8bb33368ddd88be225b4..228d2ce00f5831a2778d506ba4590a76ddabcb05 100644 --- a/components/cycle-day/symptoms/mood.js +++ b/components/cycle-day/symptoms/mood.js @@ -13,7 +13,6 @@ class Mood extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -64,7 +63,6 @@ class Mood extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/mucus.js b/components/cycle-day/symptoms/mucus.js index 030745212683fd79012715b1e7b7283ab94c8598..2a57362b097a70e5c732305a1b0cd9a2d188554b 100644 --- a/components/cycle-day/symptoms/mucus.js +++ b/components/cycle-day/symptoms/mucus.js @@ -15,7 +15,6 @@ class Mucus extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -63,7 +62,6 @@ class Mucus extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/note.js b/components/cycle-day/symptoms/note.js index 158ae0b9264075335457b46b51de72e68abc815a..17cfef17169cebb709bec93766f24f1fce9ee249 100644 --- a/components/cycle-day/symptoms/note.js +++ b/components/cycle-day/symptoms/note.js @@ -39,7 +39,6 @@ class Note extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/pain.js b/components/cycle-day/symptoms/pain.js index 9dd1e2ceecd0e0e36a07e0e4b6186f54193ee24e..218eb38f31fd85d35d15a65c82adcccac8fedb13 100644 --- a/components/cycle-day/symptoms/pain.js +++ b/components/cycle-day/symptoms/pain.js @@ -14,7 +14,6 @@ class Pain extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -65,7 +64,6 @@ class Pain extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/sex.js b/components/cycle-day/symptoms/sex.js index d4dd170df46a46bbf06809dab9421bf18fa93fcb..5cb636eaef8b3ccb7955c585c7936c3ed9433eab 100644 --- a/components/cycle-day/symptoms/sex.js +++ b/components/cycle-day/symptoms/sex.js @@ -14,7 +14,6 @@ class Sex extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -65,7 +64,6 @@ class Sex extends Component { <SymptomView symptom={this.symptom} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/cycle-day/symptoms/symptom-view.js b/components/cycle-day/symptoms/symptom-view.js index a84d93dd30e26570603a9e90ccea468e56a7d8aa..82bb86bf9fb16922fd97824fa278b36805c8ec60 100644 --- a/components/cycle-day/symptoms/symptom-view.js +++ b/components/cycle-day/symptoms/symptom-view.js @@ -4,6 +4,7 @@ import PropTypes from 'prop-types' import { connect } from 'react-redux' import { getDate } from '../../../slices/date' +import { goBack } from '../../../slices/navigation' import { saveSymptom } from '../../../db' import formatDate from '../../helpers/format-date' @@ -27,8 +28,8 @@ class SymptomView extends Component { symptom: PropTypes.string.isRequired, values: PropTypes.object, date: PropTypes.string, - handleBackButtonPress: PropTypes.func, children: PropTypes.node, + goBack: PropTypes.func, } constructor(props) { @@ -52,7 +53,7 @@ class SymptomView extends Component { onDeleteConfirmation = () => { this.deleteSymptomEntry() - this.props.handleBackButtonPress() + this.props.goBack() } showConfirmationAlert = () => { @@ -75,13 +76,13 @@ class SymptomView extends Component { } render() { - const { symptom, date } = this.props + const { symptom, date, goBack } = this.props return ( <View style={{flex: 1}}> <Header title={headerTitles[symptom]} subtitle={formatDate(date)} - handleBack={this.props.handleBackButtonPress} + handleBack={goBack} handleDelete={ this.state.shouldShowDelete && this.showConfirmationAlert } @@ -99,11 +100,17 @@ class SymptomView extends Component { const mapStateToProps = (state) => { return({ - date: getDate(state) + date: getDate(state), + }) +} + +const mapDispatchToProps = (dispatch) => { + return({ + goBack: () => dispatch(goBack()), }) } export default connect( mapStateToProps, - null + mapDispatchToProps, )(SymptomView) diff --git a/components/cycle-day/symptoms/temperature.js b/components/cycle-day/symptoms/temperature.js index f73500114d1e89d68270abd10aae42f6e2566a27..5c033c926c5bc5326cb4ed1c7c22c4805c4ff1b9 100644 --- a/components/cycle-day/symptoms/temperature.js +++ b/components/cycle-day/symptoms/temperature.js @@ -20,7 +20,6 @@ class Temperature extends Component { static propTypes = { cycleDay: PropTypes.object, - handleBackButtonPress: PropTypes.func, date: PropTypes.string.isRequired, } @@ -90,7 +89,6 @@ class Temperature extends Component { <SymptomView symptom={'temperature'} values={this.state} - handleBackButtonPress={this.props.handleBackButtonPress} date={this.props.date} > <SymptomSection diff --git a/components/home.js b/components/home.js index 0b300cba80f0608160de1ae6bba07dc9930e8330..2b900d58a00e2b50efbc2110ea9ef07a0a329431 100644 --- a/components/home.js +++ b/components/home.js @@ -30,11 +30,10 @@ class Home extends Component { static propTypes = { navigate: PropTypes.func, setDate: PropTypes.func, - // The following three is not being used, + // The following are not being used, // we could see if it's possible to not pass them from the <App /> cycleDay: PropTypes.object, date: PropTypes.string, - handleBackButtonPress: PropTypes.func, } constructor(props) {