diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..3c3629e6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/components/calendar/calendar-client.tsx b/components/calendar/calendar-client.tsx
index 8510f25f..e587c5fe 100644
--- a/components/calendar/calendar-client.tsx
+++ b/components/calendar/calendar-client.tsx
@@ -38,6 +38,12 @@ import { Badge } from "@/components/ui/badge";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
+import DatePicker, { registerLocale } from "react-datepicker";
+import "react-datepicker/dist/react-datepicker.css";
+import { fr } from 'date-fns/locale';
+
+// Register French locale
+registerLocale('fr', fr);
// Predefined professional color palette
const colorPalette = [
@@ -561,8 +567,8 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
setEventForm({
title: "",
description: null,
- start: startDate.toISOString().slice(0, 16),
- end: endDate.toISOString().slice(0, 16),
+ start: startDate.toISOString(),
+ end: endDate.toISOString(),
allDay: selectInfo.allDay,
location: null,
calendarId: selectedCalendarId,
@@ -693,6 +699,53 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
);
+ // Add these helper functions for date handling
+ const getDateFromString = (dateString: string) => {
+ return dateString ? new Date(dateString) : new Date();
+ };
+
+ const handleStartDateChange = (date: Date | null) => {
+ if (!date) return;
+
+ const endDate = getDateFromString(eventForm.end);
+ if (date > endDate) {
+ // If start date is after end date, set end date to start date + 1 hour
+ const newEndDate = new Date(date);
+ newEndDate.setHours(date.getHours() + 1);
+ setEventForm({
+ ...eventForm,
+ start: date.toISOString(),
+ end: newEndDate.toISOString(),
+ });
+ } else {
+ setEventForm({
+ ...eventForm,
+ start: date.toISOString(),
+ });
+ }
+ };
+
+ const handleEndDateChange = (date: Date | null) => {
+ if (!date) return;
+
+ const startDate = getDateFromString(eventForm.start);
+ if (date < startDate) {
+ // If end date is before start date, set start date to end date - 1 hour
+ const newStartDate = new Date(date);
+ newStartDate.setHours(date.getHours() - 1);
+ setEventForm({
+ ...eventForm,
+ start: newStartDate.toISOString(),
+ end: date.toISOString(),
+ });
+ } else {
+ setEventForm({
+ ...eventForm,
+ end: date.toISOString(),
+ });
+ }
+ };
+
return (
@@ -811,63 +864,90 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
{/* Event dialog */}