Naming update: isFertile>isClosedAndHard, getSymptomColorIndex>symptomColorMethods; update of symptom index retrieval for the sake of readibility

This commit is contained in:
mashazyu
2019-10-02 13:49:18 +02:00
committed by Sofiya Tepikin
parent f376602843
commit 7514b01cf4
+13 -6
View File
@@ -40,8 +40,14 @@ class DayColumn extends Component {
this.getTemperatureProps(symptomData, columnHeight, dateString) this.getTemperatureProps(symptomData, columnHeight, dateString)
} else { } else {
if (symptomData && ! symptomData.exclude) { if (symptomData && ! symptomData.exclude) {
symptomDataToDisplay[symptom] = // if symptomColorMethods entry doesn't exist for given symptom,
(this.getSymptomColorIndex[symptom] || this.getSymptomColorIndex['default'])(symptomData) // use 'default'
const getSymptomColorIndex =
this.symptomColorMethods[symptom] ||
this.symptomColorMethods['default']
getSymptomColorIndex(symptomData)
symptomDataToDisplay[symptom] = getSymptomColorIndex(symptomData)
} }
} }
@@ -72,7 +78,7 @@ class DayColumn extends Component {
}, extractedData) }, extractedData)
} }
getSymptomColorIndex = { symptomColorMethods = {
'mucus': (symptomData) => { 'mucus': (symptomData) => {
const { feeling, texture } = symptomData const { feeling, texture } = symptomData
const colorIndex = feeling + texture const colorIndex = feeling + texture
@@ -81,9 +87,10 @@ class DayColumn extends Component {
'cervix': (symptomData) => { 'cervix': (symptomData) => {
const { opening, firmness } = symptomData const { opening, firmness } = symptomData
const isDataComplete = opening !== null && firmness !== null const isDataComplete = opening !== null && firmness !== null
// is fertile? fertile only when opening=closed and firmness=hard (=0) const isClosedAndHard =
const isFertile = isDataComplete && (opening === 0 && firmness === 0) isDataComplete &&
const colorIndex = isFertile ? 0 : 2 (opening === 0 && firmness === 0)
const colorIndex = isClosedAndHard ? 0 : 2
return colorIndex return colorIndex
}, },
'sex': (symptomData) => { 'sex': (symptomData) => {