Merge branch 'fix-cycle-day-prop' into 'master'
Fix cycle day prop See merge request bloodyhealth/drip!264
This commit is contained in:
+1
-11
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
|
|||||||
import { View, BackHandler } from 'react-native'
|
import { View, BackHandler } from 'react-native'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { LocalDate } from 'js-joda'
|
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
import { getDate, setDate } from '../slices/date'
|
import { getDate, setDate } from '../slices/date'
|
||||||
@@ -27,13 +26,6 @@ class App extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.todayDateString = LocalDate.now().toString()
|
|
||||||
props.setDate(this.todayDateString)
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
cycleDay: getCycleDay(this.todayDateString),
|
|
||||||
}
|
|
||||||
|
|
||||||
this.backHandler = BackHandler.addEventListener(
|
this.backHandler = BackHandler.addEventListener(
|
||||||
'hardwareBackPress',
|
'hardwareBackPress',
|
||||||
props.goBack
|
props.goBack
|
||||||
@@ -54,8 +46,6 @@ class App extends Component {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cycleDay } = this.state
|
|
||||||
|
|
||||||
const Page = viewsList[currentPage]
|
const Page = viewsList[currentPage]
|
||||||
const title = headerTitles[currentPage]
|
const title = headerTitles[currentPage]
|
||||||
|
|
||||||
@@ -69,7 +59,7 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pageProps = {
|
const pageProps = {
|
||||||
cycleDay,
|
cycleDay: date && getCycleDay(date),
|
||||||
date,
|
date,
|
||||||
handleBackButtonPress: goBack,
|
handleBackButtonPress: goBack,
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -4,6 +4,7 @@ import { ScrollView, View } from 'react-native'
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
import { navigate } from '../slices/navigation'
|
import { navigate } from '../slices/navigation'
|
||||||
|
import { setDate } from '../slices/date'
|
||||||
|
|
||||||
import DripHomeIcon from '../assets/drip-home-icons'
|
import DripHomeIcon from '../assets/drip-home-icons'
|
||||||
import {
|
import {
|
||||||
@@ -71,10 +72,12 @@ class Home extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigateToCycleDayView = () => {
|
navigateToCycleDayView = () => {
|
||||||
|
this.props.setDate(this.todayDateString)
|
||||||
this.props.navigate('CycleDay')
|
this.props.navigate('CycleDay')
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToBleedingEditView = () => {
|
navigateToBleedingEditView = () => {
|
||||||
|
this.props.setDate(this.todayDateString)
|
||||||
this.props.navigate('BleedingEditView')
|
this.props.navigate('BleedingEditView')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +160,8 @@ class Home extends Component {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return({
|
||||||
navigate: (page) => dispatch(navigate(page))
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
|
setDate: (date) => dispatch(setDate(date)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
import { createSlice } from 'redux-starter-kit'
|
import { createSlice } from 'redux-starter-kit'
|
||||||
|
import { LocalDate } from 'js-joda'
|
||||||
|
|
||||||
const dateSlice = createSlice({
|
const dateSlice = createSlice({
|
||||||
slice: 'date',
|
slice: 'date',
|
||||||
initialState: null,
|
initialState: LocalDate.now().toString(),
|
||||||
reducers: {
|
reducers: {
|
||||||
setDate: (state, action) => action.payload
|
setDate: (state, action) => action.payload
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user