diff --git a/app/javascript/shared/components/CustomerSatisfaction.vue b/app/javascript/shared/components/CustomerSatisfaction.vue index ead32834d..3bf242dcc 100644 --- a/app/javascript/shared/components/CustomerSatisfaction.vue +++ b/app/javascript/shared/components/CustomerSatisfaction.vue @@ -29,8 +29,8 @@ :disabled="isButtonDisabled" :style="{ background: widgetColor, borderColor: widgetColor }" > - - + + @@ -50,6 +50,10 @@ export default { type: Object, default: () => {}, }, + messageId: { + type: Number, + required: true, + }, }, data() { return { @@ -84,10 +88,10 @@ export default { mounted() { if (this.isRatingSubmitted) { const { - csat_survey_response: { rating, feedback }, + csat_survey_response: { rating, feedback_message }, } = this.messageContentAttributes; this.selectedRating = rating; - this.feedback = feedback; + this.feedback = feedback_message; } }, @@ -100,11 +104,23 @@ export default { 'emoji-button', ]; }, - onSubmit() { - this.$emit('submit', { - rating: this.selectedRating, - feedback: this.feedback, - }); + async onSubmit() { + this.isUpdating = true; + try { + await this.$store.dispatch('message/update', { + submittedValues: { + csat_survey_response: { + rating: this.selectedRating, + feedback_message: this.feedback, + }, + }, + messageId: this.messageId, + }); + } catch (error) { + // Ignore error + } finally { + this.isUpdating = false; + } }, selectRating(rating) { this.selectedRating = rating.value; diff --git a/app/javascript/widget/components/AgentMessageBubble.vue b/app/javascript/widget/components/AgentMessageBubble.vue index bdb7ba981..2aec14e05 100755 --- a/app/javascript/widget/components/AgentMessageBubble.vue +++ b/app/javascript/widget/components/AgentMessageBubble.vue @@ -47,7 +47,7 @@ @@ -125,17 +125,6 @@ export default { messageId: this.messageId, }); }, - onCSATSubmit({ feedback, rating }) { - this.onResponse({ - submittedValues: { - csat_survey_response: { - rating, - feedback_message: feedback, - }, - }, - messageId: this.messageId, - }); - }, }, }; diff --git a/app/javascript/widget/components/template/EmailInput.vue b/app/javascript/widget/components/template/EmailInput.vue index 3afcebb64..cf37839f0 100644 --- a/app/javascript/widget/components/template/EmailInput.vue +++ b/app/javascript/widget/components/template/EmailInput.vue @@ -18,7 +18,7 @@ :disabled="$v.email.$invalid" :style="{ background: widgetColor, borderColor: widgetColor }" > - + @@ -47,11 +47,11 @@ export default { data() { return { email: '', + isUpdating: false, }; }, computed: { ...mapGetters({ - uiFlags: 'message/getUIFlags', widgetColor: 'appConfig/getWidgetColor', }), hasSubmitted() { @@ -68,15 +68,21 @@ export default { }, }, methods: { - onSubmit() { + async onSubmit() { if (this.$v.$invalid) { return; } - - this.$store.dispatch('message/update', { - email: this.email, - messageId: this.messageId, - }); + this.isUpdating = true; + try { + await this.$store.dispatch('message/update', { + email: this.email, + messageId: this.messageId, + }); + } catch (error) { + // Ignore error + } finally { + this.isUpdating = false; + } }, }, };