2023-05-20 12:00:15 +00:00
|
|
|
import useSWR from "swr";
|
|
|
|
|
|
|
|
// services
|
|
|
|
import issuesService from "services/issues.service";
|
|
|
|
// hooks
|
|
|
|
import useIssuesView from "hooks/use-issues-view";
|
|
|
|
// fetch-keys
|
|
|
|
import { VIEW_ISSUES } from "constants/fetch-keys";
|
|
|
|
|
|
|
|
const useGanttChartViewIssues = (
|
|
|
|
workspaceSlug: string | undefined,
|
|
|
|
projectId: string | undefined,
|
|
|
|
viewId: string | undefined
|
|
|
|
) => {
|
|
|
|
const { params } = useIssuesView();
|
|
|
|
const { order_by, group_by, ...viewGanttParams } = params;
|
|
|
|
|
|
|
|
// all issues under the view
|
|
|
|
const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR(
|
2023-08-11 10:29:13 +00:00
|
|
|
workspaceSlug && projectId && viewId
|
2023-08-28 07:55:47 +00:00
|
|
|
? VIEW_ISSUES(viewId.toString(), { ...viewGanttParams, order_by, start_target_date: true })
|
2023-08-11 10:29:13 +00:00
|
|
|
: null,
|
2023-05-20 12:00:15 +00:00
|
|
|
workspaceSlug && projectId && viewId
|
|
|
|
? () =>
|
2023-08-11 10:29:13 +00:00
|
|
|
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), {
|
|
|
|
...viewGanttParams,
|
|
|
|
start_target_date: true,
|
|
|
|
})
|
2023-05-20 12:00:15 +00:00
|
|
|
: null
|
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
ganttIssues,
|
|
|
|
mutateGanttIssues,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default useGanttChartViewIssues;
|