diff --git a/app/vision/page.tsx b/app/vision/page.tsx index f3e015a..a13be64 100644 --- a/app/vision/page.tsx +++ b/app/vision/page.tsx @@ -7,7 +7,7 @@ import { ResponsiveIframe } from "@/app/components/responsive-iframe"; import { Users, FolderKanban, Video, ArrowLeft, Loader2, Calendar, Clock, Plus, X } from "lucide-react"; import { Button } from "@/components/ui/button"; import { useToast } from "@/components/ui/use-toast"; -import { Calendar as CalendarComponent } from "@/components/ui/calendar"; +import { CalendarClient } from "@/components/calendar/calendar-client"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; @@ -52,6 +52,8 @@ export default function VisionPage() { const [scheduledMeetings, setScheduledMeetings] = useState([]); const [showMeetingDialog, setShowMeetingDialog] = useState(false); const [selectedDate, setSelectedDate] = useState(new Date()); + const [calendars, setCalendars] = useState([]); + const [calendarsLoading, setCalendarsLoading] = useState(true); const [meetingForm, setMeetingForm] = useState<{ type: "group" | "mission" | ""; entityId: string; @@ -96,6 +98,32 @@ export default function VisionPage() { } }, [scheduledMeetings, session, status]); + // Fetch calendars + useEffect(() => { + const fetchCalendars = async () => { + if (status !== "authenticated" || !session?.user?.id) { + return; + } + + try { + setCalendarsLoading(true); + const response = await fetch("/api/calendars"); + if (response.ok) { + const calendarsData = await response.json(); + setCalendars(Array.isArray(calendarsData) ? calendarsData : []); + } else { + console.error("Failed to fetch calendars"); + } + } catch (error) { + console.error("Error fetching calendars:", error); + } finally { + setCalendarsLoading(false); + } + }; + + fetchCalendars(); + }, [session, status]); + // Fetch user groups and missions useEffect(() => { const fetchData = async () => { @@ -378,74 +406,75 @@ export default function VisionPage() {
- {/* Colonne calendrier (étroite) */} + {/* Colonne calendrier (étroite) - CalendarClient avec dimensions réduites */}
-