import { Box, Card, CardContent, Chip, Grid, Typography } from '@mui/joy' import moment from 'moment' import React, { useState } from 'react' import Calendar from 'react-calendar' import 'react-calendar/dist/Calendar.css' import { useNavigate } from 'react-router-dom' import { UserContext } from '../../contexts/UserContext' import { getTextColorFromBackgroundColor, TASK_COLOR } from '../../utils/Colors' import './Calendar.css' const getAssigneeColor = (assignee, userProfile) => { return assignee === userProfile.id ? TASK_COLOR.ASSIGNED_TO_ME : TASK_COLOR.ASSIGNED_TO_OTHER } const CalendarView = ({ chores }) => { const { userProfile } = React.useContext(UserContext) const [selectedDate, setSeletedDate] = useState(null) const Navigate = useNavigate() const tileContent = ({ date, view }) => { if (view === 'month') { const dayChores = chores.filter(chore => { // Validate chore.nextDueDate before using it if (!chore.nextDueDate) return false const choreDate = new Date(chore.nextDueDate) if (isNaN(choreDate)) return false // Check if the date is invalid if (!date) return false return choreDate.toLocaleDateString() === date.toLocaleDateString() }) return (