import { useState } from 'react' import { ChevronLeft, ChevronRight } from 'lucide-react' interface Deadline { date: number month: number year: number label: string } const DEADLINES: Deadline[] = [ { date: 4, month: 4, year: 2025, label: 'Laporan Progress 1 Internify– 4 May' }, { date: 5, month: 4, year: 2025, label: 'Laporan Progress 1 Internify– 4 May' }, ] const DAY_LABELS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] const MONTH_NAMES = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ] function getDaysInMonth(year: number, month: number) { return new Date(year, month + 1, 0).getDate() } function getFirstDayOfMonth(year: number, month: number) { return new Date(year, month, 1).getDay() } const HomeCalendar = () => { const today = new Date() const [currentYear, setCurrentYear] = useState(2025) const [currentMonth, setCurrentMonth] = useState(4) // May = 4 (0-indexed) const daysInMonth = getDaysInMonth(currentYear, currentMonth) const firstDay = getFirstDayOfMonth(currentYear, currentMonth) const prevMonth = () => { if (currentMonth === 0) { setCurrentMonth(11) setCurrentYear(y => y - 1) } else { setCurrentMonth(m => m - 1) } } const nextMonth = () => { if (currentMonth === 11) { setCurrentMonth(0) setCurrentYear(y => y + 1) } else { setCurrentMonth(m => m + 1) } } const isToday = (day: number) => day === today.getDate() && currentMonth === today.getMonth() && currentYear === today.getFullYear() const hasDeadline = (day: number) => DEADLINES.some(d => d.date === day && d.month === currentMonth && d.year === currentYear) const upcomingDeadlines = DEADLINES.filter( d => d.month === currentMonth && d.year === currentYear ) // Previous month trailing days const prevMonthDays = getDaysInMonth(currentYear, currentMonth - 1 < 0 ? 11 : currentMonth - 1) const trailingDays = Array.from({ length: firstDay }, (_, i) => prevMonthDays - firstDay + 1 + i) // Current month days const currentDays = Array.from({ length: daysInMonth }, (_, i) => i + 1) // Next month leading days const totalCells = Math.ceil((firstDay + daysInMonth) / 7) * 7 const leadingDays = Array.from({ length: totalCells - firstDay - daysInMonth }, (_, i) => i + 1) // Bold dates (weekends or special) const isBold = (day: number) => { const d = new Date(currentYear, currentMonth, day).getDay() return d === 0 || d === 6 // Sun or Sat } return (
Upcoming Deadlines
{upcomingDeadlines.length > 0 ? (No upcoming deadlines this month.
)}