diff --git a/app/(home-pages)/home/LeafletList/LeafletInfo.tsx b/app/(home-pages)/home/LeafletList/LeafletInfo.tsx index eb0fda72..f2326132 100644 --- a/app/(home-pages)/home/LeafletList/LeafletInfo.tsx +++ b/app/(home-pages)/home/LeafletList/LeafletInfo.tsx @@ -50,6 +50,7 @@ export const LeafletInfo = (props: { document_uri={props.document_uri} shareLink={`/${props.token.id}`} archived={props.archived} + loggedIn={props.loggedIn} /> diff --git a/app/(home-pages)/home/LeafletList/LeafletOptions.tsx b/app/(home-pages)/home/LeafletList/LeafletOptions.tsx index 1a6125fc..1760afde 100644 --- a/app/(home-pages)/home/LeafletList/LeafletOptions.tsx +++ b/app/(home-pages)/home/LeafletList/LeafletOptions.tsx @@ -22,6 +22,8 @@ import { } from "app/lish/[did]/[publication]/dashboard/deletePost"; import { ShareButton } from "components/ShareOptions"; import { ShareSmall } from "components/Icons/ShareSmall"; +import { HideSmall } from "components/Icons/HideSmall"; +import { hideDoc } from "../storage"; import { PermissionToken } from "src/replicache"; import { @@ -40,11 +42,15 @@ export const LeafletOptions = (props: { document_uri?: string; shareLink: string; archived?: boolean | null; + loggedIn?: boolean; }) => { let [state, setState] = useState<"normal" | "template" | "areYouSure">( "normal", ); let [open, setOpen] = useState(false); + let { identity } = useIdentityData(); + let isPublicationOwner = + !!identity?.atp_did && !!props.document_uri?.includes(identity.atp_did); return ( <> {state === "normal" ? ( - props.document_uri ? ( + !props.loggedIn ? ( + + ) : props.document_uri && isPublicationOwner ? ( { - let item = data.publication?.leaflets_in_publications.find( - (l) => l.permission_tokens?.id === props.leaflet.id, - ); + let item = + data.publication?.leaflets_in_publications.find( + (l) => l.permission_tokens?.id === props.leaflet.id, + ); if (item) item.archived = false; }); await unarchivePost(props.leaflet.id); @@ -220,6 +234,58 @@ const DefaultOptions = (props: { ); }; +const LoggedOutOptions = (props: { + leaflet: PermissionToken; + isTemplate?: boolean; + setState: (s: "template" | "areYouSure") => void; + shareLink: string; +}) => { + let toaster = useToaster(); + return ( + <> + + + Copy Edit Link + + } + subtext="" + smokerText="Link copied!" + id="get-link" + link={`/${props.shareLink}`} + /> + +
+ { + hideDoc(props.leaflet); + toaster({ + content:
Removed from Home!
, + type: "success", + }); + }} + > + + Remove from Home +
+ { + e.preventDefault(); + props.setState("areYouSure"); + }} + > + + Delete Forever + + + ); +}; + const PublishedPostOptions = (props: { setState: (s: "areYouSure") => void; document_uri: string; @@ -238,7 +304,7 @@ const PublishedPostOptions = (props: { } smokerText="Link copied!" id="get-link" - link={`/${props.shareLink}}`} + link={`${props.shareLink}`} />
diff --git a/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx b/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx index 8aaa4b7a..12e2cc15 100644 --- a/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx +++ b/app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx @@ -97,6 +97,7 @@ export function PublishedPostsList(props: { leaflet={leaflet?.permission_tokens!} document_uri={doc.documents.uri} shareLink={postLink} + loggedIn={true} /> )}