From cddaefd9420507318d71f56355ff5a6648dcd951 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 19 Jan 2025 13:55:40 +0000 Subject: feat: Change webhooks to be configurable by users --- .../components/settings/WebhookEventSelector.tsx | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 apps/web/components/settings/WebhookEventSelector.tsx (limited to 'apps/web/components/settings/WebhookEventSelector.tsx') diff --git a/apps/web/components/settings/WebhookEventSelector.tsx b/apps/web/components/settings/WebhookEventSelector.tsx new file mode 100644 index 00000000..ef357754 --- /dev/null +++ b/apps/web/components/settings/WebhookEventSelector.tsx @@ -0,0 +1,70 @@ +import { Button } from "@/components/ui/button"; +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, +} from "@/components/ui/command"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Check, ChevronsUpDown } from "lucide-react"; + +import { + ZWebhookEvent, + zWebhookEventSchema, +} from "@hoarder/shared/types/webhooks"; + +export function WebhookEventSelector({ + value, + onChange, +}: { + value: ZWebhookEvent[]; + onChange: (value: ZWebhookEvent[]) => void; +}) { + return ( + + + + + + + + + No events found. + + {zWebhookEventSchema.options.map((eventType) => ( + { + const newEvents = value.includes(eventType) + ? value.filter((e) => e !== eventType) + : [...value, eventType]; + onChange(newEvents); + }} + > + {eventType} + {value?.includes(eventType) && ( + + )} + + ))} + + + + + + ); +} -- cgit v1.2.3-70-g09d2