mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-30 23:34:36 +00:00
Show loader on form submissions
This commit is contained in:
1 parent
a409fc7cd9
commit
344671b2f2
4 files changed
+34
No files matched your search
@@ -210,7 +210,9 @@ const SipTrunkForm = props => {
|
||||
};
|
||||
|
||||
const handleSumit = async e => {
|
||||
let isMounted = true;
|
||||
try {
|
||||
setShowLoader(true);
|
||||
e.preventDefault();
|
||||
setErrorMessage('');
|
||||
resetInvalidFields();
|
||||
@@ -492,8 +494,10 @@ const SipTrunkForm = props => {
|
||||
}
|
||||
|
||||
if (props.type === 'setup') {
|
||||
isMounted = false;
|
||||
history.push('/setup-complete');
|
||||
} else {
|
||||
isMounted = false;
|
||||
history.push('/internal/sip-trunks');
|
||||
const dispatchMessage = props.type === 'add'
|
||||
? 'SIP trunk created successfully'
|
||||
@@ -509,6 +513,7 @@ const SipTrunkForm = props => {
|
||||
if (err.response && err.response.status === 401) {
|
||||
localStorage.removeItem('token');
|
||||
sessionStorage.clear();
|
||||
isMounted = false;
|
||||
history.push('/');
|
||||
dispatch({
|
||||
type: 'ADD',
|
||||
@@ -519,6 +524,10 @@ const SipTrunkForm = props => {
|
||||
setErrorMessage((err.response && err.response.data && err.response.data.msg) || 'Something went wrong, please try again.');
|
||||
console.log(err.response || err);
|
||||
}
|
||||
} finally {
|
||||
if (isMounted) {
|
||||
setShowLoader(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user