2023-12-04 06:41:36 +00:00
|
|
|
import { ReactElement } from "react";
|
2023-03-16 08:37:19 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR from "swr";
|
2023-12-04 06:41:36 +00:00
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-03-16 08:37:19 +00:00
|
|
|
// components
|
2023-12-04 06:41:36 +00:00
|
|
|
import { ProjectViewsHeader } from "components/headers";
|
|
|
|
import { ProjectViewsList } from "components/views";
|
|
|
|
// layouts
|
|
|
|
import { AppLayout } from "layouts/app-layout";
|
2023-03-16 08:37:19 +00:00
|
|
|
// types
|
2023-12-04 06:41:36 +00:00
|
|
|
import { NextPageWithLayout } from "types/app";
|
2023-03-16 08:37:19 +00:00
|
|
|
|
2023-12-04 06:41:36 +00:00
|
|
|
const ProjectViewsPage: NextPageWithLayout = () => {
|
2023-04-08 08:16:46 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
2023-12-04 06:41:36 +00:00
|
|
|
// store
|
|
|
|
const {
|
|
|
|
projectViews: { fetchAllViews },
|
|
|
|
} = useMobxStore();
|
|
|
|
|
|
|
|
useSWR(
|
|
|
|
workspaceSlug && projectId ? `PROJECT_VIEWS_LIST_${workspaceSlug.toString()}_${projectId.toString()}` : null,
|
|
|
|
workspaceSlug && projectId ? () => fetchAllViews(workspaceSlug.toString(), projectId.toString()) : null
|
2023-03-16 08:37:19 +00:00
|
|
|
);
|
|
|
|
|
2023-12-04 06:41:36 +00:00
|
|
|
return <ProjectViewsList />;
|
|
|
|
};
|
2023-04-12 10:03:21 +00:00
|
|
|
|
2023-12-04 06:41:36 +00:00
|
|
|
ProjectViewsPage.getLayout = function getLayout(page: ReactElement) {
|
2023-03-16 08:37:19 +00:00
|
|
|
return (
|
2023-12-04 06:41:36 +00:00
|
|
|
<AppLayout header={<ProjectViewsHeader />} withProjectWrapper>
|
|
|
|
{page}
|
|
|
|
</AppLayout>
|
2023-03-16 08:37:19 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-12-04 06:41:36 +00:00
|
|
|
export default ProjectViewsPage;
|