Files
PaperClipAI/ui/src/components/routine-triggers/WebhookFields.tsx
T
DottaandPaperclip 527e146980 feat(ui): share animated agent setup prompts (#14862)
Use the shared animated prompt-copy control across setup, invitations, webhooks, and task handoffs. Preserve first-click copying, clipboard recovery, and logo continuity. Add Storybook coverage and restore mention icon masks for the current Lucide data shape.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-01 11:46:14 -05:00

89 lines
2.6 KiB
TypeScript

import { useState } from "react";
import { Check, Copy } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Label } from "@/components/ui/label";
import { copyTextToClipboard } from "@/lib/clipboard";
import { AgentSetupPrompt } from "@/components/AgentSetupPrompt";
export function CopyField({
label,
value,
help,
}: {
label: string;
value: string;
help?: string;
}) {
const [copied, setCopied] = useState(false);
const [error, setError] = useState(false);
return (
<div className="space-y-1.5">
<Label className="text-xs">{label}</Label>
<div className="flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-3 py-2">
<code title={value} className="min-w-0 flex-1 truncate text-xs">
{value}
</code>
<Button
variant="ghost"
size="sm"
aria-label={`Copy ${label}`}
onClick={async () => {
try {
await copyTextToClipboard(value);
setCopied(true);
setError(false);
} catch {
setError(true);
}
}}
>
{copied ? (
<Check className="h-3.5 w-3.5" />
) : (
<Copy className="h-3.5 w-3.5" />
)}
{copied ? "Copied" : "Copy"}
</Button>
</div>
{help && <p className="text-xs text-muted-foreground">{help}</p>}
{error && (
<div className="space-y-2">
<p role="alert" className="text-xs text-destructive">
Copy failed. Select and copy the text below.
</p>
<textarea
readOnly
aria-label={`${label} text`}
value={value}
rows={5}
className="w-full rounded-md border border-input bg-background p-3 font-mono text-xs"
/>
</div>
)}
</div>
);
}
export function AgentInstructions({ value }: { value: string }) {
return (
<section
aria-label="Agent instructions"
className="space-y-3 rounded-md bg-muted/40 p-4"
>
<div className="space-y-1">
<h2 className="text-sm font-medium">Agent instructions</h2>
<p className="text-sm text-muted-foreground">
Give your agent everything it needs to connect this webhook: the URL,
authentication key, and step-by-step instructions.
</p>
</div>
<AgentSetupPrompt
prompt={value}
label="Copy for your agent"
title="Webhook setup"
description="Paste this into your agent to connect this webhook to your routine."
/>
</section>
);
}