"use client" import { useCallback, useState } from "react" import { Check, Copy } from "lucide-react" import { toast } from "sonner" import { WEBHOOK_TEMPLATE_VARIABLE_GROUPS, type WebhookTemplateVariable, } from "@/lib/mail-automation/webhook-template-variables" import { cn } from "@/lib/utils" function VariableChip({ variable, copied, onCopy, }: { variable: WebhookTemplateVariable copied: boolean onCopy: (token: string) => void }) { return ( onCopy(variable.token)} className={cn( "inline-flex max-w-full items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-[11px] leading-snug transition-colors", "border-border bg-muted/40 text-foreground hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50", copied && "border-primary/40 bg-primary/10 text-primary" )} > {copied ? ( ) : ( )} {variable.token} ) } export function WebhookTemplateVariablesPanel() { const [copiedToken, setCopiedToken] = useState(null) const copyToken = useCallback(async (token: string) => { try { await navigator.clipboard.writeText(token) setCopiedToken(token) toast.success(`${token} copié`) window.setTimeout(() => { setCopiedToken((current) => (current === token ? null : current)) }, 1500) } catch { toast.error("Impossible de copier la variable") } }, []) return ( Variables du template Insérez ces variables dans votre JSON{" "} body_template. Cliquez sur une puce pour la copier dans le presse-papiers. {WEBHOOK_TEMPLATE_VARIABLE_GROUPS.map((group) => ( {group.label} {group.description} {group.variables.map((variable) => ( {variable.label} — {variable.description} {variable.example ? ( Ex. {variable.example} ) : null} ))} ))} ) }
Variables du template
Insérez ces variables dans votre JSON{" "} body_template. Cliquez sur une puce pour la copier dans le presse-papiers.
body_template
{group.description}