mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import axios from 'axios';
|
|
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
|
import { BaseApiResponse } from '@/types/api/api-general';
|
|
import {
|
|
SetAllowNegativePakanOvkPayload,
|
|
SystemSetting,
|
|
} from '@/types/api/system-settings/system-setting';
|
|
|
|
const BASE_PATH = '/system-settings';
|
|
|
|
export const SystemSettingsApi = {
|
|
basePath: BASE_PATH,
|
|
|
|
getAllFetcher: (
|
|
endpoint: string
|
|
): Promise<BaseApiResponse<SystemSetting[]>> =>
|
|
httpClientFetcher<BaseApiResponse<SystemSetting[]>>(endpoint),
|
|
|
|
async getAll(): Promise<BaseApiResponse<SystemSetting[]> | undefined> {
|
|
try {
|
|
return await httpClient<BaseApiResponse<SystemSetting[]>>(BASE_PATH);
|
|
} catch (error) {
|
|
if (axios.isAxiosError<BaseApiResponse<SystemSetting[]>>(error)) {
|
|
return error.response?.data;
|
|
}
|
|
return undefined;
|
|
}
|
|
},
|
|
|
|
async setAllowNegativePakanOvk(
|
|
payload: SetAllowNegativePakanOvkPayload
|
|
): Promise<BaseApiResponse | undefined> {
|
|
try {
|
|
return await httpClient<BaseApiResponse>(
|
|
`${BASE_PATH}/allow-negative-pakan-ovk`,
|
|
{
|
|
method: 'PATCH',
|
|
body: payload,
|
|
}
|
|
);
|
|
} catch (error) {
|
|
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
|
return error.response?.data;
|
|
}
|
|
return undefined;
|
|
}
|
|
},
|
|
};
|