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:
Sivin Varghese 2022-03-14 20:43:56 +05:30 committed by GitHub
parent 4a2452173e
commit b3ba8b9513
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View file

@ -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.onClose();
})
.catch(() => {
this.showAlert(this.$t('LABEL_MGMT.ADD.API.ERROR_MESSAGE'));
}); });
this.showAlert(this.$t('LABEL_MGMT.ADD.API.SUCCESS_MESSAGE'));
this.onClose();
} catch (error) {
const errorMessage =
error.message || this.$t('LABEL_MGMT.ADD.API.ERROR_MESSAGE');
this.showAlert(errorMessage);
}
}, },
}, },
}; };

View file

@ -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 });
} }