Skip to content
Snippets Groups Projects
Commit f1b6f000 authored by MALDONADO Kevin's avatar MALDONADO Kevin
Browse files

Merge branch 'CorrectionCalendarFormat' into 'main'

Correction de l'erreur sur la date de début du mois pour le calendrier,...

See merge request !11
parents f7190882 7bbbddfa
Branches
No related tags found
1 merge request!11Correction de l'erreur sur la date de début du mois pour le calendrier,...
import React, { useState } from 'react'; 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 { enUS } from 'date-fns/locale';
import { ChevronLeft, ChevronRight } from 'lucide-react'; import { ChevronLeft, ChevronRight } from 'lucide-react';
...@@ -15,6 +15,8 @@ const Calendar = () => { ...@@ -15,6 +15,8 @@ const Calendar = () => {
end: endOfMonth(currentDate), end: endOfMonth(currentDate),
}); });
const startDay = getDay(startOfMonth(currentDate));
return ( return (
<div className="space-y-6"> <div className="space-y-6">
<div className="bg-violet-100 rounded-2xl p-6"> <div className="bg-violet-100 rounded-2xl p-6">
...@@ -33,7 +35,7 @@ const Calendar = () => { ...@@ -33,7 +35,7 @@ const Calendar = () => {
</div> </div>
<div className="grid grid-cols-7 gap-2 text-center mb-2"> <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"> <div key={day} className="text-sm font-medium text-violet-800">
{day} {day}
</div> </div>
...@@ -41,6 +43,10 @@ const Calendar = () => { ...@@ -41,6 +43,10 @@ const Calendar = () => {
</div> </div>
<div className="grid grid-cols-7 gap-2"> <div className="grid grid-cols-7 gap-2">
{[...Array(startDay)].map((_, index) => (
<div key={`empty-${index}`} className="p-2"></div>
))}
{days.map(day => { {days.map(day => {
const isSelected = isSameDay(day, selectedDate); const isSelected = isSameDay(day, selectedDate);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment