import { Chart } from '@baseline/types/chart'; import { getRequestHandler } from './request-handler'; export const getChart = async (chartId: string): Promise => { const response = await getRequestHandler().request({ method: 'GET', url: `chart/admin/${chartId}`, hasAuthentication: true, }); if ('data' in response) { return response.data; } throw response; }; export const getAllCharts = async (): Promise => { const response = await getRequestHandler().request({ method: 'GET', url: `chart/admin/list`, hasAuthentication: true, }); if ('data' in response) { return response.data; } throw response; }; export const deleteChart = async (chartId: string): Promise => { const response = await getRequestHandler().request({ method: 'DELETE', url: `chart/admin/${chartId}`, hasAuthentication: true, }); if ('data' in response) { return response.data; } throw response; }; export const createChart = async (chart: Partial): Promise => { const response = await getRequestHandler().request({ method: 'POST', url: `chart/admin`, hasAuthentication: true, data: chart, }); if ('data' in response) { return response.data; } throw response; }; export const updateChart = async (chart: Partial): Promise => { const response = await getRequestHandler().request({ method: 'PATCH', url: `chart/admin`, hasAuthentication: true, data: chart, }); if ('data' in response) { return response.data; } throw response; };