diff --git a/src/client/services/CalculationService.ts b/src/client/services/CalculationService.ts index d2e6f21..527a05c 100644 --- a/src/client/services/CalculationService.ts +++ b/src/client/services/CalculationService.ts @@ -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 => + static getInitialOptions = ( + elementsList: TGetInitialOptions, + ): Promise => 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 => + }: IGetEntity): Promise => new Promise((resolve, reject) => { axios .post('/api/calculation/getEntityOptions', { diff --git a/src/core/types/Requests/Calculation.ts b/src/core/types/Requests/Calculation.ts index 976fc21..a40f26f 100644 --- a/src/core/types/Requests/Calculation.ts +++ b/src/core/types/Requests/Calculation.ts @@ -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[];