Merge remote-tracking branch 'origin/dev/guerby' into dev/cedric
This commit is contained in:
@@ -18,6 +18,7 @@ type Event struct {
|
|||||||
bun.BaseModel `bun:"table:events"`
|
bun.BaseModel `bun:"table:events"`
|
||||||
|
|
||||||
EventID uuid.UUID `bun:"event_id,type:uuid,pk,default:gen_random_uuid()" json:"id"`
|
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"`
|
CreationDate time.Time `bun:"creation_date,notnull,default:current_timestamp" json:"creationDate"`
|
||||||
ScheduleStart time.Time `bun:"schedule_start,notnull" json:"start"`
|
ScheduleStart time.Time `bun:"schedule_start,notnull" json:"start"`
|
||||||
ScheduleEnd time.Time `bun:"schedule_end,notnull" json:"end"`
|
ScheduleEnd time.Time `bun:"schedule_end,notnull" json:"end"`
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { KeyedMutator } from "swr";
|
import { KeyedMutator } from "swr";
|
||||||
import { getCookie } from "cookies-next";
|
import { getCookie } from "cookies-next";
|
||||||
import { useTheme } from "next-themes";
|
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<{
|
const Planning: React.FC<{
|
||||||
events: CalendarEventExternal[];
|
events: CalendarEventExternal[];
|
||||||
@@ -39,14 +47,15 @@ const Planning: React.FC<{
|
|||||||
const isConnected = getCookie("auth_token");
|
const isConnected = getCookie("auth_token");
|
||||||
const plugins = isConnected
|
const plugins = isConnected
|
||||||
? [
|
? [
|
||||||
createEventsServicePlugin(),
|
createEventsServicePlugin(),
|
||||||
createDragAndDropPlugin(),
|
createDragAndDropPlugin(),
|
||||||
createResizePlugin(),
|
createResizePlugin(),
|
||||||
createEventRecurrencePlugin(),
|
createEventRecurrencePlugin(),
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
const [eventSelected, setEventSelected] =
|
const [eventSelected, setEventSelected] =
|
||||||
useState<CalendarEventExternal | null>(null);
|
useState<CalendarEventExternal | null>(null);
|
||||||
|
const [eventStatus, setEventStatus] = useState<String>("Active")
|
||||||
const [newEvent, setNewEvent] = useState<Omit<
|
const [newEvent, setNewEvent] = useState<Omit<
|
||||||
CalendarEventExternal,
|
CalendarEventExternal,
|
||||||
"id"
|
"id"
|
||||||
@@ -155,13 +164,30 @@ const Planning: React.FC<{
|
|||||||
return ev;
|
return ev;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
onTitleChange={(e) => {
|
||||||
|
const val = e.currentTarget.value;
|
||||||
|
setNewEvent((ev) => {
|
||||||
|
if (ev)
|
||||||
|
return {
|
||||||
|
...ev,
|
||||||
|
title: val,
|
||||||
|
};
|
||||||
|
return ev;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
onActiveStateChange={(e) => {
|
||||||
|
e ? setEventStatus("Active")
|
||||||
|
: setEventStatus("Inactive")
|
||||||
|
}}
|
||||||
onAdd={async () => {
|
onAdd={async () => {
|
||||||
try {
|
try {
|
||||||
const event: Omit<CalendarEventExternal, "id"> = {
|
const event: Omit<CalendarEventExternal, "id"> = {
|
||||||
...newEvent,
|
...newEvent,
|
||||||
start: `${new Date(newEvent.start).toISOString()}`,
|
start: `${new Date(newEvent.start).toISOString()}`,
|
||||||
end: `${new Date(newEvent.end).toISOString()}`,
|
end: `${new Date(newEvent.end).toISOString()}`,
|
||||||
};
|
title: newEvent.title,
|
||||||
|
status: eventStatus
|
||||||
|
}
|
||||||
const res = await request<undefined>(
|
const res = await request<undefined>(
|
||||||
`/events/new`,
|
`/events/new`,
|
||||||
{
|
{
|
||||||
@@ -253,6 +279,8 @@ const EventDialog: React.FC<
|
|||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
onUpdate?: () => void;
|
onUpdate?: () => void;
|
||||||
onAdd?: () => void;
|
onAdd?: () => void;
|
||||||
|
onTitleChange?: React.ChangeEventHandler<HTMLInputElement>;
|
||||||
|
onActiveStateChange?: (status: boolean) => void;
|
||||||
event: CalendarEventExternal | Omit<CalendarEventExternal, "id">;
|
event: CalendarEventExternal | Omit<CalendarEventExternal, "id">;
|
||||||
} & DialogProps
|
} & DialogProps
|
||||||
> = ({
|
> = ({
|
||||||
@@ -263,22 +291,40 @@ const EventDialog: React.FC<
|
|||||||
onDelete,
|
onDelete,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onAdd,
|
onAdd,
|
||||||
|
onTitleChange,
|
||||||
|
onActiveStateChange,
|
||||||
event,
|
event,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
||||||
<DialogContent className="sm:max-w-md">
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>{event.title}</DialogTitle>
|
|
||||||
<DialogDescription>{event.description}</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
|
|
||||||
<div className="grid gap-4 py-4">
|
const [checked, setChecked] = useState<CheckedState>(event.status === "Active")
|
||||||
<div className="grid grid-cols-4 items-center gap-4">
|
|
||||||
<Label htmlFor="start" className="text-right">
|
return (
|
||||||
Début
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
</Label>
|
<DialogContent className="sm:max-w-md">
|
||||||
{/*<Popover>
|
<DialogHeader>
|
||||||
|
<DialogTitle>{event.title}</DialogTitle>
|
||||||
|
<DialogDescription>{event.description}</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
<div className="grid gap-4 py-4">
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label htmlFor="title" className="text-right">
|
||||||
|
Titre
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="title"
|
||||||
|
value={event.title || ""}
|
||||||
|
onChange={onTitleChange}
|
||||||
|
className="col-span-3"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label htmlFor="start" className="text-right">
|
||||||
|
Début
|
||||||
|
</Label>
|
||||||
|
{/*<Popover>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant={"outline"}
|
variant={"outline"}
|
||||||
@@ -317,53 +363,74 @@ const EventDialog: React.FC<
|
|||||||
/>
|
/>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover> */}
|
</Popover> */}
|
||||||
<Input
|
<Input
|
||||||
id="start"
|
id="start"
|
||||||
value={event.start || ""}
|
value={event.start || ""}
|
||||||
onChange={onStartChange}
|
onChange={onStartChange}
|
||||||
className="col-span-3"
|
className="col-span-3"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label htmlFor="end" className="text-right">
|
||||||
|
Fin
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="end"
|
||||||
|
value={event.end || ""}
|
||||||
|
onChange={onEndChange}
|
||||||
|
className="col-span-3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
|
<Label htmlFor="status" className="col-span-3 text-right">
|
||||||
|
Rendre cette évènement actif ?
|
||||||
|
</Label>
|
||||||
|
<Checkbox
|
||||||
|
id="status"
|
||||||
|
checked={
|
||||||
|
checked
|
||||||
|
}
|
||||||
|
onCheckedChange={(e) => {
|
||||||
|
const booleanCheck = !!e
|
||||||
|
setChecked(prev => { return !prev })
|
||||||
|
if (onActiveStateChange) {
|
||||||
|
onActiveStateChange(booleanCheck)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-4 items-center gap-4">
|
<div className="">
|
||||||
<Label htmlFor="end" className="text-right">
|
Date syntax : yyyy-MM-dd HH:mm
|
||||||
Fin
|
|
||||||
</Label>
|
|
||||||
<Input
|
|
||||||
id="end"
|
|
||||||
value={event.end || ""}
|
|
||||||
onChange={onEndChange}
|
|
||||||
className="col-span-3"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<DialogFooter className="flex flex-row justify-end">
|
||||||
<DialogFooter className="flex flex-row justify-end">
|
{onUpdate && (
|
||||||
{onUpdate && (
|
<Button
|
||||||
<Button
|
variant="outline"
|
||||||
variant="outline"
|
onClick={() => onUpdate()}
|
||||||
onClick={() => onUpdate()}
|
type="submit"
|
||||||
type="submit"
|
>
|
||||||
>
|
Actualiser
|
||||||
Actualiser
|
</Button>
|
||||||
</Button>
|
)}
|
||||||
)}
|
{onDelete && (
|
||||||
{onDelete && (
|
<Button
|
||||||
<Button
|
variant="destructive"
|
||||||
variant="destructive"
|
onClick={() => onDelete()}
|
||||||
onClick={() => onDelete()}
|
type="submit"
|
||||||
type="submit"
|
>
|
||||||
>
|
Supprimer
|
||||||
Supprimer
|
</Button>
|
||||||
</Button>
|
)}
|
||||||
)}
|
{onAdd && !onUpdate && !onDelete && (
|
||||||
{onAdd && !onUpdate && !onDelete && (
|
<Button onClick={() => onAdd()} type="submit">
|
||||||
<Button onClick={() => onAdd()} type="submit">
|
Créer
|
||||||
Créer
|
</Button>
|
||||||
</Button>
|
)}
|
||||||
)}
|
</DialogFooter>
|
||||||
</DialogFooter>
|
</DialogContent>
|
||||||
</DialogContent>
|
</Dialog>
|
||||||
</Dialog>
|
);
|
||||||
);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
export default Planning;
|
export default Planning;
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
"use client";
|
"use client"
|
||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react"
|
||||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
||||||
import { Check } from "lucide-react";
|
import { Check } from "lucide-react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
const Checkbox = React.forwardRef<
|
const Checkbox = React.forwardRef<
|
||||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<CheckboxPrimitive.Root
|
<CheckboxPrimitive.Root
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||||
className,
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<CheckboxPrimitive.Indicator
|
<CheckboxPrimitive.Indicator
|
||||||
className={cn("flex items-center justify-center text-current")}
|
className={cn("flex items-center justify-center text-current")}
|
||||||
>
|
>
|
||||||
<Check className="h-4 w-4" />
|
<Check className="h-4 w-4" />
|
||||||
</CheckboxPrimitive.Indicator>
|
</CheckboxPrimitive.Indicator>
|
||||||
</CheckboxPrimitive.Root>
|
</CheckboxPrimitive.Root>
|
||||||
));
|
))
|
||||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
||||||
|
|
||||||
export { Checkbox };
|
export { Checkbox }
|
||||||
|
|||||||
6
frontend/package-lock.json
generated
6
frontend/package-lock.json
generated
@@ -1993,9 +1993,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@schedule-x/calendar": {
|
"node_modules/@schedule-x/calendar": {
|
||||||
"version": "2.14.3",
|
"version": "2.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/@schedule-x/calendar/-/calendar-2.14.3.tgz",
|
"resolved": "https://registry.npmjs.org/@schedule-x/calendar/-/calendar-2.17.0.tgz",
|
||||||
"integrity": "sha512-JR2HxAOzaz+6DguGhT7gYp8ydJmIgbPeTd4hTDd05zyF6OoUcbEgFmiZDC5VvDTbThzjkS1a9v/OM2n0WAHcPA==",
|
"integrity": "sha512-a/Rpf+yOKjTpiMXNmZzhzlsF1/NvbUL4CRglHlY4Dn/oK/d3bOA1Q++y/Qzsv77y+cM7Ly1zLVl2aFvJNqT7Zg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user