"use client"; /* import Script from "next/script"; import { createContext, useContext, useState } from "react"; type ShareToSocialName = "pinterest" | "facebook" | "teitter" | "X" | "x" | "whatsapp" | "email" | "copy_link"; type SDKLoadState = "none" | "loading" | "error" | "success"; type SDKName = "pinterest"; interface SocialSDKState { pinterest: SDKLoadState; } interface SocialShareContextProps { loadSDKState: SocialSDKState; } const pinterestShareSDKURL = "https://assets.pinterest.com/js/pinit.js"; const SocialShareContext = createContext(null); export function SocialShareProvider({ children }: { children:React.ReactNode; }){ const [loadSDKState, setLoadSDKState] = useState({ pinterest: 'none', // none loading error success }); const onSdkLoad = (m:SDKName) => { setLoadSDKState((prev) => { return { ...prev, [m]: 'success' } }); }; const onSdkError = (m:SDKName) => { setLoadSDKState((prev) => { return { ...prev, [m]: 'error' } }); }; const handlerShare = ({ name, url, title, pic, }:{ name: ShareToSocialName; url: string; title: string; pic: string; }) => { var facebook = 'https://www.facebook.com/sharer/sharer.php?u={url}&t={title}&pic={pic}'; if(name === 'pinterest') { if(loadSDKState.pinterest === 'success') { // window.PinUtils.pinOne({ // url: url, // media: pic, // description: title, // }); } } else if(name === 'facebook') { // shareModal.simpleShare.facebook(); var facebook = 'https://www.facebook.com/sharer/sharer.php?u={url}&t={title}&pic={pic}'; } else if(name === 'teitter') { var twitter = 'https://twitter.com/intent/tweet?text={title}&url={url}'; } else if(name === 'whatsapp') { var waShareUrl = 'https://wa.me/?text=' + window.encodeURIComponent(title + url) window.open(waShareUrl,'t','toolbar=0,resizable=1,status=0,width=640,height=528,left=500,top=300'); }else if(name === 'email') { // var aDom = jQuery(''); // aDom.attr('href', 'mailto:?subject=' + window.encodeURIComponent('Share Alipearlhair Product') + '&body=' + window.encodeURIComponent(shareModal.shareInfo.url)); // aDom[0].click(); } else if(name === 'copy_link') { // shareModal.copyText(shareModal.shareInfo.url); } }; return (