From 1e7be73803000bc5ceaba30ac9a29188fd4c3369 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 11 Aug 2022 19:12:53 -0400 Subject: [PATCH] fix(striker-ui): add submit message to StrikerInitForm --- striker-ui/components/StrikerInitForm.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/striker-ui/components/StrikerInitForm.tsx b/striker-ui/components/StrikerInitForm.tsx index 0fdf8c8b..158ae437 100644 --- a/striker-ui/components/StrikerInitForm.tsx +++ b/striker-ui/components/StrikerInitForm.tsx @@ -6,6 +6,7 @@ import GeneralInitForm, { GeneralInitFormForwardRefContent, } from './GeneralInitForm'; import mainAxiosInstance from '../lib/singletons/mainAxiosInstance'; +import MessageBox, { Message } from './MessageBox'; import NetworkInitForm, { NetworkInitFormForwardRefContent, } from './NetworkInitForm'; @@ -14,6 +15,7 @@ import Spinner from './Spinner'; import { HeaderText } from './Text'; const StrikerInitForm: FC = () => { + const [submitMessage, setSubmitMessage] = useState(); const [isSubmittingForm, setIsSubmittingForm] = useState(false); const generalInitFormRef = useRef({}); @@ -39,6 +41,14 @@ const StrikerInitForm: FC = () => { headers: { 'Content-Type': 'application/json' }, }) .then(() => { + setIsSubmittingForm(false); + }) + .catch((reason) => { + setSubmitMessage({ + children: `Failed to submit; ${reason}`, + type: 'error', + }); + setIsSubmittingForm(false); }); }} @@ -58,6 +68,12 @@ const StrikerInitForm: FC = () => { + {submitMessage && ( + setSubmitMessage(undefined)} + /> + )} {buildSubmitSection}