import Calendar from 'react-calendar'
import { getPriorityColor } from '../../utils/Colors'
import styles from './Calendar.module.css'
const CalendarMonthly = ({ chores, onDateChange }) => {
const tileContent = ({ date, view }) => {
if (view === 'month') {
const dayChores = chores.filter(chore => {
const choreDate = new Date(chore.nextDueDate).toLocaleDateString()
const tileDate = date.toLocaleDateString()
return choreDate === tileDate
})
if (dayChores.length === 0) {
return (
)
}
if (dayChores.length > 3) {
return (
)
}
return (
{dayChores.map((chore, index) => {
return (
)
})}
)
}
return null
}
return (
{
onDateChange(new Date(d))
}}
// format the days from MON, TUE, WED, THU, FRI, SAT, SUN to first three letters:
formatShortWeekday={(locale, date) =>
['S', 'M', 'T', 'W', 'T', 'F', 'S'][date.getDay()]
}
// format month names to show only first 3 characters
formatMonth={(locale, date) => {
const monthNames = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
]
return monthNames[date.getMonth()]
}}
/>
)
}
export default CalendarMonthly