Skip to content

Commit

Permalink
chore: Update CSAT submit action behaviour (#2556)
Browse files Browse the repository at this point in the history
* update behaviour of CSAT submit

* code cleanup
  • Loading branch information
muhsin-k committed Jul 2, 2021
1 parent f0f66c7 commit 8341a43
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions app/javascript/shared/components/CustomerSatisfaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</button>
</div>
<form
v-if="!isCSATSubmitted"
v-if="!isFeedbackSubmitted"
class="feedback-form"
@submit.prevent="onSubmit()"
>
Expand Down Expand Up @@ -64,37 +64,39 @@ 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;
}
},
methods: {
buttonClass(rating) {
return [
{ selected: rating.value === this.selectedRating },
{ disabled: this.isCSATSubmitted },
{ hover: this.isCSATSubmitted },
{ disabled: this.isRatingSubmitted },
{ hover: this.isRatingSubmitted },
'emoji-button',
];
},
Expand All @@ -106,6 +108,7 @@ export default {
},
selectRating(rating) {
this.selectedRating = rating.value;
this.onSubmit();
},
},
};
Expand Down

0 comments on commit 8341a43

Please sign in to comment.