diff --git a/backend/core/models/events.go b/backend/core/models/events.go index e222922..f350f13 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" 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 57fe324..e4b18ef 100644 --- a/frontend/components/planning.tsx +++ b/frontend/components/planning.tsx @@ -29,6 +29,14 @@ import { Button } from "@/components/ui/button"; import { KeyedMutator } from "swr"; import { getCookie } from "cookies-next"; import { useTheme } from "next-themes"; +import { Checkbox } from "@/components/ui/checkbox"; +import { eventNames } from "process"; +import { useSearchParams } from "next/navigation"; +import { CheckedState } from "@radix-ui/react-checkbox"; + +interface CalendarEventExternalDB extends CalendarEventExternal { + status: "Active" | "Inactive" +} const Planning: React.FC<{ events: CalendarEventExternal[]; @@ -39,14 +47,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`, { @@ -253,6 +279,8 @@ const EventDialog: React.FC< onDelete?: () => void; onUpdate?: () => void; onAdd?: () => void; + onTitleChange?: React.ChangeEventHandler; + onActiveStateChange?: (status: boolean) => void; event: CalendarEventExternal | Omit; } & DialogProps > = ({ @@ -263,22 +291,40 @@ const EventDialog: React.FC< onDelete, onUpdate, onAdd, + onTitleChange, + onActiveStateChange, event, }) => { - return ( - - - - {event.title} - {event.description} - -
-
- - {/* + const [checked, setChecked] = useState(event.status === "Active") + + return ( + + + + {event.title} + {event.description} + + +
+
+ + +
+ +
+ + {/*
+
+ + +
+
+ + { + const booleanCheck = !!e + setChecked(prev => { return !prev }) + if (onActiveStateChange) { + onActiveStateChange(booleanCheck) + } + }} + /> +
-
- - +
+ Date syntax : yyyy-MM-dd HH:mm
-
- - {onUpdate && ( - - )} - {onDelete && ( - - )} - {onAdd && !onUpdate && !onDelete && ( - - )} - -
-
- ); -}; + + {onUpdate && ( + + )} + {onDelete && ( + + )} + {onAdd && !onUpdate && !onDelete && ( + + )} + + +
+ ); + }; export default Planning; diff --git a/frontend/components/ui/checkbox.tsx b/frontend/components/ui/checkbox.tsx index 577375b..c6fdd07 100644 --- a/frontend/components/ui/checkbox.tsx +++ b/frontend/components/ui/checkbox.tsx @@ -1,30 +1,30 @@ -"use client"; +"use client" -import * as React from "react"; -import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; -import { Check } from "lucide-react"; +import * as React from "react" +import * as CheckboxPrimitive from "@radix-ui/react-checkbox" +import { Check } from "lucide-react" -import { cn } from "@/lib/utils"; +import { cn } from "@/lib/utils" const Checkbox = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - - - - - -)); -Checkbox.displayName = CheckboxPrimitive.Root.displayName; + + + + + +)) +Checkbox.displayName = CheckboxPrimitive.Root.displayName -export { Checkbox }; +export { Checkbox } diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 38596ed..d136233 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1993,9 +1993,9 @@ "license": "MIT" }, "node_modules/@schedule-x/calendar": { - "version": "2.14.3", - "resolved": "https://registry.npmjs.org/@schedule-x/calendar/-/calendar-2.14.3.tgz", - "integrity": "sha512-JR2HxAOzaz+6DguGhT7gYp8ydJmIgbPeTd4hTDd05zyF6OoUcbEgFmiZDC5VvDTbThzjkS1a9v/OM2n0WAHcPA==", + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/@schedule-x/calendar/-/calendar-2.17.0.tgz", + "integrity": "sha512-a/Rpf+yOKjTpiMXNmZzhzlsF1/NvbUL4CRglHlY4Dn/oK/d3bOA1Q++y/Qzsv77y+cM7Ly1zLVl2aFvJNqT7Zg==", "license": "MIT", "peer": true, "peerDependencies": {