/* ┌──────────────────────────────────────────────────────────────────────────────┐ │ @author: Davidson Gomes │ │ @file: /app/agents/dialogs/ShareAgentDialog.tsx │ │ Developed by: Davidson Gomes │ │ Creation date: May 13, 2025 │ │ Contact: contato@evolution-api.com │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @copyright © Evolution API 2025. All rights reserved. │ │ Licensed under the Apache License, Version 2.0 │ │ │ │ You may not use this file except in compliance with the License. │ │ You may obtain a copy of the License at │ │ │ │ http://www.apache.org/licenses/LICENSE-2.0 │ │ │ │ Unless required by applicable law or agreed to in writing, software │ │ distributed under the License is distributed on an "AS IS" BASIS, │ │ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @important │ │ For any future changes to the code in this file, it is recommended to │ │ include, together with the modification, the information of the developer │ │ who changed it and the date of modification. │ └──────────────────────────────────────────────────────────────────────────────┘ */ "use client"; import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Agent } from "@/types/agent"; import { Input } from "@/components/ui/input"; import { Copy, Share2, ExternalLink } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; interface ShareAgentDialogProps { open: boolean; onOpenChange: (open: boolean) => void; agent: Agent; apiKey?: string; } export function ShareAgentDialog({ open, onOpenChange, agent, apiKey, }: ShareAgentDialogProps) { const [copied, setCopied] = useState(false); const [shareLink, setShareLink] = useState(""); const { toast } = useToast(); useEffect(() => { if (open && agent && apiKey) { const baseUrl = window.location.origin; setShareLink(`${baseUrl}/shared-chat?agent=${agent.id}&key=${apiKey}`); } }, [open, agent, apiKey]); const handleCopyLink = () => { if (shareLink) { navigator.clipboard.writeText(shareLink); setCopied(true); toast({ title: "Link copied!", description: "The share link has been copied to the clipboard.", }); setTimeout(() => setCopied(false), 2000); } }; const handleCopyApiKey = () => { if (apiKey) { navigator.clipboard.writeText(apiKey); setCopied(true); toast({ title: "API Key copied!", description: "The API Key has been copied to the clipboard.", }); setTimeout(() => setCopied(false), 2000); } }; return ( Share Agent Share this agent with others without the need to login.

Share Link

Any person with this link can access the agent using the included API key.

API Key

The API key allows access to the agent. Do not share with untrusted people.

); }