'use client'; import React, { useState, useMemo } from 'react'; interface Prayer { id: string; date: string; text: string; prayFor?: string; } interface CalendarViewProps { prayers: Prayer[]; onDayClick: (date: string) => void; } export default function CalendarView({ prayers, onDayClick }: CalendarViewProps) { const [currentMonth, setCurrentMonth] = useState(new Date()); const daysWithEntries = useMemo(() => { return new Set(prayers.map(p => p.date)); }, [prayers]); const getDaysInMonth = (date: Date) => { return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate(); }; const getFirstDayOfMonth = (date: Date) => { return new Date(date.getFullYear(), date.getMonth(), 1).getDay(); }; const daysInMonth = getDaysInMonth(currentMonth); const firstDay = getFirstDayOfMonth(currentMonth); const prevMonth = () => setCurrentMonth(new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1)); const nextMonth = () => setCurrentMonth(new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1)); const days = []; for (let i = 0; i < firstDay; i++) { days.push(null); } for (let i = 1; i <= daysInMonth; i++) { days.push(i); } return (
Click on days with entries to view them
Total Entries
{prayers.length}
Days with Entries
{daysWithEntries.size}