fix(ui): show error from the api on failing to save integration
This commit is contained in:
parent
89afab8a22
commit
d0df66b539
1 changed files with 10 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import React from 'react';
|
|||
import { useStore } from 'App/mstore';
|
||||
import { namedStore } from 'App/mstore/integrationsStore';
|
||||
import { Button, Checkbox, Form, Input, Loader } from 'UI';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
function IntegrationForm(props: any) {
|
||||
const { formFields, name, integrated } = props;
|
||||
|
|
@ -31,6 +32,15 @@ function IntegrationForm(props: any) {
|
|||
onSave(customPath || name).then(() => {
|
||||
fetchList();
|
||||
props.onClose();
|
||||
}).catch(async (error) => {
|
||||
if (error.response) {
|
||||
const errorResponse = await error.response.json();
|
||||
if (errorResponse.errors && Array.isArray(errorResponse.errors)) {
|
||||
toast.error(errorResponse.errors.map((e: any) => e).join(', '));
|
||||
} else {
|
||||
toast.error('Failed to save integration');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue