1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-17 13:46:47 +02:00
unleash.unleash/frontend/src/hooks/api/actions/useFeatureLifecycleApi/useFeatureLifecycleApi.ts
Jaanus Sellin 28a7797aea
feat: feature lifecycle completed schema (#7021)
1. Added new schema and tests
2. Controller also accepts the data
3. Also sending fake data from frontend currently

Next steps, implement service/store layer and frontend
2024-05-09 09:51:44 +03:00

37 lines
1.0 KiB
TypeScript

import useAPI from '../useApi/useApi';
const useFeatureLifecycleApi = () => {
const { makeRequest, makeLightRequest, createRequest, errors, loading } =
useAPI({
propagateErrors: true,
});
const markFeatureCompleted = async (name: string, project: string) => {
const path = `api/admin/projects/${project}/features/${name}/lifecycle/complete`;
const req = createRequest(path, {
method: 'POST',
body: JSON.stringify({ status: 'kept' }),
});
return makeRequest(req.caller, req.id);
};
const markFeatureUncompleted = async (name: string, project: string) => {
const path = `api/admin/projects/${project}/features/${name}/lifecycle/uncomplete`;
const req = createRequest(path, {
method: 'POST',
});
return makeRequest(req.caller, req.id);
};
return {
markFeatureCompleted,
markFeatureUncompleted,
errors,
loading,
};
};
export default useFeatureLifecycleApi;