initial options types

This commit is contained in:
Владислав Чикалкин 2020-09-23 13:39:54 +03:00
parent 776bbc5b04
commit a9a0b0885c
2 changed files with 17 additions and 19 deletions

View File

@ -1,20 +1,18 @@
import axios from 'axios';
import {
IGetEntity,
IGetEntityOptionsResponse,
IGetInitialData,
IGetInitialDataResponse,
TGetEntityOptionsResponse,
TGetInitialOptions,
TGetInitialOptionsResponse,
} from 'core/types/Requests/Calculation';
class CalculationService {
static _getInitialData = ({
username,
}: IGetInitialData): Promise<IGetInitialDataResponse> =>
static getInitialOptions = (
elementsList: TGetInitialOptions,
): Promise<TGetInitialOptionsResponse> =>
new Promise((resolve, reject) => {
axios
.post('/api/calculation/getInitialData', {
username,
})
.post('/api/calculation/getInitialOptions', { elementsList })
.then(res => {
resolve(res.data);
})
@ -27,7 +25,7 @@ class CalculationService {
entityName,
fields,
where,
}: IGetEntity): Promise<IGetEntityOptionsResponse> =>
}: IGetEntity): Promise<TGetEntityOptionsResponse> =>
new Promise((resolve, reject) => {
axios
.post('/api/calculation/getEntityOptions', {

View File

@ -1,21 +1,21 @@
import { IOption } from 'core/types/Calculation/options';
import { EntityNames } from 'core/types/Entities/entityNames';
import { ElementsNames } from 'core/types/elements';
export interface IGetInitialData {
username: string;
}
export type TGetInitialOptions = {
[elementName in ElementsNames]?: IGetEntity;
};
export interface IGetInitialDataResponse {
leads: IOption[];
}
export type TGetInitialOptionsResponse = {
[elementName in ElementsNames]?: IOption[];
};
export interface IGetEntity {
// TODO enitity names list
entityName: EntityNames;
//TODO: remove ?
fields?: string[];
where?: { [prop: string]: any };
whereIn?: { [prop: string]: any };
[prop: string]: any;
}
export type IGetEntityOptionsResponse = IOption[];
export type TGetEntityOptionsResponse = IOption[];