diff --git a/src/components/Calendar.jsx b/src/components/Calendar.jsx index 2a4a7ac046e61eead5ba2760879a3bf6947f9e1b..d3cb662abf9ef553020978b99b3f3a88dc4cb528 100644 --- a/src/components/Calendar.jsx +++ b/src/components/Calendar.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { format, addMonths, subMonths, startOfMonth, endOfMonth, eachDayOfInterval, isSameDay } from 'date-fns'; +import { format, addMonths, subMonths, startOfMonth, endOfMonth, eachDayOfInterval, getDay, isSameDay } from 'date-fns'; import { enUS } from 'date-fns/locale'; import { ChevronLeft, ChevronRight } from 'lucide-react'; @@ -15,6 +15,8 @@ const Calendar = () => { end: endOfMonth(currentDate), }); + const startDay = getDay(startOfMonth(currentDate)); + return ( <div className="space-y-6"> <div className="bg-violet-100 rounded-2xl p-6"> @@ -33,7 +35,7 @@ const Calendar = () => { </div> <div className="grid grid-cols-7 gap-2 text-center mb-2"> - {['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].map(day => ( + {['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(day => ( <div key={day} className="text-sm font-medium text-violet-800"> {day} </div> @@ -41,6 +43,10 @@ const Calendar = () => { </div> <div className="grid grid-cols-7 gap-2"> + {[...Array(startDay)].map((_, index) => ( + <div key={`empty-${index}`} className="p-2"></div> + ))} + {days.map(day => { const isSelected = isSameDay(day, selectedDate);