dirty-chai
This commit is contained in:
+19
-3
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user