From d2289e41c3b30458251ef590c7e381475d9c5589 Mon Sep 17 00:00:00 2001 From: despiegk Date: Thu, 31 Oct 2024 09:28:13 +0100 Subject: [PATCH] ... --- .../src/components/calendar/calendar.tsx | 101 +++++++----------- 1 file changed, 36 insertions(+), 65 deletions(-) diff --git a/react-shadcn-starter/src/components/calendar/calendar.tsx b/react-shadcn-starter/src/components/calendar/calendar.tsx index 8cd83c5..67dcfff 100644 --- a/react-shadcn-starter/src/components/calendar/calendar.tsx +++ b/react-shadcn-starter/src/components/calendar/calendar.tsx @@ -1,7 +1,6 @@ import * as React from 'react' import { addDays, format, startOfWeek, endOfWeek, startOfMonth, endOfMonth, eachDayOfInterval, isSameMonth, isSameDay, parseISO } from 'date-fns' import { ChevronLeft, ChevronRight, Plus, Moon, Sun, Clock, X } from 'lucide-react' -import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd' import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { @@ -272,20 +271,6 @@ export function OurCalendar({ webdavConfig, calendarFile, circleFile }: Calendar await saveCalendarData(events.filter(event => event.id !== id)) } - const onDragEnd = async (result: any) => { - if (!result.destination) return - - const newEvents = Array.from(events) - const [reorderedItem] = newEvents.splice(result.source.index, 1) - newEvents.splice(result.destination.index, 0, { - ...reorderedItem, - date: days[result.destination.droppableId].toISOString().split('T')[0], - }) - - setEvents(newEvents) - await saveCalendarData(newEvents) - } - return (
@@ -335,61 +320,47 @@ export function OurCalendar({ webdavConfig, calendarFile, circleFile }: Calendar
- -
- {['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((day) => ( -
- {day} -
- ))} - {days.map((day, index) => ( - - {(provided: any) => ( +
+ {['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map((day) => ( +
+ {day} +
+ ))} + {days.map((day) => ( +
+
{format(day, 'd')}
+ {events + .filter((event) => isSameDay(parseISO(event.date), day)) + .map((event) => (
setSelectedEvent(event)} > -
{format(day, 'd')}
- {events - .filter((event) => isSameDay(parseISO(event.date), day)) - .map((event, eventIndex) => ( - - {(provided: any) => ( -
setSelectedEvent(event)} - > -
- {event.title} - {!event.isFullDay && ( - - - {event.time} - - )} -
-
- )} -
- ))} - {provided.placeholder} +
+ {event.title} + {!event.isFullDay && ( + + + {event.time} + + )} +
- )} - - ))} -
- + ))} +
+ ))} +
{selectedEvent && (