From f20efe731ba68cbf3decabdfb52ee917c85ec1cb Mon Sep 17 00:00:00 2001 From: Anthony Grullon Date: Wed, 4 Dec 2024 11:51:35 -0500 Subject: [PATCH] Help Center: update rating logic for improved clarity (#96930) * Refactor WasThisHelpfulButtons: update rating logic for improved clarity * Add connection check for Zendesk to conditionally render feedback buttons --- .../odie-client/src/components/message/user-message.tsx | 5 ++++- .../src/components/message/was-this-helpful-buttons.tsx | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/odie-client/src/components/message/user-message.tsx b/packages/odie-client/src/components/message/user-message.tsx index fc6de161677872..dff6adc100760e 100644 --- a/packages/odie-client/src/components/message/user-message.tsx +++ b/packages/odie-client/src/components/message/user-message.tsx @@ -32,6 +32,7 @@ export const UserMessage = ( { const isRequestingHumanSupport = message.context?.flags?.forward_to_human_support; const hasFeedback = !! message?.rating_value; const isBot = message.role === 'bot'; + const isConnectedToZendesk = chat?.provider === 'zendesk'; const isPositiveFeedback = hasFeedback && message && message.rating_value && +message.rating_value === 1; const showExtraContactOptions = @@ -64,7 +65,9 @@ export const UserMessage = ( { const renderDisclaimers = () => ( <> - + { ! isConnectedToZendesk && ( + + ) } { ! showExtraContactOptions && } diff --git a/packages/odie-client/src/components/message/was-this-helpful-buttons.tsx b/packages/odie-client/src/components/message/was-this-helpful-buttons.tsx index 093d979b37fad2..d35ac86aa184c2 100644 --- a/packages/odie-client/src/components/message/was-this-helpful-buttons.tsx +++ b/packages/odie-client/src/components/message/was-this-helpful-buttons.tsx @@ -17,9 +17,11 @@ const WasThisHelpfulButtons = ( { useOdieAssistantContext(); const { mutateAsync: sendOdieMessageFeedback } = useSendOdieFeedback(); - const liked = message.liked === true; - const notLiked = message.liked === false; - const rated = message.liked !== null && message.liked !== undefined; + const liked = message.rating_value?.toString() === '1' || message.liked || false; + const notLiked = message.rating_value?.toString() === '0' || message.liked === false; + const rated = + ( message.rating_value !== null && message.rating_value !== undefined ) || + ( message.liked !== null && message.liked !== undefined ); const handleIsHelpful = ( isHelpful: boolean ) => { sendOdieMessageFeedback( {