From 8341a43143a564b01297ca41e9eb8fa4ce3aded6 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Fri, 2 Jul 2021 14:52:20 +0530 Subject: [PATCH] chore: Update CSAT submit action behaviour (#2556) * update behaviour of CSAT submit * code cleanup --- .../components/CustomerSatisfaction.vue | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/javascript/shared/components/CustomerSatisfaction.vue b/app/javascript/shared/components/CustomerSatisfaction.vue index 4a49e8c89..ead32834d 100644 --- a/app/javascript/shared/components/CustomerSatisfaction.vue +++ b/app/javascript/shared/components/CustomerSatisfaction.vue @@ -14,7 +14,7 @@
@@ -64,28 +64,30 @@ export default { ...mapGetters({ widgetColor: 'appConfig/getWidgetColor', }), - isCSATSubmitted() { - return ( - this.messageContentAttributes && - this.messageContentAttributes.csat_survey_response - ); + isRatingSubmitted() { + return this.messageContentAttributes?.csat_survey_response?.rating; + }, + isFeedbackSubmitted() { + return this.messageContentAttributes?.csat_survey_response + ?.feedback_message; }, isButtonDisabled() { return !(this.selectedRating && this.feedback); }, title() { - return this.isCSATSubmitted + return this.isRatingSubmitted ? this.$t('CSAT.SUBMITTED_TITLE') : this.$t('CSAT.TITLE'); }, }, mounted() { - if (this.isCSATSubmitted) { + if (this.isRatingSubmitted) { const { - csat_survey_response: { rating }, + csat_survey_response: { rating, feedback }, } = this.messageContentAttributes; this.selectedRating = rating; + this.feedback = feedback; } }, @@ -93,8 +95,8 @@ export default { buttonClass(rating) { return [ { selected: rating.value === this.selectedRating }, - { disabled: this.isCSATSubmitted }, - { hover: this.isCSATSubmitted }, + { disabled: this.isRatingSubmitted }, + { hover: this.isRatingSubmitted }, 'emoji-button', ]; }, @@ -106,6 +108,7 @@ export default { }, selectRating(rating) { this.selectedRating = rating.value; + this.onSubmit(); }, }, };