From 7b68a7639f270120801bcace7b3e1c56c97ac7c9 Mon Sep 17 00:00:00 2001 From: Karthick Venkatesan Date: Wed, 16 Aug 2023 05:02:06 +0530 Subject: [PATCH] fix: Set the default value to false for the checkbox custom attribute (#7561) Co-authored-by: Pranav Raj S --- .../customAttributes/CustomAttributeSelector.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributeSelector.vue b/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributeSelector.vue index a0b11cabd..60ef9d860 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributeSelector.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributeSelector.vue @@ -58,13 +58,19 @@ 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 { @@ -72,11 +78,11 @@ export default { 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 =