Add new home screen
This commit is contained in:
+27
-8
@@ -1,10 +1,13 @@
|
||||
import getFertilityStatus from './sympto'
|
||||
import cycleModule from './cycle'
|
||||
import { fertilityStatus } from '../components/cycle-day/labels/labels'
|
||||
import { fertilityStatus } from '../components/labels'
|
||||
|
||||
export function getFertilityStatusStringForDay(dateString) {
|
||||
export function getFertilityStatusForDay(dateString) {
|
||||
const status = getCycleStatusForDay(dateString)
|
||||
if (!status) return fertilityStatus.unknown
|
||||
if (!status) return {
|
||||
status: fertilityStatus.fertile,
|
||||
phase: null
|
||||
}
|
||||
|
||||
const phaseNameForDay = Object.keys(status.phases).find(phaseName => {
|
||||
const phase = status.phases[phaseName]
|
||||
@@ -18,7 +21,7 @@ export function getFertilityStatusStringForDay(dateString) {
|
||||
return dayIsAfterPhaseStart && dayIsBeforePhaseEnd
|
||||
})
|
||||
|
||||
return mapToString(phaseNameForDay, dateString, status)
|
||||
return formatStatus(phaseNameForDay, dateString, status)
|
||||
}
|
||||
|
||||
export function getCycleStatusForDay(dateString) {
|
||||
@@ -46,17 +49,33 @@ export function getCycleStatusForDay(dateString) {
|
||||
return getFertilityStatus(cycleInfo)
|
||||
}
|
||||
|
||||
function mapToString(phaseNameForDay, dateString, status) {
|
||||
function formatStatus(phaseNameForDay, dateString, status) {
|
||||
const mapping = {
|
||||
preOvulatory: () => fertilityStatus.infertile,
|
||||
preOvulatory: () => {
|
||||
return {
|
||||
status: fertilityStatus.infertile,
|
||||
phase: 1,
|
||||
statusText: fertilityStatus.preOvuText
|
||||
}
|
||||
},
|
||||
periOvulatory: (dateString, status) => {
|
||||
const phaseEnd = status.phases.periOvulatory.end
|
||||
if (phaseEnd && phaseEnd.date === dateString) {
|
||||
return fertilityStatus.fertileUntilEvening
|
||||
}
|
||||
return fertilityStatus.fertile
|
||||
return {
|
||||
status: fertilityStatus.fertile,
|
||||
phase: 2,
|
||||
statusText: fertilityStatus.periOvuText
|
||||
}
|
||||
},
|
||||
postOvulatory: () => fertilityStatus.infertile
|
||||
postOvulatory: (dateString, status) => {
|
||||
return {
|
||||
status: fertilityStatus.infertile,
|
||||
phase: 3,
|
||||
statusText: fertilityStatus.postOvuText(status.temperatureShift.rule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mapping[phaseNameForDay](dateString, status)
|
||||
|
||||
Reference in New Issue
Block a user