| 1 | "use client"; |
| 2 | |
| 3 | import { Checkbox } from |
| 4 | import { |
| 5 | type WebhookEvent, |
| 6 | webhookEventLabels, |
| 7 | webhookEvents, |
| 8 | } from "@/lib/webhooks"; |
| 9 | |
| 10 | export function EventPicker({ |
| 11 | value, |
| 12 | onChange, |
| 13 | }: { |
| 14 | value: WebhookEvent |
| 15 | onChange: (events |
| 16 | }) { |
| 17 | const toggle = |
| 18 | onChange( |
| 19 | checked |
| 20 | ? webhookEvents.filter( |
| 21 | : value.filter( |
| 22 | ); |
| 23 | |
| 24 | return ( |
| 25 | <fieldset className="flex flex-col gap-3 |
| 26 | <legend className="mb-3 text-sm font-medium |
| 27 | {webhookEvents.map(( |
| 28 | <label |
| 29 | key={event} |
| 30 | htmlFor={`event-${event |
| 31 | className="flex items-start gap-3 text-sm" |
| 32 | > |
| 33 | <Checkbox |
| 34 | id={`event-${event |
| 35 | className="mt-0.5" |
| 36 | checked={value.includes |
| 37 | onCheckedChange={(checked) |
| 38 | /> |
| 39 | <span className="flex flex-col gap-0.5 |
| 40 | <span className="font-mono text-xs |
| 41 | <span className="text-muted-foreground |
| 42 | {webhookEventLabels[event]} |
| 43 | </span> |
| 44 | </span> |
| 45 | </label> |
| 46 | ))} |
| 47 | </fieldset> |
| 48 | ); |
| 49 | } |