"use client" import { Checkbox } from "@/components/ui/checkbox" import { Label } from "@/components/ui/label" import { ApiTokenDriveScopeEditor } from "@/components/gmail/settings/automation/api-token-drive-scope-editor" import { ApiTokenMailScopeEditor } from "@/components/gmail/settings/automation/api-token-mail-scope-editor" import { WebhookContactsScopeEditor } from "@/components/gmail/settings/automation/webhook-contacts-scope-editor" import { WebhookAgendaScopeEditor } from "@/components/gmail/settings/automation/webhook-agenda-scope-editor" import { AUTOMATION_DOMAIN_LABELS, type AutomationDomain, } from "@/lib/mail-automation/domains" import { AutomationBorderedFieldset } from "@/components/gmail/settings/automation/automation-bordered-fieldset" import { AutomationDomainMark } from "@/components/gmail/settings/automation/automation-domain-mark" import type { TriggerType } from "@/lib/mail-automation/types" import { hasAgendaWebhookEvents, hasContactsWebhookEvents, hasDriveWebhookEvents, hasMailWebhookEvents, WEBHOOK_EVENT_OPTIONS, } from "@/lib/mail-automation/webhook-config" import type { ApiTokenDriveScope, ApiTokenMailScope } from "@/lib/api/types" import type { WebhookContactsScope, WebhookAgendaScope } from "@/lib/mail-automation/webhook-config" import { cn } from "@/lib/utils" const DOMAINS: AutomationDomain[] = ["mail", "drive", "contacts", "agenda"] export function WebhookEventScopeEditor({ eventTypes, onEventTypesChange, mailScope, onMailScopeChange, driveScope, onDriveScopeChange, contactsScope, onContactsScopeChange, agendaScope, onAgendaScopeChange, className, }: { eventTypes: TriggerType[] onEventTypesChange: (types: TriggerType[]) => void mailScope: ApiTokenMailScope onMailScopeChange: (scope: ApiTokenMailScope) => void driveScope: ApiTokenDriveScope onDriveScopeChange: (scope: ApiTokenDriveScope) => void contactsScope: WebhookContactsScope onContactsScopeChange: (scope: WebhookContactsScope) => void agendaScope: WebhookAgendaScope onAgendaScopeChange: (scope: WebhookAgendaScope) => void className?: string }) { function toggleEvent(type: TriggerType) { if (eventTypes.includes(type)) { onEventTypesChange(eventTypes.filter((t) => t !== type)) } else { onEventTypesChange([...eventTypes, type]) } } return (

Le webhook part uniquement pour les événements cochés, dans le périmètre défini ci-dessous.

{DOMAINS.map((domain) => { const options = WEBHOOK_EVENT_OPTIONS.filter((o) => o.domain === domain) return ( {AUTOMATION_DOMAIN_LABELS[domain]} } legendClassName="flex items-center gap-1.5 text-xs" >
    {options.map((opt) => (
  • ))}
) })}
) }