mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-29 14:54: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
@@ -216,7 +216,9 @@ const ApplicationForm = props => {
|
||||
|
||||
|
||||
const handleSumit = async (e) => {
|
||||
let isMounted = true;
|
||||
try {
|
||||
setShowLoader(true);
|
||||
e.preventDefault();
|
||||
setErrorMessage('');
|
||||
setInvalidName(false);
|
||||
@@ -350,8 +352,10 @@ const ApplicationForm = props => {
|
||||
});
|
||||
|
||||
if (props.type === 'setup') {
|
||||
isMounted = false;
|
||||
history.push('/configure-sip-trunk');
|
||||
} else {
|
||||
isMounted = false;
|
||||
history.push('/internal/applications');
|
||||
const dispatchMessage = props.type === 'add'
|
||||
? 'Application created successfully'
|
||||
@@ -367,6 +371,7 @@ const ApplicationForm = props => {
|
||||
if (err.response && err.response.status === 401) {
|
||||
localStorage.removeItem('token');
|
||||
sessionStorage.clear();
|
||||
isMounted = false;
|
||||
history.push('/');
|
||||
dispatch({
|
||||
type: 'ADD',
|
||||
@@ -377,6 +382,10 @@ const ApplicationForm = 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