import { useState } from "react"; import { usePopper } from "react-popper"; import { Calendar, History, Info } from "lucide-react"; // helpers import { renderFormattedDate } from "@/helpers/date-time.helper"; // store import { IPageStore } from "@/store/pages/page.store"; type Props = { page: IPageStore; }; export const PageInfoPopover: React.FC = (props) => { const { page } = props; // states const [isPopoverOpen, setIsPopoverOpen] = useState(false); // refs const [referenceElement, setReferenceElement] = useState(null); const [popperElement, setPopperElement] = useState(null); // popper-js const { styles: infoPopoverStyles, attributes: infoPopoverAttributes } = usePopper(referenceElement, popperElement, { placement: "bottom-start", }); // derived values const { created_at, updated_at } = page; return (
setIsPopoverOpen(true)} onMouseLeave={() => setIsPopoverOpen(false)}> {isPopoverOpen && (
Last updated on
{renderFormattedDate(updated_at)}
Created on
{renderFormattedDate(created_at)}
)}
); };