32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import type * as ELT from './types';
|
|
import getUrls from '@/config/urls';
|
|
import type { QueryFunctionContext } from '@tanstack/react-query';
|
|
import type { AxiosError } from 'axios';
|
|
import axios from 'axios';
|
|
|
|
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
|
|
|
|
export async function getEltOsago(payload: ELT.RequestEltOsago, { signal }: QueryFunctionContext) {
|
|
return axios
|
|
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal })
|
|
.then((response) => response.data)
|
|
.catch((error: AxiosError | Error) => {
|
|
if (axios.isAxiosError(error)) {
|
|
// TODO: track error
|
|
throw new Error(error.message);
|
|
}
|
|
});
|
|
}
|
|
|
|
export async function getEltKasko(payload: ELT.RequestEltKasko, { signal }: QueryFunctionContext) {
|
|
return axios
|
|
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { signal })
|
|
.then((response) => response.data)
|
|
.catch((error: AxiosError | Error) => {
|
|
if (axios.isAxiosError(error)) {
|
|
// TODO: track error
|
|
throw new Error(error.message);
|
|
}
|
|
});
|
|
}
|