chore: page and cycle refactor (#1159)

* fix: release note modal fix

* chore: cycle and page endpoint refactor
This commit is contained in:
Anmol Singh Bhatia 2023-05-29 18:35:16 +05:30 committed by GitHub
parent 26ba4d71c3
commit c8caa925b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 51 additions and 50 deletions

View File

@ -21,9 +21,7 @@ export const AllCyclesList: React.FC<Props> = ({ viewType }) => {
workspaceSlug && projectId ? CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {
cycle_view: "all",
})
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), "all")
: null
);

View File

@ -21,9 +21,11 @@ export const CompletedCyclesList: React.FC<Props> = ({ viewType }) => {
workspaceSlug && projectId ? COMPLETED_CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {
cycle_view: "completed",
})
cyclesService.getCyclesWithParams(
workspaceSlug.toString(),
projectId.toString(),
"completed"
)
: null
);

View File

@ -21,9 +21,7 @@ export const DraftCyclesList: React.FC<Props> = ({ viewType }) => {
workspaceSlug && projectId ? DRAFT_CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {
cycle_view: "draft",
})
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), "draft")
: null
);

View File

@ -21,9 +21,11 @@ export const UpcomingCyclesList: React.FC<Props> = ({ viewType }) => {
workspaceSlug && projectId ? UPCOMING_CYCLES_LIST(projectId.toString()) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug.toString(), projectId.toString(), {
cycle_view: "upcoming",
})
cyclesService.getCyclesWithParams(
workspaceSlug.toString(),
projectId.toString(),
"upcoming"
)
: null
);

View File

@ -38,10 +38,7 @@ export const CycleSelect: React.FC<IssueCycleSelectProps> = ({
const { data: cycles } = useSWR(
workspaceSlug && projectId ? CYCLES_LIST(projectId) : null,
workspaceSlug && projectId
? () =>
cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, {
cycle_view: "all",
})
? () => cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, "all")
: null
);

View File

@ -60,9 +60,11 @@ export const TransferIssuesModal: React.FC<Props> = ({ isOpen, handleClose }) =>
workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug as string, projectId as string, {
cycle_view: "incomplete",
})
cyclesService.getCyclesWithParams(
workspaceSlug as string,
projectId as string,
"incomplete"
)
: null
);

View File

@ -36,9 +36,11 @@ export const SidebarCycleSelect: React.FC<Props> = ({
workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cyclesService.getCyclesWithParams(workspaceSlug as string, projectId as string, {
cycle_view: "incomplete",
})
cyclesService.getCyclesWithParams(
workspaceSlug as string,
projectId as string,
"incomplete"
)
: null
);

View File

@ -18,10 +18,7 @@ export const AllPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
const { data: pages } = useSWR(
workspaceSlug && projectId ? ALL_PAGES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
page_view: "all",
})
? () => pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, "all")
: null
);

View File

@ -19,9 +19,7 @@ export const FavoritePagesList: React.FC<TPagesListProps> = ({ viewType }) => {
workspaceSlug && projectId ? FAVORITE_PAGES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
page_view: "favorite",
})
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, "favorite")
: null
);

View File

@ -19,9 +19,11 @@ export const MyPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
workspaceSlug && projectId ? MY_PAGES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
page_view: "created_by_me",
})
pagesService.getPagesWithParams(
workspaceSlug as string,
projectId as string,
"created_by_me"
)
: null
);

View File

@ -19,9 +19,11 @@ export const OtherPagesList: React.FC<TPagesListProps> = ({ viewType }) => {
workspaceSlug && projectId ? OTHER_PAGES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
pagesService.getPagesWithParams(workspaceSlug as string, projectId as string, {
page_view: "created_by_other",
})
pagesService.getPagesWithParams(
workspaceSlug as string,
projectId as string,
"created_by_other"
)
: null
);

View File

@ -41,10 +41,12 @@ const WorkspacePage: NextPage = () => {
return (
<WorkspaceAuthorizationLayout noHeader>
<ProductUpdatesModal
isOpen={isProductUpdatesModalOpen}
setIsOpen={setIsProductUpdatesModalOpen}
/>
{isProductUpdatesModalOpen && (
<ProductUpdatesModal
isOpen={isProductUpdatesModalOpen}
setIsOpen={setIsProductUpdatesModalOpen}
/>
)}
<div className="p-8">
<div className="flex flex-col gap-8">
<div className="text-brand-muted-1 flex flex-col justify-between gap-x-2 gap-y-6 rounded-lg border border-brand-base bg-brand-base px-8 py-6 md:flex-row md:items-center md:py-3">

View File

@ -56,10 +56,7 @@ const SingleCycle: React.FC = () => {
const { data: cycles } = useSWR(
workspaceSlug && projectId ? CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, {
cycle_view: "all",
})
? () => cycleServices.getCyclesWithParams(workspaceSlug as string, projectId as string, "all")
: null
);

View File

@ -73,9 +73,7 @@ const ProjectCycles: NextPage = () => {
workspaceSlug && projectId ? CURRENT_CYCLE_LIST(projectId as string) : null,
workspaceSlug && projectId
? () =>
cycleService.getCyclesWithParams(workspaceSlug as string, projectId as string, {
cycle_view: "current",
})
cycleService.getCyclesWithParams(workspaceSlug as string, projectId as string, "current")
: null
);

View File

@ -29,10 +29,12 @@ class ProjectCycleServices extends APIService {
async getCyclesWithParams(
workspaceSlug: string,
projectId: string,
queries: any
cycleType: "all" | "current" | "upcoming" | "draft" | "completed" | "incomplete"
): Promise<ICycle[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/`, {
params: queries,
params: {
cycle_view: cycleType,
},
})
.then((response) => response?.data)
.catch((error) => {

View File

@ -86,10 +86,12 @@ class PageServices extends APIService {
async getPagesWithParams(
workspaceSlug: string,
projectId: string,
queries: any
pageType: "all" | "favorite" | "created_by_me" | "created_by_other"
): Promise<IPage[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, {
params: queries,
params: {
page_view: pageType,
},
})
.then((response) => response?.data)
.catch((error) => {