Ver código fonte

Add copy link functionality

gpt-engineer-app[bot] 2 meses atrás
pai
commit
4152cf3ec2
1 arquivos alterados com 34 adições e 13 exclusões
  1. 34 13
      src/components/NewsCard.tsx

+ 34 - 13
src/components/NewsCard.tsx

@@ -3,9 +3,10 @@ import { NewsItem } from '@/types/news';
 import { Card, CardContent, CardHeader } from '@/components/ui/card';
 import { Badge } from '@/components/ui/badge';
 import { Button } from '@/components/ui/button';
-import { Clock, Pin, ExternalLink, Eye, Trash2 } from 'lucide-react';
+import { Clock, Pin, ExternalLink, Eye, Trash2, Copy } from 'lucide-react';
 import { cn } from '@/lib/utils';
 import { useAuth } from '@/hooks/useAuth';
+import { toast } from 'sonner';
 
 interface NewsCardProps {
   news: NewsItem;
@@ -156,18 +157,38 @@ const NewsCard = ({
             )}
             
             {news.url && (
-              <Button
-                variant="default"
-                size="sm"
-                className="gap-1"
-                onClick={(e) => {
-                  e.stopPropagation();
-                  window.open(news.url, '_blank');
-                }}
-              >
-                <ExternalLink className="h-3 w-3" />
-                Lire
-              </Button>
+              <>
+                <Button
+                  variant="outline"
+                  size="sm"
+                  className="gap-1"
+                  onClick={async (e) => {
+                    e.stopPropagation();
+                    try {
+                      await navigator.clipboard.writeText(news.url!);
+                      toast.success("Lien copié dans le presse-papier");
+                    } catch (error) {
+                      toast.error("Erreur lors de la copie du lien");
+                    }
+                  }}
+                >
+                  <Copy className="h-3 w-3" />
+                  Copier
+                </Button>
+                
+                <Button
+                  variant="default"
+                  size="sm"
+                  className="gap-1"
+                  onClick={(e) => {
+                    e.stopPropagation();
+                    window.open(news.url, '_blank');
+                  }}
+                >
+                  <ExternalLink className="h-3 w-3" />
+                  Lire
+                </Button>
+              </>
             )}
           </div>
         </div>