mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
27 lines
838 B
TypeScript
27 lines
838 B
TypeScript
import { fetcher, useApiGetter } from '../useApiGetter/useApiGetter';
|
|
import type { ProjectStatusSchema } from '../../../../openapi';
|
|
import { formatApiPath } from 'utils/formatPath';
|
|
|
|
const path = (projectId: string) => `api/admin/projects/${projectId}/status`;
|
|
|
|
const placeholderData: ProjectStatusSchema = {
|
|
activityCountByDate: [],
|
|
resources: {
|
|
connectedEnvironments: 0,
|
|
members: 0,
|
|
apiTokens: 0,
|
|
segments: 0,
|
|
},
|
|
averageHealth: 0,
|
|
};
|
|
|
|
export const useProjectStatus = (projectId: string) => {
|
|
const projectPath = formatApiPath(path(projectId));
|
|
const { data, refetch, loading, error } = useApiGetter<ProjectStatusSchema>(
|
|
projectPath,
|
|
() => fetcher(projectPath, 'Project Status'),
|
|
);
|
|
|
|
return { data: data || placeholderData, refetch, loading, error };
|
|
};
|