diff --git a/src/components/SocialShareButton.jsx b/src/components/SocialShareButton.jsx index 86f48ab..1989a32 100644 --- a/src/components/SocialShareButton.jsx +++ b/src/components/SocialShareButton.jsx @@ -1,5 +1,4 @@ -import React, { useRef, useEffect, useState } from 'react'; -import { FiShare2 } from 'react-icons/fi'; +import React, { useRef, useEffect } from 'react'; const DEFAULT_HASHTAGS = []; const DEFAULT_PLATFORMS = ['whatsapp', 'facebook', 'twitter', 'linkedin', 'telegram', 'reddit', 'pinterest']; @@ -16,7 +15,6 @@ const SocialShareButton = ({ buttonText = 'Share', customClass = '', onShare = null, - onCopy = null, buttonStyle = 'default', modalPosition = 'center', buttonColor = '', @@ -30,41 +28,35 @@ const SocialShareButton = ({ }) => { const containerRef = useRef(null); const shareButtonRef = useRef(null); - const [loadError, setLoadError] = useState(false); useEffect(() => { - if (typeof window !== 'undefined') { - if (window.SocialShareButton) { - setLoadError(false); - shareButtonRef.current = new window.SocialShareButton({ - container: containerRef.current, - url: url || 'https://orgexplorer.aossie.org/', - title: title || document.title, - description, - hashtags, - via, - platforms, - theme, - buttonText, - customClass, - onShare, - onCopy, - buttonStyle, - modalPosition, - buttonColor, - buttonHoverColor, - showButton, - analytics, - onAnalytics, - analyticsPlugins, - componentId, - debug, - }); - } else { - setLoadError(true); - } + if (typeof window !== 'undefined' && window.SocialShareButton) { + shareButtonRef.current = new window.SocialShareButton({ + container: containerRef.current, + url: url || 'https://orgexplorer.aossie.org/', + title: title || document.title, + description, + hashtags, + via, + platforms, + theme, + buttonText, + customClass, + onShare, + buttonStyle, + modalPosition, + buttonColor, + buttonHoverColor, + showButton, + analytics, + onAnalytics, + analyticsPlugins, + componentId, + debug, + }); + } else { + console.warn('SocialShareButton widget not loaded'); } - return () => { if (shareButtonRef.current) { shareButtonRef.current.destroy(); @@ -73,43 +65,11 @@ const SocialShareButton = ({ }; }, [ url, title, description, hashtags, via, platforms, theme, buttonText, - customClass, onShare, onCopy, buttonStyle, modalPosition, buttonColor, + customClass, onShare, buttonStyle, modalPosition, buttonColor, buttonHoverColor, showButton, analytics, onAnalytics, analyticsPlugins, - componentId, debug + componentId, debug, ]); - if (loadError) { - const handleFallbackCopy = async () => { - try { - if (onCopy) { - await onCopy(); - } else { - const fallbackUrl = url || 'https://orgexplorer.aossie.org/'; - if (navigator.clipboard && navigator.clipboard.writeText) { - await navigator.clipboard.writeText(fallbackUrl); - } else { - throw new Error("Clipboard API not available"); - } - } - alert("Widget failed to load. Link copied to clipboard!"); - } catch (err) { - console.error("Failed to copy link: ", err); - alert("Widget failed to load. Failed to copy link."); - } - }; - - return ( - - ); - } - return
; };