import React, { useEffect, useState } from "react"; import { useRouter } from "next/router"; // mobx import { observer } from "mobx-react-lite"; // headless ui import { Dialog, Transition } from "@headlessui/react"; // components import { FullScreenPeekView, SidePeekView } from "components/issues/peek-overview"; // lib import { useMobxStore } from "lib/mobx/store-provider"; type Props = {}; export const IssuePeekOverview: React.FC = observer(() => { // states const [isSidePeekOpen, setIsSidePeekOpen] = useState(false); const [isModalPeekOpen, setIsModalPeekOpen] = useState(false); // router const router = useRouter(); const { workspace_slug, project_slug, peekId, board } = router.query; // store const { issueDetails: issueDetailStore, issue: issueStore } = useMobxStore(); const issueDetails = issueDetailStore.peekId && peekId ? issueDetailStore.details[peekId.toString()] : undefined; 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 = () => { issueDetailStore.setPeekId(null); router.replace( { pathname: `/${workspace_slug?.toString()}/${project_slug}`, query: { board, }, }, undefined, { shallow: true } ); }; useEffect(() => { if (peekId) { if (issueDetailStore.peekMode === "side") { setIsSidePeekOpen(true); setIsModalPeekOpen(false); } else { setIsModalPeekOpen(true); setIsSidePeekOpen(false); } } else { setIsSidePeekOpen(false); setIsModalPeekOpen(false); } }, [peekId, issueDetailStore.peekMode]); return ( <>
{issueDetailStore.peekMode === "modal" && ( )} {issueDetailStore.peekMode === "full" && ( )}
); });