49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import axios from 'axios';
|
|
import {
|
|
IGetEntity,
|
|
IGetEntityOptionsResponse,
|
|
IGetInitialData,
|
|
IGetInitialDataResponse,
|
|
} from 'core/types/Requests/Calculation';
|
|
|
|
class ComponentsService {
|
|
static _getInitialData = ({
|
|
username,
|
|
}: IGetInitialData): Promise<IGetInitialDataResponse> =>
|
|
new Promise((resolve, reject) => {
|
|
axios
|
|
.post('/api/calculation/getInitialData', {
|
|
username,
|
|
})
|
|
.then(res => {
|
|
resolve(res.data);
|
|
})
|
|
.catch(err => {
|
|
reject(err);
|
|
});
|
|
});
|
|
|
|
static getEntityOptions = ({
|
|
entityName,
|
|
fields,
|
|
where,
|
|
}: IGetEntity): Promise<IGetEntityOptionsResponse> =>
|
|
new Promise((resolve, reject) => {
|
|
axios
|
|
.post('/api/calculation/getEntityOptions', {
|
|
entityName,
|
|
fields,
|
|
where,
|
|
})
|
|
.then(res => {
|
|
const { entityOptions } = res.data;
|
|
resolve(entityOptions);
|
|
})
|
|
.catch(err => {
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
export default ComponentsService;
|