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 { useModule } from "@/hooks/store"; // components import { ModuleDetailsSidebar } from "./sidebar"; type Props = { projectId: string; workspaceSlug: string; isArchived?: boolean; }; export const ModulePeekOverview: React.FC = observer(({ projectId, workspaceSlug, isArchived = false }) => { // router const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const peekModule = searchParams.get("peekModule"); // refs const ref = React.useRef(null); // store hooks const { fetchModuleDetails, fetchArchivedModuleDetails } = useModule(); const handleClose = () => { const query = generateQueryParams(searchParams, ["peekModule"]); router.push(`${pathname}?${query}`); }; useEffect(() => { if (!peekModule) return; if (isArchived) fetchArchivedModuleDetails(workspaceSlug, projectId, peekModule.toString()); else fetchModuleDetails(workspaceSlug, projectId, peekModule.toString()); }, [fetchArchivedModuleDetails, fetchModuleDetails, isArchived, peekModule, projectId, workspaceSlug]); return ( <> {peekModule && (
)} ); });