From 8a98ada8f37955a38a29045770ea5f53258c8c59 Mon Sep 17 00:00:00 2001 From: despiegk Date: Thu, 31 Oct 2024 08:00:48 +0100 Subject: [PATCH] ... --- .../src/components/calendar.tsx | 165 +--------------- .../src/components/eventform.tsx | 182 ++++++++++++++++++ 2 files changed, 186 insertions(+), 161 deletions(-) create mode 100644 react-shadcn-starter/src/components/eventform.tsx diff --git a/react-shadcn-starter/src/components/calendar.tsx b/react-shadcn-starter/src/components/calendar.tsx index 168847b..792e071 100644 --- a/react-shadcn-starter/src/components/calendar.tsx +++ b/react-shadcn-starter/src/components/calendar.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { addDays, format, startOfWeek, endOfWeek, startOfMonth, endOfMonth, eachDayOfInterval, isSameMonth, isSameDay, parseISO } from 'date-fns' -import { Calendar as CalendarIcon, ChevronLeft, ChevronRight, MoreHorizontal, Plus, Moon, Sun, Clock, X } from 'lucide-react' +import { ChevronLeft, ChevronRight, Plus, Moon, Sun, Clock, X } from 'lucide-react' import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd' import ReactMarkdown from 'react-markdown' import { v4 as uuidv4 } from 'uuid' @@ -8,8 +8,6 @@ import { v4 as uuidv4 } from 'uuid' import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" -import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" -import { Calendar } from "@/components/ui/calendar" import { Dialog, DialogContent, @@ -21,16 +19,8 @@ import { } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" -import { Textarea } from "@/components/ui/textarea" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select" -import { useToast } from "@/components/ui/use-toast" import { Switch } from "@/components/ui/switch" +import { useToast } from "@/components/ui/use-toast" import { Event, categories, @@ -40,6 +30,7 @@ import { WebDAVConfig } from '@/lib/calendar-data' import { CircleDataManager, Member } from '@/lib/circle-data' +import { EventForm } from './eventform' const dataManager = CalendarDataManager.getInstance(); const circleManager = CircleDataManager.getInstance(); @@ -50,7 +41,7 @@ interface CalendarProps { circleFile: string; } -function AttendeeSelector({ selectedAttendees, onAttendeeChange }: { +export function AttendeeSelector({ selectedAttendees, onAttendeeChange }: { selectedAttendees: string[]; onAttendeeChange: (attendees: string[]) => void; }) { @@ -421,154 +412,6 @@ export function OurCalendar({ webdavConfig, calendarFile, circleFile }: Calendar ) } -function EventForm({ onSubmit, initialData, isDarkMode }: { onSubmit: (event: Event) => void, initialData?: Event, isDarkMode: boolean }) { - const [title, setTitle] = React.useState(initialData?.title || '') - const [date, setDate] = React.useState(initialData ? parseISO(initialData.date) : undefined) - const [time, setTime] = React.useState(initialData?.time || '10:00') - const [duration, setDuration] = React.useState(initialData?.duration?.toString() || '60') - const [category, setCategory] = React.useState(initialData?.category || '') - const [content, setContent] = React.useState(initialData?.content || '') - const [attendees, setAttendees] = React.useState(initialData?.attendees || []) - const [isFullDay, setIsFullDay] = React.useState(initialData?.isFullDay || false) - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault() - if (title && date && category) { - const color = categories.find(c => c.name === category)?.color || 'bg-gray-500 dark:bg-gray-700' - onSubmit({ - id: initialData?.id || uuidv4(), - title, - date: date.toISOString().split('T')[0], - time: isFullDay ? '00:00' : time, - duration: parseInt(duration), - category, - color, - content, - attendees, - isFullDay - }) - } - } - - return ( -
-
- - setTitle(e.target.value)} - required - className="dark:bg-gray-700 dark:text-white dark:border-gray-600" - /> -
-
- - - - - - - - - -
-
- - -
- {!isFullDay && ( -
- - -
- )} - {!isFullDay && ( -
- - -
- )} -
- - -
-
- - -
-
- -