plane/apps/app/hooks/use-sub-issue.tsx
Anmol Singh Bhatia e08fc59114
feat: spreadsheet view (#1369)
* feat: spreadsheet view

* fix: fix scroll and overflow issues, feat: updated issue properties component, style: ui improvements

* feat: sub-issue toggle and sub-issue hook added, chore: code refactor

* fix: only render parent issue

* feat: sub issue fetching hook updated and nested sub issue added, chore: code refactor

* style: title sticky to left on scroll and column styling

* fix: tooltip , filter and view z-index fix

* feat: spreadsheet view column sorting, fix: sticky scroll issue fix

* feat: updated issue view filter for spreadsheet view

* style: spreadsheet view column

* feat: double click to edit title

* fix: estimate sorting fix

* style: spreadsheet view columns

* fix: spreadsheet view mutation, feat: edit , copy and delete option added

* fix: edit sub issue fix
2023-06-23 17:20:05 +05:30

35 lines
917 B
TypeScript

import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import useSWR from "swr";
// services
import issuesService from "services/issues.service";
// types
import { ISubIssueResponse } from "types";
// fetch-keys
import { SUB_ISSUES } from "constants/fetch-keys";
const useSubIssue = (issueId: string, isExpanded: boolean) => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
const shouldFetch = workspaceSlug && projectId && issueId && isExpanded;
const { data: subIssuesResponse, isLoading } = useSWR<ISubIssueResponse>(
shouldFetch ? SUB_ISSUES(issueId as string) : null,
shouldFetch
? () =>
issuesService.subIssues(workspaceSlug as string, projectId as string, issueId as string)
: null
);
return {
subIssues: subIssuesResponse?.sub_issues ?? [],
isLoading,
};
};
export default useSubIssue;