mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
feat: make impact metrics config save call
This commit is contained in:
parent
4908a2d906
commit
5c78c5cbe2
@ -0,0 +1,32 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
|
import useAPI from '../useApi/useApi.js';
|
||||||
|
import type { ImpactMetricsConfigSchema } from '../../../../openapi.js';
|
||||||
|
|
||||||
|
export const useImpactMetricsApi = () => {
|
||||||
|
const { makeRequest, createRequest, errors, loading } = useAPI({
|
||||||
|
propagateErrors: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateImpactMetric = useCallback(
|
||||||
|
async (config: ImpactMetricsConfigSchema) => {
|
||||||
|
const path = `api/admin/impact-metrics/config`;
|
||||||
|
const req = createRequest(
|
||||||
|
path,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(config),
|
||||||
|
},
|
||||||
|
'updateImpactMetric',
|
||||||
|
);
|
||||||
|
|
||||||
|
return makeRequest(req.caller, req.id);
|
||||||
|
},
|
||||||
|
[makeRequest, createRequest],
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
updateImpactMetric,
|
||||||
|
errors,
|
||||||
|
loading,
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user