import { FC } from "react"; import { useRouter } from "next/router"; import { Plus } from "lucide-react"; // hooks import { useApplication, useUser } from "hooks/store"; // components import { NewEmptyState } from "components/common/new-empty-state"; // ui import { Loader } from "@plane/ui"; // images import emptyPage from "public/empty-state/empty_page.png"; // constants import { EUserProjectRoles } from "constants/project"; import { PagesListItem } from "./list-item"; type IPagesListView = { pageIds: string[]; }; export const PagesListView: FC = (props) => { const { pageIds: projectPageIds } = props; // store hooks // trace(true); const { commandPalette: { toggleCreatePageModal }, } = useApplication(); const { membership: { currentProjectRole }, } = useUser(); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // here we are only observing the projectPageStore, so that we can re-render the component when the projectPageStore changes const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; return ( <> {projectPageIds && workspaceSlug && projectId ? (
{projectPageIds.length > 0 ? ( ) : ( , text: "Create your first page", onClick: () => toggleCreatePageModal(true), }} disabled={!isEditingAllowed} /> )}
) : ( )} ); };