1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00
unleash.unleash/frontend/src/hooks/api/getters/useLifecycleCount/useLifecycleCount.ts
Tymoteusz Czech 3ac087e0f6
feat: count per lifecycle stage (#9845)
Show count per stage, and include count if flags are filtered.
2025-04-25 10:52:11 +00:00

24 lines
640 B
TypeScript

import { formatApiPath } from 'utils/formatPath';
import useSWR from 'swr';
import type { FeatureLifecycleCountSchema } from 'openapi';
import handleErrorResponses from '../httpErrorResponseHandler';
export const useLifecycleCount = () => {
const { data, error } = useSWR<FeatureLifecycleCountSchema>(
formatApiPath('api/admin/lifecycle/count'),
fetcher,
);
return {
lifecycleCount: data,
error,
loading: !error && !data,
};
};
const fetcher = (path: string) => {
return fetch(path)
.then(handleErrorResponses('Lifecycle count'))
.then((res) => res.json());
};