1
0
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:
kwasniew 2025-08-29 11:04:14 +02:00
parent 4908a2d906
commit 5c78c5cbe2
No known key found for this signature in database
GPG Key ID: 43A7CBC24C119560

View File

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