diff --git a/components/cycle-day/cycle-day-overview.js b/components/cycle-day/cycle-day-overview.js index 82a2d42..eeef9f2 100644 --- a/components/cycle-day/cycle-day-overview.js +++ b/components/cycle-day/cycle-day-overview.js @@ -44,44 +44,49 @@ export default class DayView extends Component { } render() { - const bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value let bleedingLabel - if (typeof bleedingValue === 'number') { - bleedingLabel = `${bleedingLabels[bleedingValue]}` - if (this.cycleDay.bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )" + if (this.cycleDay.bleeding) { + const bleeding = this.cycleDay.bleeding + if (typeof bleeding === 'number') { + bleedingLabel = `${bleedingLabels[bleeding]}` + if (bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )" + } } else { bleedingLabel = 'edit' } - const temperatureValue = this.cycleDay.temperature && this.cycleDay.temperature.value let temperatureLabel - if (typeof temperatureValue === 'number') { - temperatureLabel = `${temperatureValue} °C - ${this.cycleDay.temperature.time}` - if (this.cycleDay.temperature.exclude) { - temperatureLabel = "( " + temperatureLabel + " )" + if (this.cycleDay.temperature) { + const temperature = this.cycleDay.temperature + if (typeof temperature === 'number') { + temperatureLabel = `${temperature} °C - ${temperature.time}` + if (temperature.exclude) { + temperatureLabel = "( " + temperatureLabel + " )" + } } } else { temperatureLabel = 'edit' } - const mucusFeelingValue = this.cycleDay.mucus && this.cycleDay.mucus.feeling - const mucusTextureValue = this.cycleDay.mucus && this.cycleDay.mucus.texture - const mucusComputedValue = this.cycleDay.mucus && this.cycleDay.mucus.computedNfp let mucusLabel - if (typeof mucusFeelingValue === 'number' && typeof mucusTextureValue === 'number') { - mucusLabel = `${feelingLabels[mucusFeelingValue]} + ${textureLabels[mucusTextureValue]} ( ${computeSensiplanMucusLabels[mucusComputedValue]} )` - if (this.cycleDay.mucus.exclude) mucusLabel = "( " + mucusLabel + " )" + if (this.cycleDay.mucus) { + const mucus = this.cycleDay.mucus + if (typeof mucus.feeling === 'number' && typeof mucus.texture === 'number') { + mucusLabel = `${feelingLabels[mucus.feeling]} + ${textureLabels[mucus.texture]} ( ${computeSensiplanMucusLabels[mucus.computedNfp]} )` + if (mucus.exclude) mucusLabel = "( " + mucusLabel + " )" + } } else { mucusLabel = 'edit' } - const cervixOpeningValue = this.cycleDay.cervix && this.cycleDay.cervix.opening - const cervixFirmnessValue = this.cycleDay.cervix && this.cycleDay.cervix.firmness - const cervixPositionValue = this.cycleDay.cervix && this.cycleDay.cervix.position let cervixLabel - if (typeof cervixPositionValue === 'number' && typeof cervixOpeningValue === 'number') { - cervixLabel = `${openingLabels[cervixOpeningValue]} + ${firmnessLabels[cervixFirmnessValue]} ( ${positionLabels[cervixPositionValue]} )` - if (this.cycleDay.cervix.exclude) cervixLabel = "( " + cervixLabel + " )" + if (this.cycleDay.cervix) { + const cervix = this.cycleDay.cervix + if (cervix.opening > -1 && cervix.firmness > -1) { + cervixLabel = `${openingLabels[cervix.opening]} + ${firmnessLabels[cervix.firmness]}` + if (cervix.position > -1) cervixLabel += `+ ${positionLabels[cervix.position]}` + if (cervix.exclude) cervixLabel = "( " + cervixLabel + " )" + } } else { cervixLabel = 'edit' }