2023-05-20 12:00:15 +00:00
|
|
|
import useSWR from "swr";
|
|
|
|
|
|
|
|
// services
|
|
|
|
import issuesService from "services/issues.service";
|
2023-08-11 10:29:13 +00:00
|
|
|
// hooks
|
|
|
|
import useIssuesView from "hooks/use-issues-view";
|
2023-05-20 12:00:15 +00:00
|
|
|
// fetch-keys
|
|
|
|
import { PROJECT_ISSUES_LIST_WITH_PARAMS } from "constants/fetch-keys";
|
|
|
|
|
|
|
|
const useGanttChartIssues = (workspaceSlug: string | undefined, projectId: string | undefined) => {
|
2023-08-11 10:29:13 +00:00
|
|
|
const { orderBy, filters, showSubIssues } = useIssuesView();
|
|
|
|
|
|
|
|
const params: any = {
|
|
|
|
order_by: orderBy,
|
|
|
|
type: filters?.type ? filters?.type : undefined,
|
|
|
|
sub_issue: showSubIssues,
|
|
|
|
start_target_date: true,
|
|
|
|
};
|
|
|
|
|
2023-05-20 12:00:15 +00:00
|
|
|
// all issues under the workspace and project
|
|
|
|
const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR(
|
2023-08-11 10:29:13 +00:00
|
|
|
workspaceSlug && projectId ? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId, params) : null,
|
2023-05-20 12:00:15 +00:00
|
|
|
workspaceSlug && projectId
|
2023-08-11 10:29:13 +00:00
|
|
|
? () =>
|
|
|
|
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
2023-05-20 12:00:15 +00:00
|
|
|
: null
|
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
ganttIssues,
|
|
|
|
mutateGanttIssues,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default useGanttChartIssues;
|