Skip to content

Commit

Permalink
Help Center: update rating logic for improved clarity (#96930)
Browse files Browse the repository at this point in the history
* Refactor WasThisHelpfulButtons: update rating logic for improved clarity

* Add connection check for Zendesk to conditionally render feedback buttons
  • Loading branch information
agrullon95 authored Dec 4, 2024
1 parent a2d9fe0 commit f20efe7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/odie-client/src/components/message/user-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -64,7 +65,9 @@ export const UserMessage = ( {

const renderDisclaimers = () => (
<>
<WasThisHelpfulButtons message={ message } isDisliked={ isDisliked } />
{ ! isConnectedToZendesk && (
<WasThisHelpfulButtons message={ message } isDisliked={ isDisliked } />
) }

{ ! showExtraContactOptions && <DirectEscalationLink messageId={ message.message_id } /> }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( {
Expand Down

0 comments on commit f20efe7

Please sign in to comment.