2021-06-22 07:31:19 +00:00
|
|
|
<template>
|
|
|
|
<div class="customer-satisfcation">
|
2021-06-25 06:30:49 +00:00
|
|
|
<h6 class="title">
|
|
|
|
{{ title }}
|
|
|
|
</h6>
|
2021-06-22 07:31:19 +00:00
|
|
|
<div class="ratings">
|
|
|
|
<button
|
|
|
|
v-for="rating in ratings"
|
|
|
|
:key="rating.key"
|
2021-06-25 06:30:49 +00:00
|
|
|
:class="buttonClass(rating)"
|
2021-06-22 07:31:19 +00:00
|
|
|
@click="selectRating(rating)"
|
|
|
|
>
|
|
|
|
{{ rating.emoji }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<form
|
2021-07-02 09:22:20 +00:00
|
|
|
v-if="!isFeedbackSubmitted"
|
2021-06-22 07:31:19 +00:00
|
|
|
class="feedback-form"
|
|
|
|
@submit.prevent="onSubmit()"
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
v-model="feedback"
|
|
|
|
class="form-input"
|
|
|
|
:placeholder="$t('CSAT.PLACEHOLDER')"
|
|
|
|
@keyup.enter="onSubmit"
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
class="button"
|
2021-06-25 06:30:49 +00:00
|
|
|
:disabled="isButtonDisabled"
|
2021-06-22 07:31:19 +00:00
|
|
|
:style="{ background: widgetColor, borderColor: widgetColor }"
|
|
|
|
>
|
|
|
|
<i v-if="!isUpdating" class="ion-ios-arrow-forward" />
|
|
|
|
<spinner v-else />
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import Spinner from 'shared/components/Spinner';
|
|
|
|
import { CSAT_RATINGS } from 'shared/constants/messages';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Spinner,
|
|
|
|
},
|
2021-06-25 06:30:49 +00:00
|
|
|
props: {
|
|
|
|
messageContentAttributes: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
2021-06-22 07:31:19 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
email: '',
|
|
|
|
ratings: CSAT_RATINGS,
|
|
|
|
selectedRating: null,
|
|
|
|
isUpdating: false,
|
|
|
|
feedback: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
widgetColor: 'appConfig/getWidgetColor',
|
|
|
|
}),
|
2021-07-02 09:22:20 +00:00
|
|
|
isRatingSubmitted() {
|
|
|
|
return this.messageContentAttributes?.csat_survey_response?.rating;
|
|
|
|
},
|
|
|
|
isFeedbackSubmitted() {
|
|
|
|
return this.messageContentAttributes?.csat_survey_response
|
|
|
|
?.feedback_message;
|
2021-06-25 06:30:49 +00:00
|
|
|
},
|
|
|
|
isButtonDisabled() {
|
|
|
|
return !(this.selectedRating && this.feedback);
|
|
|
|
},
|
|
|
|
title() {
|
2021-07-02 09:22:20 +00:00
|
|
|
return this.isRatingSubmitted
|
2021-06-25 06:30:49 +00:00
|
|
|
? this.$t('CSAT.SUBMITTED_TITLE')
|
|
|
|
: this.$t('CSAT.TITLE');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-07-02 09:22:20 +00:00
|
|
|
if (this.isRatingSubmitted) {
|
2021-06-25 06:30:49 +00:00
|
|
|
const {
|
2021-07-02 09:22:20 +00:00
|
|
|
csat_survey_response: { rating, feedback },
|
2021-06-25 06:30:49 +00:00
|
|
|
} = this.messageContentAttributes;
|
|
|
|
this.selectedRating = rating;
|
2021-07-02 09:22:20 +00:00
|
|
|
this.feedback = feedback;
|
2021-06-25 06:30:49 +00:00
|
|
|
}
|
2021-06-22 07:31:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2021-06-25 06:30:49 +00:00
|
|
|
buttonClass(rating) {
|
|
|
|
return [
|
|
|
|
{ selected: rating.value === this.selectedRating },
|
2021-07-02 09:22:20 +00:00
|
|
|
{ disabled: this.isRatingSubmitted },
|
|
|
|
{ hover: this.isRatingSubmitted },
|
2021-06-25 06:30:49 +00:00
|
|
|
'emoji-button',
|
|
|
|
];
|
|
|
|
},
|
|
|
|
onSubmit() {
|
|
|
|
this.$emit('submit', {
|
|
|
|
rating: this.selectedRating,
|
|
|
|
feedback: this.feedback,
|
|
|
|
});
|
|
|
|
},
|
2021-06-22 07:31:19 +00:00
|
|
|
selectRating(rating) {
|
2021-06-25 06:30:49 +00:00
|
|
|
this.selectedRating = rating.value;
|
2021-07-02 09:22:20 +00:00
|
|
|
this.onSubmit();
|
2021-06-22 07:31:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
@import '~widget/assets/scss/mixins.scss';
|
|
|
|
|
|
|
|
.customer-satisfcation {
|
|
|
|
@include light-shadow;
|
2021-06-25 06:30:49 +00:00
|
|
|
|
2021-06-22 07:31:19 +00:00
|
|
|
background: $color-white;
|
|
|
|
border-bottom-left-radius: $space-smaller;
|
2021-06-25 06:30:49 +00:00
|
|
|
border-radius: $space-small;
|
2021-06-22 07:31:19 +00:00
|
|
|
border-top: $space-micro solid $color-woot;
|
2021-06-25 06:30:49 +00:00
|
|
|
color: $color-body;
|
2021-06-22 07:31:19 +00:00
|
|
|
display: inline-block;
|
|
|
|
line-height: 1.5;
|
2021-06-25 06:30:49 +00:00
|
|
|
margin-top: $space-smaller;
|
|
|
|
width: 80%;
|
|
|
|
|
2021-06-22 07:31:19 +00:00
|
|
|
.title {
|
|
|
|
font-size: $font-size-default;
|
|
|
|
font-weight: $font-weight-medium;
|
2021-06-25 06:30:49 +00:00
|
|
|
padding: $space-two $space-one 0;
|
2021-06-22 07:31:19 +00:00
|
|
|
text-align: center;
|
|
|
|
}
|
2021-06-25 06:30:49 +00:00
|
|
|
|
2021-06-22 07:31:19 +00:00
|
|
|
.ratings {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-around;
|
|
|
|
padding: $space-two $space-normal;
|
|
|
|
|
|
|
|
.emoji-button {
|
|
|
|
box-shadow: none;
|
|
|
|
filter: grayscale(100%);
|
2021-06-25 06:30:49 +00:00
|
|
|
font-size: $font-size-big;
|
|
|
|
outline: none;
|
|
|
|
|
|
|
|
&.selected,
|
|
|
|
&:hover,
|
|
|
|
&:focus,
|
|
|
|
&:active {
|
2021-06-22 07:31:19 +00:00
|
|
|
filter: grayscale(0%);
|
|
|
|
transform: scale(1.32);
|
|
|
|
}
|
2021-06-25 06:30:49 +00:00
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
cursor: default;
|
|
|
|
opacity: 0.5;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2021-06-22 07:31:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.feedback-form {
|
|
|
|
display: flex;
|
2021-06-25 06:30:49 +00:00
|
|
|
|
2021-06-22 07:31:19 +00:00
|
|
|
input {
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-top-right-radius: 0;
|
2021-06-25 06:30:49 +00:00
|
|
|
border-bottom-left-radius: $space-small;
|
|
|
|
border: 0;
|
2021-06-22 07:31:19 +00:00
|
|
|
border-top: 1px solid $color-border;
|
2021-06-25 06:30:49 +00:00
|
|
|
padding: $space-one;
|
|
|
|
width: 100%;
|
2021-06-22 07:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.button {
|
2021-06-25 06:30:49 +00:00
|
|
|
appearance: none;
|
2021-06-22 07:31:19 +00:00
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
border-top-left-radius: 0;
|
2021-06-25 06:30:49 +00:00
|
|
|
border-bottom-right-radius: $space-small;
|
2021-06-22 07:31:19 +00:00
|
|
|
font-size: $font-size-large;
|
|
|
|
height: auto;
|
|
|
|
margin-left: -1px;
|
2021-06-25 06:30:49 +00:00
|
|
|
|
2021-06-22 07:31:19 +00:00
|
|
|
.spinner {
|
|
|
|
display: block;
|
|
|
|
padding: 0;
|
|
|
|
height: auto;
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|