import React, { useEffect } from "react"; import { observer } from "mobx-react"; import { usePathname, useSearchParams } from "next/navigation"; // hooks import { generateQueryParams } from "@plane/utils"; import { useCycle } from "@/hooks/store/use-cycle"; import { useAppRouter } from "@/hooks/use-app-router"; // components import { CycleDetailsSidebar } from "./analytics-sidebar"; type Props = { projectId?: string; workspaceSlug: string; isArchived?: boolean; }; export const CyclePeekOverview: React.FC = observer((props) => { const { projectId: propsProjectId, workspaceSlug, isArchived } = props; // router const router = useAppRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const peekCycle = searchParams.get("peekCycle"); // refs const ref = React.useRef(null); // store hooks const { getCycleById, fetchCycleDetails, fetchArchivedCycleDetails } = useCycle(); // derived values const cycleDetails = peekCycle ? getCycleById(peekCycle.toString()) : undefined; const projectId = propsProjectId || cycleDetails?.project_id; const handleClose = () => { const query = generateQueryParams(searchParams, ["peekCycle"]); router.push(`${pathname}?${query}`, { showProgress: false }); }; useEffect(() => { if (!peekCycle || !projectId) return; if (isArchived) fetchArchivedCycleDetails(workspaceSlug, projectId, peekCycle.toString()); else fetchCycleDetails(workspaceSlug, projectId, peekCycle.toString()); }, [fetchArchivedCycleDetails, fetchCycleDetails, isArchived, peekCycle, projectId, workspaceSlug]); return ( <> {peekCycle && projectId && (
)} ); });