mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-25 05:44:13 -05:00
disable confirm button while submitting
This commit is contained in:
parent
5d838ef659
commit
6834d675b1
1 changed files with 4 additions and 1 deletions
|
@ -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 = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
|
setSubmitting(true);
|
||||||
handleTransferHost(passwordInputValue, newHostUsername, selectedId)
|
handleTransferHost(passwordInputValue, newHostUsername, selectedId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
handleClose();
|
handleClose();
|
||||||
|
@ -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 = ({
|
||||||
<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>
|
||||||
|
|
Loading…
Reference in a new issue