move calculationservice to single file
This commit is contained in:
parent
b34bbeb3c4
commit
bb6ff077fa
@ -1,5 +1,5 @@
|
||||
import { useStores } from 'client/hooks/useStores';
|
||||
import { ComponentsService } from 'client/services/CalculationService';
|
||||
import CalculationService from 'client/services/CalculationService';
|
||||
import { Box, Flex } from 'client/UIKit/grid';
|
||||
import React, { useEffect } from 'react';
|
||||
import Results from './Results';
|
||||
@ -8,7 +8,7 @@ import Sections from './Sections';
|
||||
const Calculation = () => {
|
||||
const { calculationStore } = useStores();
|
||||
useEffect(() => {
|
||||
ComponentsService.getEntityOptions({
|
||||
CalculationService.getEntityOptions({
|
||||
entityName: 'lead',
|
||||
fields: undefined,
|
||||
where: undefined,
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
IGetInitialDataResponse,
|
||||
} from 'core/types/Requests/Calculation';
|
||||
|
||||
class ComponentsService {
|
||||
class CalculationService {
|
||||
static _getInitialData = ({
|
||||
username,
|
||||
}: IGetInitialData): Promise<IGetInitialDataResponse> =>
|
||||
@ -45,4 +45,4 @@ class ComponentsService {
|
||||
});
|
||||
}
|
||||
|
||||
export default ComponentsService;
|
||||
export default CalculationService;
|
||||
@ -1,35 +0,0 @@
|
||||
import axios from 'axios';
|
||||
import {
|
||||
IGetEntity,
|
||||
IGetEntityOptionsResponse,
|
||||
} from 'core/types/Requests/Calculation';
|
||||
|
||||
class EntityService {
|
||||
static getEntityOptions = ({
|
||||
entityName,
|
||||
fields,
|
||||
where,
|
||||
...props
|
||||
}: IGetEntity): Promise<IGetEntityOptionsResponse> =>
|
||||
new Promise((resolve, reject) => {
|
||||
axios({
|
||||
url: '/api/calculation/getEntityOptions',
|
||||
method: 'POST',
|
||||
data: {
|
||||
entityName,
|
||||
fields,
|
||||
where,
|
||||
...props,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
const { entityOptions }: IGetEntityOptionsResponse = res.data;
|
||||
resolve({ entityOptions });
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default EntityService;
|
||||
@ -1,4 +0,0 @@
|
||||
import ComponentsService from './Components';
|
||||
import EntityService from './Entity';
|
||||
|
||||
export { ComponentsService, EntityService };
|
||||
@ -5,7 +5,7 @@ import {
|
||||
IGetInitialDataResponse,
|
||||
} from 'core/types/Requests/Calculation';
|
||||
import { Request, Response } from 'express';
|
||||
import entityFakeData from '../../core/fakeData/entity';
|
||||
import entityFakeData from '../../core/fakeData/entityFakes';
|
||||
import { EntityNames } from 'core/types/Entities/entityNames';
|
||||
|
||||
function _getFakeEntities(entityName, fields, where) {
|
||||
|
||||
Reference in New Issue
Block a user