Skip to content

Commit

Permalink
fix: Set the default value to false for the checkbox custom attribute (
Browse files Browse the repository at this point in the history
…#7561)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
  • Loading branch information
karthi07 and pranavrajs committed Aug 15, 2023
1 parent e3b8c1f commit 7b68a76
Showing 1 changed file with 10 additions and 4 deletions.
Expand Up @@ -58,25 +58,31 @@ export default {
methods: {
async addAttribute(attribute) {
try {
const { attribute_key } = attribute;
const {
attribute_key: attributeKey,
attribute_display_type: attributeDisplayType,
default_value: attributeDefaultValue,
} = attribute;
const isCheckbox = attributeDisplayType === 'checkbox';
const defaultValue = isCheckbox ? false : attributeDefaultValue || null;
if (this.attributeType === 'conversation_attribute') {
await this.$store.dispatch('updateCustomAttributes', {
conversationId: this.conversationId,
customAttributes: {
...this.customAttributes,
[attribute_key]: null,
[attributeKey]: defaultValue,
},
});
} else {
await this.$store.dispatch('contacts/update', {
id: this.contactId,
custom_attributes: {
...this.customAttributes,
[attribute_key]: null,
[attributeKey]: defaultValue,
},
});
}
bus.$emit(BUS_EVENTS.FOCUS_CUSTOM_ATTRIBUTE, attribute_key);
bus.$emit(BUS_EVENTS.FOCUS_CUSTOM_ATTRIBUTE, attributeKey);
this.showAlert(this.$t('CUSTOM_ATTRIBUTES.FORM.ADD.SUCCESS'));
} catch (error) {
const errorMessage =
Expand Down

0 comments on commit 7b68a76

Please sign in to comment.