From dbddb1ece428191de8cfc553d947897860259550 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Fri, 25 Jun 2021 12:00:49 +0530 Subject: [PATCH] feat: Add CSAT response submit action (#2506) Co-authored-by: Pranav Raj S --- .../api/v1/widget/messages_controller.rb | 2 +- .../components/CustomerSatisfaction.vue | 100 ++++++++++++++---- app/javascript/shared/constants/messages.js | 10 +- .../widget/components/AgentMessage.vue | 2 +- .../widget/components/AgentMessageBubble.vue | 17 ++- app/javascript/widget/i18n/locale/en.json | 1 + 6 files changed, 103 insertions(+), 29 deletions(-) diff --git a/app/controllers/api/v1/widget/messages_controller.rb b/app/controllers/api/v1/widget/messages_controller.rb index 991b2f428..c5492eff9 100644 --- a/app/controllers/api/v1/widget/messages_controller.rb +++ b/app/controllers/api/v1/widget/messages_controller.rb @@ -54,7 +54,7 @@ class Api::V1::Widget::MessagesController < Api::V1::Widget::BaseController end def message_update_params - params.permit(message: [{ submitted_values: [:name, :title, :value] }]) + params.permit(message: [{ submitted_values: [:name, :title, :value, { csat_survey_response: [:feedback_text, :rating] }] }]) end def permitted_params diff --git a/app/javascript/shared/components/CustomerSatisfaction.vue b/app/javascript/shared/components/CustomerSatisfaction.vue index 3a346be18..4a49e8c89 100644 --- a/app/javascript/shared/components/CustomerSatisfaction.vue +++ b/app/javascript/shared/components/CustomerSatisfaction.vue @@ -1,21 +1,20 @@ @@ -121,6 +125,17 @@ export default { messageId: this.messageId, }); }, + onCSATSubmit({ feedback, rating }) { + this.onResponse({ + submittedValues: { + csat_survey_response: { + rating, + feedback_text: feedback, + }, + }, + messageId: this.messageId, + }); + }, }, }; diff --git a/app/javascript/widget/i18n/locale/en.json b/app/javascript/widget/i18n/locale/en.json index 3cbcd6020..dd114afff 100644 --- a/app/javascript/widget/i18n/locale/en.json +++ b/app/javascript/widget/i18n/locale/en.json @@ -59,6 +59,7 @@ }, "CSAT": { "TITLE": "Rate your conversation", + "SUBMITTED_TITLE": "Thank you for submitting the rating", "PLACEHOLDER": "Tell us more..." } }