Skip to content

Commit

Permalink
Help Center: Feedback in article sends paying users to support (#96782)
Browse files Browse the repository at this point in the history
  • Loading branch information
escapemanuele authored Nov 26, 2024
1 parent 836541b commit 1a2b90b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { v4 as uuidv4 } from 'uuid';
import { useHelpCenterContext } from '../contexts/HelpCenterContext';
import { useSupportStatus } from '../data/use-support-status';
import { useResetSupportInteraction } from '../hooks/use-reset-support-interaction';
import { ThumbsDownIcon, ThumbsUpIcon } from '../icons/thumbs';
import HelpCenterContactSupportOption from './help-center-contact-support-option';
Expand All @@ -33,6 +34,9 @@ const HelpCenterFeedbackForm = ( {
const [ startedFeedback, setStartedFeedback ] = useState< boolean | null >( null );
const [ answerValue, setAnswerValue ] = useState< number | null >( null );

const { data } = useSupportStatus();
const isUserEligibleForPaidSupport = data?.eligibility.is_user_eligible ?? false;

const { sectionName, site } = useHelpCenterContext();
const shouldUseHelpCenterExperience = config.isEnabled( 'help-center-experience' );
const navigate = useNavigate();
Expand Down Expand Up @@ -132,7 +136,10 @@ const HelpCenterFeedbackForm = ( {
) }
</p>
</div>
<GetSupport onClickAdditionalEvent={ handleContactSupportClick } />
<GetSupport
onClickAdditionalEvent={ handleContactSupportClick }
isUserEligibleForPaidSupport={ isUserEligibleForPaidSupport }
/>
</>
) : (
<HelpCenterContactSupportOption
Expand Down
14 changes: 8 additions & 6 deletions packages/odie-client/src/components/message/get-support.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import './get-support.scss';

interface GetSupportProps {
onClickAdditionalEvent?: () => void;
isUserEligibleForPaidSupport?: boolean;
}

interface ButtonConfig {
text: string;
action: () => Promise< void >;
}

export const GetSupport: React.FC< GetSupportProps > = ( { onClickAdditionalEvent } ) => {
export const GetSupport: React.FC< GetSupportProps > = ( {
onClickAdditionalEvent,
isUserEligibleForPaidSupport,
} ) => {
const navigate = useNavigate();
const newConversation = useCreateZendeskConversation();
const { shouldUseHelpCenterExperience, chat, isUserEligibleForPaidSupport } =
const { chat, isUserEligibleForPaidSupport: contextIsUserEligibleForPaidSupport } =
useOdieAssistantContext();

// Early return if user is already talking to a human
Expand All @@ -25,11 +29,9 @@ export const GetSupport: React.FC< GetSupportProps > = ( { onClickAdditionalEven
}

const getButtonConfig = (): ButtonConfig => {
if ( isUserEligibleForPaidSupport ) {
if ( isUserEligibleForPaidSupport || contextIsUserEligibleForPaidSupport ) {
return {
text: shouldUseHelpCenterExperience
? __( 'Get instant support', __i18n_text_domain__ )
: __( 'Get support', __i18n_text_domain__ ),
text: __( 'Get instant support', __i18n_text_domain__ ),
action: async () => {
onClickAdditionalEvent?.();
await newConversation();
Expand Down

0 comments on commit 1a2b90b

Please sign in to comment.