diff --git a/components/admin/ClientForm.tsx b/components/admin/ClientForm.tsx index 94bc278..0a87310 100644 --- a/components/admin/ClientForm.tsx +++ b/components/admin/ClientForm.tsx @@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { Client, ClientInput } from "@/lib/types/client"; import QRCodeDisplay from "./QRCodeDisplay"; +import { Copy, Check } from "lucide-react"; interface ClientFormProps { client?: Client; @@ -24,6 +25,7 @@ export default function ClientForm({ client, onSuccess, onCancel }: ClientFormPr const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [createdClient, setCreatedClient] = useState(client || null); + const [copied, setCopied] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -68,6 +70,29 @@ export default function ClientForm({ client, onSuccess, onCancel }: ClientFormPr return `${baseUrl}/accueil?token=${createdClient.token}`; }; + const handleCopyLink = async () => { + try { + await navigator.clipboard.writeText(getClientUrl()); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch (err) { + console.error("Erreur lors de la copie:", err); + // Fallback pour les navigateurs plus anciens + const textArea = document.createElement("textarea"); + textArea.value = getClientUrl(); + document.body.appendChild(textArea); + textArea.select(); + try { + document.execCommand("copy"); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch (e) { + alert("Impossible de copier. Veuillez copier manuellement le lien."); + } + document.body.removeChild(textArea); + } + }; + return ( @@ -167,19 +192,32 @@ export default function ClientForm({ client, onSuccess, onCancel }: ClientFormPr

Client créé avec succès !

-

Lien unique :

-
- {getClientUrl()} +

Lien unique :

+
+ + {getClientUrl()} +
+

+ Partagez ce lien avec le client pour qu'il configure son app automatiquement +

QR Code :