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.
Владислав Чикалкин 83210411d3 add loading spinner
2020-09-24 12:20:47 +03:00

60 lines
1.6 KiB
JavaScript

import { Spin } from 'antd';
import { useStores } from 'client/hooks/useStores';
import CalculationService from 'client/services/CalculationService';
import { Box, Flex } from 'client/UIKit/grid';
import initialOptionsMap from 'core/Data/initialOptionsMap';
import React, { useEffect, useState } from 'react';
import Results from './Results';
import Sections from './Sections';
const Calculation = () => {
const [ready, setReady] = useState(false);
const { calculationStore } = useStores();
useEffect(() => {
Promise.all([
CalculationService.getInitialOptions({
elementsList: initialOptionsMap,
}),
CalculationService.getEntityOptions({
entityName: 'lead',
fields: undefined,
where: undefined,
}),
])
.then(([initialOptions, leadOptions]) => {
calculationStore.applyOptions({ ...initialOptions });
calculationStore.applyOptions({ selectLead: leadOptions });
setReady(true);
})
.catch(err => {
throw err;
});
}, []);
if (!ready) {
return (
<Box height="100%" py="10px">
<Flex justifyContent="center" alignItems="center">
<Spin />
</Flex>
</Box>
);
}
return (
<Box mx={['0', '1%', '1%', '1.5%', '2%', '10%']}>
<Flex flexWrap="wrap" mb="50px">
<Sections flex={['1', '1', '1', '3']} />
<Results
flex={['1', '1', '1', '1']}
justifyContent="center"
// position={['sticky', 'sticky', 'sticky', 'relative']}
// bottom={[0, 0, 0, null]}
/>
</Flex>
</Box>
);
};
export default Calculation;