places todayString outside of reduce
This commit is contained in:
@@ -58,6 +58,7 @@ export default class CalendarView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toCalFormat(bleedingDaysSortedByDate) {
|
function toCalFormat(bleedingDaysSortedByDate) {
|
||||||
|
const todayDateString = LocalDate.now().toString()
|
||||||
return bleedingDaysSortedByDate.reduce((acc, day) => {
|
return bleedingDaysSortedByDate.reduce((acc, day) => {
|
||||||
acc[day.date] = {
|
acc[day.date] = {
|
||||||
customStyles: {
|
customStyles: {
|
||||||
@@ -66,7 +67,7 @@ function toCalFormat(bleedingDaysSortedByDate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (day.date === LocalDate.now().toString()) {
|
if (day.date === todayDateString) {
|
||||||
acc[day.date].customStyles.text = styles.calendarToday
|
acc[day.date].customStyles.text = styles.calendarToday
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
@@ -75,6 +76,7 @@ function toCalFormat(bleedingDaysSortedByDate) {
|
|||||||
|
|
||||||
function predictionToCalFormat(predictedDays) {
|
function predictionToCalFormat(predictedDays) {
|
||||||
if (!predictedDays.length) return {}
|
if (!predictedDays.length) return {}
|
||||||
|
const todayDateString = LocalDate.now().toString()
|
||||||
const middleIndex = (predictedDays[0].length - 1) / 2
|
const middleIndex = (predictedDays[0].length - 1) / 2
|
||||||
return predictedDays.reduce((acc, setOfDays) => {
|
return predictedDays.reduce((acc, setOfDays) => {
|
||||||
setOfDays.reduce((accSet, day, i) => {
|
setOfDays.reduce((accSet, day, i) => {
|
||||||
@@ -89,7 +91,7 @@ function predictionToCalFormat(predictedDays) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (day === LocalDate.now().toString()) {
|
if (day === todayDateString) {
|
||||||
accSet[day].customStyles.text = Object.assign(
|
accSet[day].customStyles.text = Object.assign(
|
||||||
{},
|
{},
|
||||||
styles.calendarToday,
|
styles.calendarToday,
|
||||||
|
|||||||
Reference in New Issue
Block a user