forked from github/plane
chore: pages endpoint updated (#1137)
This commit is contained in:
parent
11b28048bf
commit
4ce0ac6ea1
@ -18,7 +18,10 @@ export const AllPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
|
|||||||
const { data: pages } = useSWR(
|
const { data: pages } = useSWR(
|
||||||
workspaceSlug && projectId ? ALL_PAGES_LIST(projectId as string) : null,
|
workspaceSlug && projectId ? ALL_PAGES_LIST(projectId as string) : null,
|
||||||
workspaceSlug && projectId
|
workspaceSlug && projectId
|
||||||
? () => pagesService.getAllPages(workspaceSlug as string, projectId as string)
|
? () =>
|
||||||
|
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
|
||||||
|
page_view: "all",
|
||||||
|
})
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@ export const FavoritePagesList: React.FC<TPagesListProps> = ({ viewType }) => {
|
|||||||
const { data: pages } = useSWR(
|
const { data: pages } = useSWR(
|
||||||
workspaceSlug && projectId ? FAVORITE_PAGES_LIST(projectId as string) : null,
|
workspaceSlug && projectId ? FAVORITE_PAGES_LIST(projectId as string) : null,
|
||||||
workspaceSlug && projectId
|
workspaceSlug && projectId
|
||||||
? () => pagesService.getFavoritePages(workspaceSlug as string, projectId as string)
|
? () =>
|
||||||
|
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
|
||||||
|
page_view: "favorite",
|
||||||
|
})
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@ export const MyPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
|
|||||||
const { data: pages } = useSWR(
|
const { data: pages } = useSWR(
|
||||||
workspaceSlug && projectId ? MY_PAGES_LIST(projectId as string) : null,
|
workspaceSlug && projectId ? MY_PAGES_LIST(projectId as string) : null,
|
||||||
workspaceSlug && projectId
|
workspaceSlug && projectId
|
||||||
? () => pagesService.getMyPages(workspaceSlug as string, projectId as string)
|
? () =>
|
||||||
|
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
|
||||||
|
page_view: "created_by_me",
|
||||||
|
})
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@ export const OtherPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
|
|||||||
const { data: pages } = useSWR(
|
const { data: pages } = useSWR(
|
||||||
workspaceSlug && projectId ? OTHER_PAGES_LIST(projectId as string) : null,
|
workspaceSlug && projectId ? OTHER_PAGES_LIST(projectId as string) : null,
|
||||||
workspaceSlug && projectId
|
workspaceSlug && projectId
|
||||||
? () => pagesService.getOtherPages(workspaceSlug as string, projectId as string)
|
? () =>
|
||||||
|
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
|
||||||
|
page_view: "created_by_other",
|
||||||
|
})
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -83,42 +83,26 @@ class PageServices extends APIService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPagesWithParams(
|
||||||
|
workspaceSlug: string,
|
||||||
|
projectId: string,
|
||||||
|
queries: any
|
||||||
|
): Promise<IPage[]> {
|
||||||
|
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<RecentPagesResponse> {
|
async getRecentPages(workspaceSlug: string, projectId: string): Promise<RecentPagesResponse> {
|
||||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/recent-pages/`)
|
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, {
|
||||||
.then((response) => response?.data)
|
params: {
|
||||||
.catch((error) => {
|
page_view: "recent",
|
||||||
throw error?.response?.data;
|
},
|
||||||
});
|
})
|
||||||
}
|
|
||||||
|
|
||||||
async getAllPages(workspaceSlug: string, projectId: string): Promise<IPage[]> {
|
|
||||||
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<IPage[]> {
|
|
||||||
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<IPage[]> {
|
|
||||||
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<IPage[]> {
|
|
||||||
return this.get(
|
|
||||||
`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/created-by-other-pages/`
|
|
||||||
)
|
|
||||||
.then((response) => response?.data)
|
.then((response) => response?.data)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
throw error?.response?.data;
|
throw error?.response?.data;
|
||||||
|
Loading…
Reference in New Issue
Block a user