import React, { useEffect } from "react"; import { observer } from "mobx-react"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; // hooks import { generateQueryParams } from "@/helpers/router.helper"; import { useCycle } from "@/hooks/store"; // components import { CycleDetailsSidebar } from "./"; type Props = { projectId: string; workspaceSlug: string; isArchived?: boolean; }; export const CyclePeekOverview: React.FC = observer(({ projectId, workspaceSlug, isArchived = false }) => { // router const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const peekCycle = searchParams.get("peekCycle"); // refs const ref = React.useRef(null); // store hooks const { fetchCycleDetails, fetchArchivedCycleDetails } = useCycle(); const handleClose = () => { const query = generateQueryParams(searchParams, ["peekCycle"]); router.push(`${pathname}?${query}`); }; useEffect(() => { if (!peekCycle) return; if (isArchived) fetchArchivedCycleDetails(workspaceSlug, projectId, peekCycle.toString()); else fetchCycleDetails(workspaceSlug, projectId, peekCycle.toString()); }, [fetchArchivedCycleDetails, fetchCycleDetails, isArchived, peekCycle, projectId, workspaceSlug]); return ( <> {peekCycle && (
)} ); });