dirty-chai

This commit is contained in:
Julia Friesel
2019-02-02 18:34:12 +01:00
parent 46aa596c7a
commit efca6f0d47
16 changed files with 36 additions and 2877 deletions
+19 -3
View File
@@ -1,4 +1,4 @@
import getFertilityStatus from './sympto'
import getFertilityStatus from 'sympto'
import cycleModule from './cycle'
import { useCervixObservable } from '../local-storage'
import { fertilityStatus as labels } from '../i18n/en/labels'
@@ -99,7 +99,23 @@ function formatStatus(phaseNameForDay, dateString, status) {
}
function formatCycleForSympto(cycle) {
const formatted = cycle.reduce((acc, oldDay) => {
// deep clone
const day = JSON.parse(JSON.stringify(oldDay));
// remove excluded symptoms
['bleeding', 'temperature', 'mucus', 'cervix'].forEach(symptomName => {
if (day[symptomName] && day[symptomName].exclude) {
delete day[symptomName]
}
});
// change format
['bleeding', 'temperature', 'mucus'].forEach(symptomName => {
if (day[symptomName]) day[symptomName] = day[symptomName].value
})
acc.push(day)
return acc
}, [])
// we get earliest last, but sympto wants earliest first
cycle.reverse()
return cycle
formatted.reverse()
return formatted
}