forked from
leaflet.pub/leaflet
a tool for shared writing and social publishing
1import { useLeafletDomains } from "components/PageSWRDataProvider";
2import { ShareButton, usePublishLink } from "components/ShareOptions";
3import { useEffect, useState } from "react";
4
5export const PageShareMenu = (props: { entityID: string }) => {
6 let publishLink = usePublishLink();
7 let { data: domains } = useLeafletDomains();
8 let [collabLink, setCollabLink] = useState<null | string>(null);
9 useEffect(() => {
10 setCollabLink(window.location.pathname);
11 }, []);
12
13 return (
14 <div>
15 <ShareButton
16 text="Share Edit Link"
17 subtext=""
18 helptext="recipients can edit the full Leaflet"
19 smokerText="Collab link copied!"
20 id="get-page-collab-link"
21 link={`${collabLink}?page=${props.entityID}`}
22 />
23 <ShareButton
24 text="Share View Link"
25 subtext=""
26 helptext="recipients can view the full Leaflet"
27 smokerText="Publish link copied!"
28 id="get-page-publish-link"
29 fullLink={
30 domains?.[0]
31 ? `https://${domains[0].domain}${domains[0].route}?page=${props.entityID}`
32 : undefined
33 }
34 link={`${publishLink}?page=${props.entityID}`}
35 />
36 </div>
37 );
38};