import React from "react"; import { useRouter } from "next/router"; // headless ui import { Listbox, Transition } from "@headlessui/react"; // hooks import useToast from "hooks/use-toast"; // ui import { Icon } from "components/ui"; // icons import { East } from "@mui/icons-material"; // helpers import { copyTextToClipboard } from "helpers/string.helper"; // store import { IPeekMode } from "store/issue_details"; import { RootStore } from "store/root"; // lib import { useMobxStore } from "lib/mobx/store-provider"; // types import { IIssue } from "types/issue"; type Props = { handleClose: () => void; issueDetails: IIssue | undefined; }; const peekModes: { key: IPeekMode; icon: string; label: string; }[] = [ { key: "side", icon: "side_navigation", label: "Side Peek" }, { key: "modal", icon: "dialogs", label: "Modal Peek", }, { key: "full", icon: "nearby", label: "Full Screen Peek", }, ]; export const PeekOverviewHeader: React.FC = (props) => { const { handleClose, issueDetails } = props; const { issueDetails: issueDetailStore }: RootStore = useMobxStore(); const router = useRouter(); const { workspace_slug } = router.query; const { setToastAlert } = useToast(); const handleCopyLink = () => { const originURL = typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; copyTextToClipboard(`${originURL}/${workspace_slug}/projects/${issueDetails?.project}/`).then(() => { setToastAlert({ type: "success", title: "Link copied!", message: "Issue link copied to clipboard", }); }); }; return ( <>
{issueDetailStore.peekMode === "side" && ( )} issueDetailStore.setPeekMode(val)} className="relative flex-shrink-0 text-left" > m.key === issueDetailStore.peekMode)?.icon ?? ""} />
{peekModes.map((mode) => ( `cursor-pointer select-none truncate rounded px-1 py-1.5 ${ active || selected ? "bg-custom-background-80" : "" } ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } > {({ selected }) => (
{mode.label}
{selected && }
)}
))}
{(issueDetailStore.peekMode === "side" || issueDetailStore.peekMode === "modal") && (
)}
); };