fix(striker-ui): add submit message to StrikerInitForm

main
Tsu-ba-me 2 years ago
parent 3b0291b776
commit 1e7be73803
  1. 16
      striker-ui/components/StrikerInitForm.tsx

@ -6,6 +6,7 @@ import GeneralInitForm, {
GeneralInitFormForwardRefContent, GeneralInitFormForwardRefContent,
} from './GeneralInitForm'; } from './GeneralInitForm';
import mainAxiosInstance from '../lib/singletons/mainAxiosInstance'; import mainAxiosInstance from '../lib/singletons/mainAxiosInstance';
import MessageBox, { Message } from './MessageBox';
import NetworkInitForm, { import NetworkInitForm, {
NetworkInitFormForwardRefContent, NetworkInitFormForwardRefContent,
} from './NetworkInitForm'; } from './NetworkInitForm';
@ -14,6 +15,7 @@ import Spinner from './Spinner';
import { HeaderText } from './Text'; import { HeaderText } from './Text';
const StrikerInitForm: FC = () => { const StrikerInitForm: FC = () => {
const [submitMessage, setSubmitMessage] = useState<Message | undefined>();
const [isSubmittingForm, setIsSubmittingForm] = useState<boolean>(false); const [isSubmittingForm, setIsSubmittingForm] = useState<boolean>(false);
const generalInitFormRef = useRef<GeneralInitFormForwardRefContent>({}); const generalInitFormRef = useRef<GeneralInitFormForwardRefContent>({});
@ -39,6 +41,14 @@ const StrikerInitForm: FC = () => {
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
}) })
.then(() => { .then(() => {
setIsSubmittingForm(false);
})
.catch((reason) => {
setSubmitMessage({
children: `Failed to submit; ${reason}`,
type: 'error',
});
setIsSubmittingForm(false); setIsSubmittingForm(false);
}); });
}} }}
@ -58,6 +68,12 @@ const StrikerInitForm: FC = () => {
<FlexBox> <FlexBox>
<GeneralInitForm ref={generalInitFormRef} /> <GeneralInitForm ref={generalInitFormRef} />
<NetworkInitForm ref={networkInitFormRef} /> <NetworkInitForm ref={networkInitFormRef} />
{submitMessage && (
<MessageBox
{...submitMessage}
onClose={() => setSubmitMessage(undefined)}
/>
)}
{buildSubmitSection} {buildSubmitSection}
</FlexBox> </FlexBox>
</Panel> </Panel>

Loading…
Cancel
Save