1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-19 01:17:18 +02:00
unleash.unleash/frontend/src/hooks/api/getters/useProjectStatus/useProjectStatus.ts
Jaanus Sellin 8a507b2eec
feat: connect project health frontend with backend (#8695)
1. Connected project health frontend with backend
2. Synced orval
2024-11-08 10:53:45 +02:00

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 };
};