Commit 6834d675 authored by Eric Rosenbaum's avatar Eric Rosenbaum

disable confirm button while submitting

parent 5d838ef6
...@@ -31,6 +31,7 @@ const TransferHostConfirmation = ({ ...@@ -31,6 +31,7 @@ const TransferHostConfirmation = ({
const newHostUsername = items.find(item => item.id === selectedId).username; const newHostUsername = items.find(item => item.id === selectedId).username;
const newHostImage = items.find(item => item.id === selectedId).profile.images['90x90']; const newHostImage = items.find(item => item.id === selectedId).profile.images['90x90'];
const [passwordInputValue, setPasswordInputValue] = useState(''); const [passwordInputValue, setPasswordInputValue] = useState('');
const [submitting, setSubmitting] = useState(false);
const [validationError, setValidationError] = useState(null); const [validationError, setValidationError] = useState(null);
const {errorAlert, successAlert} = useAlertContext(); const {errorAlert, successAlert} = useAlertContext();
...@@ -43,6 +44,7 @@ const TransferHostConfirmation = ({ ...@@ -43,6 +44,7 @@ const TransferHostConfirmation = ({
}; };
const handleSubmit = () => { const handleSubmit = () => {
setSubmitting(true);
handleTransferHost(passwordInputValue, newHostUsername, selectedId) handleTransferHost(passwordInputValue, newHostUsername, selectedId)
.then(() => { .then(() => {
handleClose(); handleClose();
...@@ -54,6 +56,7 @@ const TransferHostConfirmation = ({ ...@@ -54,6 +56,7 @@ const TransferHostConfirmation = ({
.catch(e => { .catch(e => {
// For password errors, show validation alert without closing the modal // For password errors, show validation alert without closing the modal
if (e === Errors.PERMISSION) { if (e === Errors.PERMISSION) {
setSubmitting(false);
setValidationError(e); setValidationError(e);
return; return;
} }
...@@ -149,7 +152,7 @@ const TransferHostConfirmation = ({ ...@@ -149,7 +152,7 @@ const TransferHostConfirmation = ({
<button <button
className="button" className="button"
type="submit" type="submit"
disabled={passwordInputValue === '' || validationError} disabled={passwordInputValue === '' || submitting || validationError}
> >
<FormattedMessage id="studio.confirm" /> <FormattedMessage id="studio.confirm" />
</button> </button>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment