diff --git a/apps/app/components/pages/pages-list/all-pages-list.tsx b/apps/app/components/pages/pages-list/all-pages-list.tsx index ec364eba6..8bae35530 100644 --- a/apps/app/components/pages/pages-list/all-pages-list.tsx +++ b/apps/app/components/pages/pages-list/all-pages-list.tsx @@ -18,7 +18,10 @@ export const AllPagesList: React.FC = ({ viewType }) => { const { data: pages } = useSWR( workspaceSlug && projectId ? ALL_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => pagesService.getAllPages(workspaceSlug as string, projectId as string) + ? () => + pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { + page_view: "all", + }) : null ); diff --git a/apps/app/components/pages/pages-list/favorite-pages-list.tsx b/apps/app/components/pages/pages-list/favorite-pages-list.tsx index bf0ab8133..b846fbb7e 100644 --- a/apps/app/components/pages/pages-list/favorite-pages-list.tsx +++ b/apps/app/components/pages/pages-list/favorite-pages-list.tsx @@ -18,7 +18,10 @@ export const FavoritePagesList: React.FC = ({ viewType }) => { const { data: pages } = useSWR( workspaceSlug && projectId ? FAVORITE_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => pagesService.getFavoritePages(workspaceSlug as string, projectId as string) + ? () => + pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { + page_view: "favorite", + }) : null ); diff --git a/apps/app/components/pages/pages-list/my-pages-list.tsx b/apps/app/components/pages/pages-list/my-pages-list.tsx index 41704e52e..832d2a350 100644 --- a/apps/app/components/pages/pages-list/my-pages-list.tsx +++ b/apps/app/components/pages/pages-list/my-pages-list.tsx @@ -18,7 +18,10 @@ export const MyPagesList: React.FC = ({ viewType }) => { const { data: pages } = useSWR( workspaceSlug && projectId ? MY_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => pagesService.getMyPages(workspaceSlug as string, projectId as string) + ? () => + pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { + page_view: "created_by_me", + }) : null ); diff --git a/apps/app/components/pages/pages-list/other-pages-list.tsx b/apps/app/components/pages/pages-list/other-pages-list.tsx index 7cf21a3e2..b8ab1bdee 100644 --- a/apps/app/components/pages/pages-list/other-pages-list.tsx +++ b/apps/app/components/pages/pages-list/other-pages-list.tsx @@ -18,7 +18,10 @@ export const OtherPagesList: React.FC = ({ viewType }) => { const { data: pages } = useSWR( workspaceSlug && projectId ? OTHER_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId - ? () => pagesService.getOtherPages(workspaceSlug as string, projectId as string) + ? () => + pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, { + page_view: "created_by_other", + }) : null ); diff --git a/apps/app/services/pages.service.ts b/apps/app/services/pages.service.ts index 89fba2624..72776c29e 100644 --- a/apps/app/services/pages.service.ts +++ b/apps/app/services/pages.service.ts @@ -83,42 +83,26 @@ class PageServices extends APIService { }); } + async getPagesWithParams( + workspaceSlug: string, + projectId: string, + queries: any + ): Promise { + return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, { + params: queries, + }) + .then((response) => response?.data) + .catch((error) => { + throw error?.response?.data; + }); + } + async getRecentPages(workspaceSlug: string, projectId: string): Promise { - return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/recent-pages/`) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async getAllPages(workspaceSlug: string, projectId: string): Promise { - return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async getFavoritePages(workspaceSlug: string, projectId: string): Promise { - return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/favorite-pages/`) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async getMyPages(workspaceSlug: string, projectId: string): Promise { - return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/my-pages/`) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } - - async getOtherPages(workspaceSlug: string, projectId: string): Promise { - return this.get( - `/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/created-by-other-pages/` - ) + return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, { + params: { + page_view: "recent", + }, + }) .then((response) => response?.data) .catch((error) => { throw error?.response?.data;