mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
23 lines
594 B
TypeScript
23 lines
594 B
TypeScript
|
import useSWR from "swr";
|
||
|
// services
|
||
|
import userService from "services/user.service";
|
||
|
// types
|
||
|
import type { IIssue } from "types";
|
||
|
// fetch-keys
|
||
|
import { USER_ISSUE } from "constants/fetch-keys";
|
||
|
|
||
|
const useIssues = (workspaceSlug: string | undefined) => {
|
||
|
// API Fetching
|
||
|
const { data: myIssues, mutate: mutateMyIssues } = useSWR<IIssue[]>(
|
||
|
workspaceSlug ? USER_ISSUE(workspaceSlug as string) : null,
|
||
|
workspaceSlug ? () => userService.userIssues(workspaceSlug as string) : null
|
||
|
);
|
||
|
|
||
|
return {
|
||
|
myIssues: myIssues || [],
|
||
|
mutateMyIssues,
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export default useIssues;
|