Get previous cycles before detecting fertility status
This commit is contained in:
+10
-6
@@ -1,18 +1,22 @@
|
||||
import getFertilityStatus from './sympto'
|
||||
import cycleModule from './cycle'
|
||||
|
||||
const { getCycleDaysBeforeDay } = cycleModule()
|
||||
const { getCycleDaysBeforeDay, getPreviousCycles } = cycleModule()
|
||||
|
||||
export default function (dateString) {
|
||||
const cycle = getCycleDaysBeforeDay(dateString)
|
||||
if (!cycle) return `We cannot show any cycle information because no menses has been entered`
|
||||
|
||||
// we get earliest last, but sympto wants earliest first
|
||||
const cycle = getCycleDaysBeforeDay(dateString).reverse()
|
||||
// const previousCycles = getPreviousCycles()
|
||||
const status = getFertilityStatus({cycle})
|
||||
cycle.reverse()
|
||||
const previousCycles = getPreviousCycles(cycle[0])
|
||||
previousCycles.forEach(cycle => cycle.reverse())
|
||||
|
||||
const status = getFertilityStatus({cycle, previousCycles})
|
||||
|
||||
return formatStatusForApp(status)
|
||||
}
|
||||
|
||||
function formatStatusForApp(status) {
|
||||
const fertileStatus = status.assumeFertility ? 'fertile' : 'infertile'
|
||||
return `You are currently ${fertileStatus}`
|
||||
return status.assumeFertility ? 'fertile' : 'infertile'
|
||||
}
|
||||
Reference in New Issue
Block a user