import React, { useEffect, useMemo } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // components import { FullScreenPeekView, SidePeekView } from "components/issues/peek-overview"; // types import type { IIssue } from "types/issue"; // lib import { useMobxStore } from "lib/mobx/store-provider"; type Props = { isOpen: boolean; onClose: () => void; }; export const IssuePeekOverview: React.FC = observer((props) => { const { isOpen, onClose } = props; // router const router = useRouter(); const { workspace_slug, project_slug, peekId } = router.query; // store const { issueDetails: issueDetailStore, issue: issueStore } = useMobxStore(); const issueDetails = issueDetailStore.peekId && peekId ? issueDetailStore.details[peekId.toString()] : null; useEffect(() => { if (workspace_slug && project_slug && peekId && issueStore.issues && issueStore.issues.length > 0) { if (!issueDetails) { issueDetailStore.fetchIssueDetails(workspace_slug.toString(), project_slug.toString(), peekId.toString()); } } }, [workspace_slug, project_slug, issueDetailStore, issueDetails, peekId, issueStore.issues]); const handleClose = () => { onClose(); issueDetailStore.setPeekMode("side"); }; return ( {/* add backdrop conditionally */} {(issueDetailStore.peekMode === "modal" || issueDetailStore.peekMode === "full") && (
)}
{(issueDetailStore.peekMode === "side" || issueDetailStore.peekMode === "modal") && ( )} {issueDetailStore.peekMode === "full" && ( )}
); });