From 92909a19ed2c72876d9a6ca6397efb6f0f71c34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A7=D0=B8=D0=BA=D0=B0=D0=BB=D0=BA=D0=B8=D0=BD?= Date: Thu, 24 Sep 2020 13:19:13 +0300 Subject: [PATCH] add server error result --- src/client/Components/{Result.tsx => Result.jsx} | 4 ++++ src/client/Containers/Calculation/index.jsx | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) rename src/client/Components/{Result.tsx => Result.jsx} (59%) diff --git a/src/client/Components/Result.tsx b/src/client/Components/Result.jsx similarity index 59% rename from src/client/Components/Result.tsx rename to src/client/Components/Result.jsx index f56f83e..fd883dd 100644 --- a/src/client/Components/Result.tsx +++ b/src/client/Components/Result.jsx @@ -4,3 +4,7 @@ import { Result, Button } from 'antd'; export const NotFound = () => ( ); + +export const ServerError = () => ( + +); diff --git a/src/client/Containers/Calculation/index.jsx b/src/client/Containers/Calculation/index.jsx index 7f63c44..9f53fe0 100644 --- a/src/client/Containers/Calculation/index.jsx +++ b/src/client/Containers/Calculation/index.jsx @@ -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 ( @@ -43,6 +46,10 @@ const Calculation = () => { ); } + if (error) { + return ; + } + const ModalComponent = withStoreModal(Modal); return (