This repository has been archived on 2025-05-09. You can view files and clone it, but cannot push or open issues or pull requests.
Владислав Чикалкин b34bbeb3c4 MANY: types & get entity options
2020-09-22 18:46:14 +03:00

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;