2024-01-22 11:37:32 +00:00
|
|
|
import useSWR from "swr";
|
2024-02-21 13:50:46 +00:00
|
|
|
import { useCycle, useEstimate, useLabel, useModule, useProjectState } from "./store";
|
2024-01-22 11:37:32 +00:00
|
|
|
|
2024-01-25 08:57:35 +00:00
|
|
|
export const useWorkspaceIssueProperties = (workspaceSlug: string | string[] | undefined) => {
|
2024-01-22 11:37:32 +00:00
|
|
|
const { fetchWorkspaceLabels } = useLabel();
|
|
|
|
|
|
|
|
const { fetchWorkspaceStates } = useProjectState();
|
|
|
|
|
2024-01-25 08:57:35 +00:00
|
|
|
const { fetchWorkspaceEstimates } = useEstimate();
|
2024-01-22 11:37:32 +00:00
|
|
|
|
2024-02-21 13:50:46 +00:00
|
|
|
const { fetchWorkspaceModules } = useModule();
|
|
|
|
|
|
|
|
const { fetchWorkspaceCycles } = useCycle();
|
|
|
|
|
|
|
|
// fetch workspace Modules
|
|
|
|
useSWR(
|
|
|
|
workspaceSlug ? `WORKSPACE_MODULES_${workspaceSlug}` : null,
|
2024-02-28 09:48:11 +00:00
|
|
|
workspaceSlug ? () => fetchWorkspaceModules(workspaceSlug.toString()) : null,
|
|
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
2024-02-21 13:50:46 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// fetch workspace Cycles
|
|
|
|
useSWR(
|
|
|
|
workspaceSlug ? `WORKSPACE_CYCLES_${workspaceSlug}` : null,
|
2024-02-28 09:48:11 +00:00
|
|
|
workspaceSlug ? () => fetchWorkspaceCycles(workspaceSlug.toString()) : null,
|
|
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
2024-02-21 13:50:46 +00:00
|
|
|
);
|
|
|
|
|
2024-01-22 11:37:32 +00:00
|
|
|
// fetch workspace labels
|
|
|
|
useSWR(
|
|
|
|
workspaceSlug ? `WORKSPACE_LABELS_${workspaceSlug}` : null,
|
2024-02-28 09:48:11 +00:00
|
|
|
workspaceSlug ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null,
|
|
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
2024-01-22 11:37:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// fetch workspace states
|
|
|
|
useSWR(
|
|
|
|
workspaceSlug ? `WORKSPACE_STATES_${workspaceSlug}` : null,
|
2024-02-28 09:48:11 +00:00
|
|
|
workspaceSlug ? () => fetchWorkspaceStates(workspaceSlug.toString()) : null,
|
|
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
2024-01-22 11:37:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// fetch workspace estimates
|
|
|
|
useSWR(
|
|
|
|
workspaceSlug ? `WORKSPACE_ESTIMATES_${workspaceSlug}` : null,
|
2024-02-28 09:48:11 +00:00
|
|
|
workspaceSlug ? () => fetchWorkspaceEstimates(workspaceSlug.toString()) : null,
|
|
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
2024-01-22 11:37:32 +00:00
|
|
|
);
|
|
|
|
};
|