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 = { pageStore: IPageStore; }; export const PageInfoPopover: React.FC = (props) => { const { pageStore } = 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 } = pageStore; return (
setIsPopoverOpen(true)} onMouseLeave={() => setIsPopoverOpen(false)}> {isPopoverOpen && (
Last updated on
{renderFormattedDate(updated_at)}
Created on
{renderFormattedDate(created_at)}
)}
); };