2023-03-25 18:09:46 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
|
|
|
import useSWR from "swr";
|
|
|
|
|
|
|
|
// services
|
|
|
|
import pagesService from "services/pages.service";
|
|
|
|
// components
|
|
|
|
import { PagesView } from "components/pages";
|
|
|
|
// types
|
2023-03-27 17:49:05 +00:00
|
|
|
import { TPagesListProps } from "./types";
|
2023-03-25 18:09:46 +00:00
|
|
|
// fetch-keys
|
|
|
|
import { OTHER_PAGES_LIST } from "constants/fetch-keys";
|
|
|
|
|
2023-03-27 17:49:05 +00:00
|
|
|
export const OtherPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
|
2023-03-25 18:09:46 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
|
|
|
|
const { data: pages } = useSWR(
|
|
|
|
workspaceSlug && projectId ? OTHER_PAGES_LIST(projectId as string) : null,
|
|
|
|
workspaceSlug && projectId
|
2023-05-26 10:08:44 +00:00
|
|
|
? () =>
|
2023-05-29 13:05:16 +00:00
|
|
|
pagesService.getPagesWithParams(
|
|
|
|
workspaceSlug as string,
|
|
|
|
projectId as string,
|
|
|
|
"created_by_other"
|
|
|
|
)
|
2023-03-25 18:09:46 +00:00
|
|
|
: null
|
|
|
|
);
|
|
|
|
|
2023-05-29 09:46:49 +00:00
|
|
|
return <PagesView pages={pages} viewType={viewType} />;
|
2023-03-25 18:09:46 +00:00
|
|
|
};
|