Merge branch 'fix-cycle-day-prop' into 'master'

Fix cycle day prop

See merge request bloodyhealth/drip!264
This commit is contained in:
Sofiya Tepikin
2020-02-29 11:07:57 +00:00
3 changed files with 9 additions and 14 deletions
+2 -12
View File
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
import { View, BackHandler } from 'react-native'
import PropTypes from 'prop-types'
import { LocalDate } from 'js-joda'
import { connect } from 'react-redux'
import { getDate, setDate } from '../slices/date'
@@ -27,13 +26,6 @@ class App extends Component {
constructor(props) {
super(props)
this.todayDateString = LocalDate.now().toString()
props.setDate(this.todayDateString)
this.state = {
cycleDay: getCycleDay(this.todayDateString),
}
this.backHandler = BackHandler.addEventListener(
'hardwareBackPress',
props.goBack
@@ -54,8 +46,6 @@ class App extends Component {
return false
}
const { cycleDay } = this.state
const Page = viewsList[currentPage]
const title = headerTitles[currentPage]
@@ -69,7 +59,7 @@ class App extends Component {
}
const pageProps = {
cycleDay,
cycleDay: date && getCycleDay(date),
date,
handleBackButtonPress: goBack,
}
@@ -108,4 +98,4 @@ const mapDispatchToProps = (dispatch) => {
export default connect(
mapStateToProps,
mapDispatchToProps
)(App)
)(App)
+5 -1
View File
@@ -4,6 +4,7 @@ import { ScrollView, View } from 'react-native'
import { connect } from 'react-redux'
import { navigate } from '../slices/navigation'
import { setDate } from '../slices/date'
import DripHomeIcon from '../assets/drip-home-icons'
import {
@@ -71,10 +72,12 @@ class Home extends Component {
}
navigateToCycleDayView = () => {
this.props.setDate(this.todayDateString)
this.props.navigate('CycleDay')
}
navigateToBleedingEditView = () => {
this.props.setDate(this.todayDateString)
this.props.navigate('BleedingEditView')
}
@@ -157,7 +160,8 @@ class Home extends Component {
const mapDispatchToProps = (dispatch) => {
return({
navigate: (page) => dispatch(navigate(page))
navigate: (page) => dispatch(navigate(page)),
setDate: (date) => dispatch(setDate(date)),
})
}
+2 -1
View File
@@ -1,8 +1,9 @@
import { createSlice } from 'redux-starter-kit'
import { LocalDate } from 'js-joda'
const dateSlice = createSlice({
slice: 'date',
initialState: null,
initialState: LocalDate.now().toString(),
reducers: {
setDate: (state, action) => action.payload
}