UNPKG

@roadiehq/backstage-plugin-jira

Version:
26 lines (23 loc) 720 B
import { useCallback } from 'react'; import { useApi } from '@backstage/core-plugin-api'; import { useAsync } from 'react-use'; import { handleError } from './utils.esm.js'; import { jiraApiRef } from '../api/index.esm.js'; const useStatuses = (projectKey) => { const api = useApi(jiraApiRef); const getStatuses = useCallback(async () => { try { return await api.getStatuses(projectKey); } catch (err) { return handleError(err); } }, [api, projectKey]); const { loading, value, error } = useAsync(() => getStatuses(), []); return { statusesLoading: loading, statuses: value, statusesError: error }; }; export { useStatuses }; //# sourceMappingURL=useStatuses.esm.js.map