checkbox for status visibility in frontend
This commit is contained in:
@@ -28,10 +28,13 @@ 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";
|
||||
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"
|
||||
status: "Active" | "Inactive"
|
||||
}
|
||||
|
||||
const Planning: React.FC<{
|
||||
@@ -183,7 +186,7 @@ const Planning: React.FC<{
|
||||
end: `${new Date(newEvent.end).toISOString()}`,
|
||||
title: newEvent.title,
|
||||
status: eventStatus
|
||||
}
|
||||
}
|
||||
const res = await request<undefined>(
|
||||
`/events/new`,
|
||||
{
|
||||
@@ -291,6 +294,9 @@ const EventDialog: React.FC<
|
||||
onActiveStateChange,
|
||||
event,
|
||||
}) => {
|
||||
|
||||
const [checked, setChecked] = useState<CheckedState>(event.status === "Active")
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
@@ -379,18 +385,23 @@ const EventDialog: React.FC<
|
||||
Rendre cette évènement actif ?
|
||||
</Label>
|
||||
<Checkbox
|
||||
className="grid-cols-4 p-0 m-0 h-4 w-4 border rounded"
|
||||
id="status"
|
||||
checked={true}
|
||||
checked={
|
||||
checked
|
||||
}
|
||||
onCheckedChange={(e) => {
|
||||
const isChecked = typeof e === "boolean" ? e : false;
|
||||
if (onActiveStateChange != undefined) {
|
||||
onActiveStateChange(isChecked)
|
||||
const booleanCheck = !!e
|
||||
setChecked(prev => { return !prev })
|
||||
if (onActiveStateChange) {
|
||||
onActiveStateChange(booleanCheck)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="">
|
||||
Date syntax : yyyy-MM-dd HH:mm
|
||||
</div>
|
||||
<DialogFooter className="flex flex-row justify-end">
|
||||
{onUpdate && (
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user