"use client";

import { Share2 } from "lucide-react";
import { Button } from "@/components/ui/button";

export function ShareButton({ text }: { text: string }) {
  const handleShare = async () => {
    if (navigator.share) {
      await navigator.share({ text, url: window.location.href });
      return;
    }

    await navigator.clipboard.writeText(window.location.href);
  };

  return (
    <Button variant="secondary" className="gap-2" onClick={() => void handleShare()}>
      <Share2 size={16} />
      مشاركة
    </Button>
  );
}
