import { Button, Modal, Tooltip } from "antd";
import { Clipboard } from "./Icons/Clipboard";
import { CrossCircle } from "./Icons/CrossCircle";
import { NLView } from "../types";
import { PinterestIcon } from "./Icons/PinterestIcon";
import { PinterestShareButton, TelegramShareButton, TumblrShareButton, TwitterShareButton } from "react-share";
import { PostReadResponse, UserReadPrivateResponse } from "@newstackdev/iosdk-newgraph-client-js";
import { QRCodeSVG } from "qrcode.react";
import { ShareIcon } from "./Icons/ShareIcon";
import { TelegramIcon } from "./Icons/TelegramIcon";
import { TumblrIcon } from "./Icons/TumblrIcon";
import { TwitterIcon } from "./Icons/TwitterIcon";
import { useContentImageUrl } from "./MediaComponents/ImageMediaComponent";
import CopyToClipboard from "react-copy-to-clipboard";
import React, { useCallback, useEffect, useState } from "react";
const ShareModalContent: NLView<{
label?: string;
children: React.ReactNode;
style?: React.CSSProperties;
}> = ({ children, label, style }) => {
return (
{label ? (
) : (
false
)}
{children}
);
};
export const Share: NLView<{
currentPostProps?: PostReadResponse;
urlToShare?: string;
user?: UserReadPrivateResponse;
}> = ({ currentPostProps, urlToShare, user }) => {
const URL =
!currentPostProps && urlToShare
? urlToShare
: process.env.NODE_ENV === "production"
? window.location.href
: `https://web-dev.newlife.io${window.location.pathname}`;
const [isVisible, setIsVisible] = useState(false);
const [hashtags, setHashtags] = useState([]);
const [copyToClipboard, setCopyToClipboard] = useState(false);
const [viewQR, setViewQR] = useState(false);
const onCancelHandler = useCallback(() => {
setIsVisible(false);
setViewQR(false);
}, [setIsVisible, setViewQR]);
useEffect(() => {
if (currentPostProps?.tags) {
const tags = currentPostProps.tags.map((tag) => tag.value?.replace(/ /g, "") as string);
setHashtags(tags);
}
}, [currentPostProps?.tags]);
const contentImageUrl = useContentImageUrl(currentPostProps ? { ...currentPostProps } : { ...user });
return (
<>
{isVisible ? (
}
visible={isVisible}
onCancel={onCancelHandler}
className="nl-white-box-modal"
footer={null}
width={375}
title={
<>
Share to
Share this content to your networks!
>
}
>
{viewQR ? (
) : (
<>
{
if (visible) {
setTimeout(() => {
setCopyToClipboard(false);
}, 500);
}
}}
>
>
)}
) : (
false
)}
setIsVisible(true)} className="nl-share-button-icon">
>
);
};