add server error result
This commit is contained in:
parent
91e8cd3d1f
commit
92909a19ed
@ -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={'Ой! Что-то сломалось.'} />
|
||||
);
|
||||
@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user