import { useState } from "react"; import { observer } from "mobx-react-lite"; import { PlusIcon } from "lucide-react"; // hooks import { useApplication, useIssueDetail, useIssues, useUser } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { EmptyState } from "components/common"; import { ExistingIssuesListModal } from "components/core"; // ui import { Button } from "@plane/ui"; // assets import emptyIssue from "public/empty-state/issue.svg"; // types import { ISearchIssueResponse } from "@plane/types"; // constants import { EUserProjectRoles } from "constants/project"; import { EIssuesStoreType } from "constants/issue"; type Props = { workspaceSlug: string | undefined; projectId: string | undefined; moduleId: string | undefined; }; export const ModuleEmptyState: React.FC = observer((props) => { const { workspaceSlug, projectId, moduleId } = props; // states const [moduleIssuesListModal, setModuleIssuesListModal] = useState(false); // store hooks const { issues } = useIssues(EIssuesStoreType.MODULE); const { updateIssue, fetchIssue } = useIssueDetail(); const { commandPalette: { toggleCreateIssueModal }, eventTracker: { setTrackElement }, } = useApplication(); const { membership: { currentProjectRole: userRole }, } = useUser(); // toast alert const { setToastAlert } = useToast(); const handleAddIssuesToModule = async (data: ISearchIssueResponse[]) => { if (!workspaceSlug || !projectId || !moduleId) return; const issueIds = data.map((i) => i.id); await issues .addIssuesToModule(workspaceSlug.toString(), projectId?.toString(), moduleId.toString(), issueIds) .catch(() => setToastAlert({ type: "error", title: "Error!", message: "Selected issues could not be added to the module. Please try again.", }) ); }; const isEditingAllowed = !!userRole && userRole >= EUserProjectRoles.MEMBER; return ( <> setModuleIssuesListModal(false)} searchParams={{ module: moduleId != undefined ? [moduleId.toString()] : [] }} handleOnSubmit={handleAddIssuesToModule} />
, onClick: () => { setTrackElement("MODULE_EMPTY_STATE"); toggleCreateIssueModal(true, EIssuesStoreType.MODULE); }, }} secondaryButton={ } disabled={!isEditingAllowed} />
); });