import MuiDrawer from '@mui/material/Drawer'; import styles from "./styles.module.scss"; import {ReactComponent as ShareIcon} from '@assets/singlesvg/share.svg'; import icon_fb from "@assets/share/facebook.png"; import icon_ws from "@assets/share/WhatsApp.png"; import icon_tg from "@assets/share/telegram.png"; import icon_twitter from "@assets/share/Twitter.png"; import icon_email from "@assets/share/email.png"; import icon_svg_ws from "@assets/share/whatsappsvg.svg"; import icon_sms from "@assets/share/sms.png"; import {useSelector} from "react-redux"; import {getNumbers, getShareUrl, getTotalAmount} from "@features/turnplateSlice"; import {formatCash, stringFormat} from "@utils/helpers"; import {CopyToClipboard} from "react-copy-to-clipboard/lib/Component"; import {toast} from "react-toastify"; import {useState} from "react"; const i18n=global.i18n; const WShare=({open,onClose})=>{ const shareUrl=useSelector(getShareUrl); const amount=useSelector(getTotalAmount); const numbers=useSelector(getNumbers); const shareTitle=stringFormat(i18n.t("turnplate.share_box.share_title"),[global.DOLLAR,formatCash(amount,0)]); const shareText=stringFormat(i18n.t("turnplate.share_box.share_text"),[global.DOLLAR,formatCash(amount,0)]); const [waPhoneIndex,setWaPhoneIndex]=useState(-1); const shareMore=()=>{ try { navigator.share ? navigator.share({ title: shareTitle, url: shareUrl, text: shareText }) : shareFb() } catch (t) { shareFb() } } const shareFb=()=>{ if (global.isIOS){ let url="fb://share/?link="+shareUrl; window.open(url); } else { let url="https://www.facebook.com/sharer/sharer.php?u="+shareUrl+"&t=" + encodeURIComponent(shareText); window.open(url); } } const shareWa=()=>{ let url="whatsapp://send?text=" + encodeURIComponent(shareText) + encodeURIComponent("\n\n" + shareUrl) + "&via=lopscoop"; window.open(url); } const shareTG=()=>{ let url="https://t.me/share/url?url=" + encodeURIComponent(shareUrl) + "&text=" + encodeURIComponent(shareText); window.open(url); } const shareTw=()=>{ let url="https://twitter.com/intent/tweet?text" + encodeURIComponent(shareText) + "&url=" + encodeURIComponent(shareUrl); window.open(url); } const shareEmail=()=>{ let url="mailto:?body=" + encodeURIComponent(shareText + " " + shareUrl); window.open(url); } const shareWaMore=()=>{ if (numbers.length>0){ let windex=waPhoneIndex+1; if (windex>=numbers.length)windex=0; setWaPhoneIndex(windex); let phone=numbers[windex]; let url="whatsapp://send?phone=+" + phone + "&text=" + encodeURIComponent("Responda OK,".concat(shareText, ".")) + encodeURIComponent("\n\n" + shareUrl) + "&via=lopscoop"; window.open(url); } } const shareSms=()=>{ let text=""; let smsCode=""; if (global.isIOS){ text="&body="+shareText+" "+shareUrl; smsCode="/open?addresses="+numbers.join(", "); } else { text="?body=" + encodeURIComponent(shareText) + " " + encodeURIComponent(shareUrl); smsCode=numbers.join(", ")+ ";"; } let url="sms:" + smsCode + text; window.open(url); } const renderIcons=()=>{ return (