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,
} 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<Message | undefined>();
const [isSubmittingForm, setIsSubmittingForm] = useState<boolean>(false);
const generalInitFormRef = useRef<GeneralInitFormForwardRefContent>({});
@ -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 = () => {
<FlexBox>
<GeneralInitForm ref={generalInitFormRef} />
<NetworkInitForm ref={networkInitFormRef} />
{submitMessage && (
<MessageBox
{...submitMessage}
onClose={() => setSubmitMessage(undefined)}
/>
)}
{buildSubmitSection}
</FlexBox>
</Panel>

Loading…
Cancel
Save