From 7514b01cf4e183953506a159d080b9352a93c119 Mon Sep 17 00:00:00 2001 From: mashazyu Date: Wed, 2 Oct 2019 13:49:18 +0200 Subject: [PATCH] Naming update: isFertile>isClosedAndHard, getSymptomColorIndex>symptomColorMethods; update of symptom index retrieval for the sake of readibility --- components/chart/day-column.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/components/chart/day-column.js b/components/chart/day-column.js index 2404887..c7b3646 100644 --- a/components/chart/day-column.js +++ b/components/chart/day-column.js @@ -40,8 +40,14 @@ class DayColumn extends Component { this.getTemperatureProps(symptomData, columnHeight, dateString) } else { if (symptomData && ! symptomData.exclude) { - symptomDataToDisplay[symptom] = - (this.getSymptomColorIndex[symptom] || this.getSymptomColorIndex['default'])(symptomData) + // if symptomColorMethods entry doesn't exist for given symptom, + // 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) } - getSymptomColorIndex = { + symptomColorMethods = { 'mucus': (symptomData) => { const { feeling, texture } = symptomData const colorIndex = feeling + texture @@ -81,9 +87,10 @@ class DayColumn extends Component { 'cervix': (symptomData) => { const { opening, firmness } = symptomData const isDataComplete = opening !== null && firmness !== null - // is fertile? fertile only when opening=closed and firmness=hard (=0) - const isFertile = isDataComplete && (opening === 0 && firmness === 0) - const colorIndex = isFertile ? 0 : 2 + const isClosedAndHard = + isDataComplete && + (opening === 0 && firmness === 0) + const colorIndex = isClosedAndHard ? 0 : 2 return colorIndex }, 'sex': (symptomData) => {