import React from "react"; import Link from "next/link"; import { useRouter } from "next/router"; // hooks import useUser from "hooks/use-user"; import useToast from "hooks/use-toast"; // ui import { CustomMenu, Tooltip } from "components/ui"; // icons import { LinkIcon, LockClosedIcon, LockOpenIcon, PencilIcon, StarIcon, TrashIcon, } from "@heroicons/react/24/outline"; import { ExclamationIcon } from "components/icons"; // helpers import { copyTextToClipboard, truncateText } from "helpers/string.helper"; import { renderShortTime, renderShortDate, renderLongDateFormat } from "helpers/date-time.helper"; // types import { IPage, IProjectMember } from "types"; type TSingleStatProps = { page: IPage; people: IProjectMember[] | undefined; handleEditPage: () => void; handleDeletePage: () => void; handleAddToFavorites: () => void; handleRemoveFromFavorites: () => void; partialUpdatePage: (page: IPage, formData: Partial) => void; }; export const SinglePageDetailedItem: React.FC = ({ page, people, handleEditPage, handleDeletePage, handleAddToFavorites, handleRemoveFromFavorites, partialUpdatePage, }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { user } = useUser(); const { setToastAlert } = useToast(); const handleCopyText = () => { const originURL = typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; copyTextToClipboard( `${originURL}/${workspaceSlug}/projects/${projectId}/pages/${page.id}` ).then(() => { setToastAlert({ type: "success", title: "Link Copied!", message: "Page link copied to clipboard.", }); }); }; return (

{truncateText(page.name, 75)}

{page.label_details.length > 0 && page.label_details.map((label) => (
{label.name}
))}

{renderShortTime(page.updated_at)}

{page.is_favorite ? ( ) : ( )} {page.created_by === user?.id && ( )} person.member.id === page.created_by)?.member .first_name ?? "" } on ${renderLongDateFormat(`${page.created_at}`)}`} > { e.preventDefault(); e.stopPropagation(); handleEditPage(); }} > Edit Page { e.preventDefault(); e.stopPropagation(); handleDeletePage(); }} > Delete Page { e.preventDefault(); e.stopPropagation(); handleCopyText(); }} >
Copy Page link
{page.blocks.length > 0 ? page.blocks.slice(0, 3).map((block) =>

{block.name}

) : null}
); };