add server error result

This commit is contained in:
Владислав Чикалкин 2020-09-24 13:19:13 +03:00
parent 91e8cd3d1f
commit 92909a19ed
2 changed files with 12 additions and 1 deletions

View File

@ -4,3 +4,7 @@ import { Result, Button } from 'antd';
export const NotFound = () => (
<Result status="404" title="404" subTitle="Ой! Тут ничего нет." />
);
export const ServerError = () => (
<Result status="500" title="500" subTitle={'Ой! Что-то сломалось.'} />
);

View File

@ -1,4 +1,5 @@
import { Spin } from 'antd';
import { ServerError } from 'client/Components/Result';
import Modal from 'client/Elements/Modal';
import { withStoreModal } from 'client/hocs/withStore';
import { useStores } from 'client/hooks/useStores';
@ -11,6 +12,7 @@ import Sections from './Sections';
const Calculation = () => {
const [ready, setReady] = useState(false);
const [error, setError] = useState(undefined);
const { calculationStore } = useStores();
useEffect(() => {
Promise.all([
@ -29,11 +31,12 @@ const Calculation = () => {
setReady(true);
})
.catch(err => {
setError(err);
throw err;
});
}, []);
if (!ready) {
if (!error && !ready) {
return (
<Box height="100%" py="10px">
<Flex justifyContent="center" alignItems="center">
@ -43,6 +46,10 @@ const Calculation = () => {
);
}
if (error) {
return <ServerError />;
}
const ModalComponent = withStoreModal(Modal);
return (