fix(cp-frontend): handle error validating name

This commit is contained in:
Sérgio Ramos 2017-08-03 13:42:39 +01:00
parent 2b552360e0
commit 0cf61c628a
1 changed files with 3 additions and 3 deletions

View File

@ -38,15 +38,15 @@ class DeploymentGroupEditOrCreate extends Component {
destroyOnUnmount: true, destroyOnUnmount: true,
forceUnregisterOnUnmount: true, forceUnregisterOnUnmount: true,
asyncValidate: async ({ name = '' }) => { asyncValidate: async ({ name = '' }) => {
const { data } = await client.query({ const [err] = await intercept(client.query({
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
query: DeploymentGroupBySlugQuery, query: DeploymentGroupBySlugQuery,
variables: { variables: {
slug: paramCase(name.trim()) slug: paramCase(name.trim())
} }
}); }));
if (data.deploymentGroups.length) { if (!err) {
// eslint-disable-next-line no-throw-literal // eslint-disable-next-line no-throw-literal
throw { name: `"${name}" already exists!` }; throw { name: `"${name}" already exists!` };
} }