plane/web/components/pages/pages-list-view.tsx
Aaryan Khandelwal 7507cb0a0f
[WEB-994] fix: pages list mutation between projects (#4179)
* fix: pages list mutation between projects

* fix: page tab logic

* chore: remove pageType from the project pages store

* chore: rename computed helper functions
2024-04-15 12:50:22 +05:30

34 lines
1.1 KiB
TypeScript

import { observer } from "mobx-react-lite";
import useSWR from "swr";
import { TPageNavigationTabs } from "@plane/types";
// components
import { PagesListHeaderRoot, PagesListMainContent } from "@/components/pages";
// hooks
import { useProjectPages } from "@/hooks/store";
type TPageView = {
workspaceSlug: string;
projectId: string;
pageType: TPageNavigationTabs;
children: React.ReactNode;
};
export const PagesListView: React.FC<TPageView> = observer((props) => {
const { workspaceSlug, projectId, pageType, children } = props;
// store hooks
const { getAllPages } = useProjectPages(projectId);
// fetching pages list
useSWR(projectId ? `PROJECT_PAGES_${projectId}` : null, projectId ? () => getAllPages(pageType) : null);
// pages loader
return (
<div className="relative w-full h-full overflow-hidden flex flex-col">
{/* tab header */}
<PagesListHeaderRoot pageType={pageType} projectId={projectId} workspaceSlug={workspaceSlug} />
<PagesListMainContent pageType={pageType} projectId={projectId}>
{children}
</PagesListMainContent>
</div>
);
});