diff --git a/backend/core/models/events.go b/backend/core/models/events.go index e222922..35f4589 100644 --- a/backend/core/models/events.go +++ b/backend/core/models/events.go @@ -18,6 +18,7 @@ type Event struct { bun.BaseModel `bun:"table:events"` EventID uuid.UUID `bun:"event_id,type:uuid,pk,default:gen_random_uuid()" json:"id"` + Title string `bun:"title,notnull,default:'no title'" json:"title"` CreationDate time.Time `bun:"creation_date,notnull,default:current_timestamp" json:"creationDate"` ScheduleStart time.Time `bun:"schedule_start,notnull" json:"start"` ScheduleEnd time.Time `bun:"schedule_end,notnull" json:"end"` diff --git a/frontend/components/planning.tsx b/frontend/components/planning.tsx index 772aca8..3805fe3 100644 --- a/frontend/components/planning.tsx +++ b/frontend/components/planning.tsx @@ -28,6 +28,11 @@ import { Button } from "@/components/ui/button"; import { KeyedMutator } from "swr"; import { getCookie } from "cookies-next"; import { useTheme } from "next-themes"; +import { Checkbox } from "@radix-ui/react-checkbox"; + +interface CalendarEventExternalDB extends CalendarEventExternal { + status: "Active" | "Inactive" +} const Planning: React.FC<{ events: CalendarEventExternal[]; @@ -38,14 +43,15 @@ const Planning: React.FC<{ const isConnected = getCookie("auth_token"); const plugins = isConnected ? [ - createEventsServicePlugin(), - createDragAndDropPlugin(), - createResizePlugin(), - createEventRecurrencePlugin(), - ] + createEventsServicePlugin(), + createDragAndDropPlugin(), + createResizePlugin(), + createEventRecurrencePlugin(), + ] : []; const [eventSelected, setEventSelected] = useState(null); + const [eventStatus, setEventStatus] = useState("Active") const [newEvent, setNewEvent] = useState { + const val = e.currentTarget.value; + setNewEvent((ev) => { + if (ev) + return { + ...ev, + title: val, + }; + return ev; + }); + }} + onActiveStateChange={(e) => { + e ? setEventStatus("Active") + : setEventStatus("Inactive") + }} onAdd={async () => { try { const event: Omit = { ...newEvent, start: `${new Date(newEvent.start).toISOString()}`, end: `${new Date(newEvent.end).toISOString()}`, - }; + title: newEvent.title, + status: eventStatus + } const res = await request( `/events/new`, { @@ -252,6 +275,8 @@ const EventDialog: React.FC< onDelete?: () => void; onUpdate?: () => void; onAdd?: () => void; + onTitleChange?: React.ChangeEventHandler; + onActiveStateChange?: (status: boolean) => void; event: CalendarEventExternal | Omit; } & DialogProps > = ({ @@ -262,22 +287,37 @@ const EventDialog: React.FC< onDelete, onUpdate, onAdd, + onTitleChange, + onActiveStateChange, event, }) => { - return ( - - - - {event.title} - {event.description} - + return ( + + + + {event.title} + {event.description} + -
-
- - {/* +
+
+ + +
+ +
+ + {/*
+
+ + +
+
+ + { + const isChecked = typeof e === "boolean" ? e : false; + if (onActiveStateChange != undefined) { + onActiveStateChange(isChecked) + } + }} + /> +
-
- - -
-
- - {onUpdate && ( - - )} - {onDelete && ( - - )} - {onAdd && !onUpdate && !onDelete && ( - - )} - - -
- ); -}; + + {onUpdate && ( + + )} + {onDelete && ( + + )} + {onAdd && !onUpdate && !onDelete && ( + + )} + +
+
+ ); + }; export default Planning;