mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-30 23:34:36 +00:00
Redirect away from forms when dependencies not met
This commit is contained in:
1 parent
7ab0aa7c2a
commit
838611607a
2 files changed
+34
No files matched your search
@@ -115,6 +115,16 @@ const ApplicationForm = props => {
|
||||
setAccounts(accounts);
|
||||
setApplications(applications);
|
||||
|
||||
if (accounts.length === 0) {
|
||||
history.push('/internal/accounts');
|
||||
dispatch({
|
||||
type: 'ADD',
|
||||
level: 'error',
|
||||
message: 'You must create an account before you can create an application.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(props.type === 'setup' && accounts.length > 1) ||
|
||||
(props.type === 'setup' && applications.length > 1)
|
||||
|
||||
@@ -108,6 +108,30 @@ const PhoneNumberForm = props => {
|
||||
setApplicationValues(applications);
|
||||
setPhoneNumbers(phoneNumbers);
|
||||
|
||||
if (!accounts.length) {
|
||||
dispatch({
|
||||
type: 'ADD',
|
||||
level: 'error',
|
||||
message: 'You must create an account before you can create a phone number.',
|
||||
});
|
||||
}
|
||||
|
||||
if (!sipTrunks.length) {
|
||||
dispatch({
|
||||
type: 'ADD',
|
||||
level: 'error',
|
||||
message: 'You must create a SIP trunk before you can create a phone number.',
|
||||
});
|
||||
}
|
||||
|
||||
if (!accounts.length) {
|
||||
history.push('/internal/accounts');
|
||||
return;
|
||||
} else if (!sipTrunks.length) {
|
||||
history.push('/internal/sip-trunks');
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.type === 'edit') {
|
||||
const phoneNumberData = promiseAllValues[3] && promiseAllValues[3].data.filter(p => {
|
||||
return p.phone_number_sid === props.phone_number_sid;
|
||||
|
||||
Reference in new issue
Block a user