fix: Could not able to create label (#4161)
* fixes: Could not able to create label * review fixes Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
parent
4a2452173e
commit
b3ba8b9513
2 changed files with 12 additions and 11 deletions
|
@ -93,21 +93,21 @@ export default {
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
},
|
},
|
||||||
addLabel() {
|
async addLabel() {
|
||||||
this.$store
|
try {
|
||||||
.dispatch('labels/create', {
|
await this.$store.dispatch('labels/create', {
|
||||||
color: this.color,
|
color: this.color,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
show_on_sidebar: this.showOnSidebar,
|
show_on_sidebar: this.showOnSidebar,
|
||||||
})
|
});
|
||||||
.then(() => {
|
|
||||||
this.showAlert(this.$t('LABEL_MGMT.ADD.API.SUCCESS_MESSAGE'));
|
this.showAlert(this.$t('LABEL_MGMT.ADD.API.SUCCESS_MESSAGE'));
|
||||||
this.onClose();
|
this.onClose();
|
||||||
})
|
} catch (error) {
|
||||||
.catch(() => {
|
const errorMessage =
|
||||||
this.showAlert(this.$t('LABEL_MGMT.ADD.API.ERROR_MESSAGE'));
|
error.message || this.$t('LABEL_MGMT.ADD.API.ERROR_MESSAGE');
|
||||||
});
|
this.showAlert(errorMessage);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,8 @@ export const actions = {
|
||||||
const response = await LabelsAPI.create(cannedObj);
|
const response = await LabelsAPI.create(cannedObj);
|
||||||
commit(types.ADD_LABEL, response.data);
|
commit(types.ADD_LABEL, response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error);
|
const errorMessage = error?.response?.data?.message;
|
||||||
|
throw new Error(errorMessage);
|
||||||
} finally {
|
} finally {
|
||||||
commit(types.SET_LABEL_UI_FLAG, { isCreating: false });
|
commit(types.SET_LABEL_UI_FLAG, { isCreating: false });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue