Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Update Start a free trial on the Concierge DM header to be clickable #51576

4 changes: 2 additions & 2 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Performance from '@libs/Performance';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportUtils from '@libs/ReportUtils';
import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu';
import FreeTrialBadge from '@pages/settings/Subscription/FreeTrialBadge';
import FreeTrial from '@pages/settings/Subscription/FreeTrial';
import variables from '@styles/variables';
import * as User from '@userActions/User';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -277,7 +277,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
ReportUtils.isSystemChat(report)
}
/>
{ReportUtils.isChatUsedForOnboarding(report) && <FreeTrialBadge badgeStyles={[styles.mnh0, styles.pl2, styles.pr2, styles.ml1]} />}
{ReportUtils.isChatUsedForOnboarding(report) && <FreeTrial badgeStyles={[styles.mnh0, styles.pl2, styles.pr2, styles.ml1]} />}
{isStatusVisible && (
<Tooltip
text={statusContent}
Expand Down
8 changes: 6 additions & 2 deletions src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import isReportOpenInRHP from '@libs/Navigation/isReportOpenInRHP';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReportUtils from '@libs/ReportUtils';
import FreeTrialBadge from '@pages/settings/Subscription/FreeTrialBadge';
import FreeTrial from '@pages/settings/Subscription/FreeTrial';
import * as Report from '@userActions/Report';
import * as Session from '@userActions/Session';
import * as Task from '@userActions/Task';
Expand Down Expand Up @@ -120,6 +120,8 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
/>
);

const freeTrialButton = <FreeTrial pressable />;

const renderAdditionalText = () => {
if (shouldShowSubtitle() || isPersonalExpenseChat || !policyName || !isEmptyObject(parentNavigationSubtitleData) || isSelfDM) {
return null;
Expand All @@ -143,6 +145,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto

const isReportInRHP = isReportOpenInRHP(navigationRef?.getRootState());
const shouldDisplaySearchRouter = !isReportInRHP;
const isChatUsedForOnboarding = ReportUtils.isChatUsedForOnboarding(report);

return (
<View
Expand Down Expand Up @@ -280,7 +283,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
)}
</PressableWithoutFeedback>
<View style={[styles.reportOptions, styles.flexRow, styles.alignItemsCenter]}>
{ReportUtils.isChatUsedForOnboarding(report) && <FreeTrialBadge />}
{!shouldUseNarrowLayout && isChatUsedForOnboarding && freeTrialButton}
{isTaskReport && !shouldUseNarrowLayout && ReportUtils.isOpenTaskReport(report, parentReportAction) && <TaskHeaderActionButton report={report} />}
{canJoin && !shouldUseNarrowLayout && joinButton}
</View>
Expand All @@ -304,6 +307,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto
)}
</View>
{!isLoading && canJoin && shouldUseNarrowLayout && <View style={[styles.ph5, styles.pb2]}>{joinButton}</View>}
{!isLoading && isChatUsedForOnboarding && shouldUseNarrowLayout && <View style={[styles.pb3, styles.ph5]}>{freeTrialButton}</View>}
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import React, {useEffect, useState} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Badge from '@components/Badge';
import Button from '@components/Button';
import useNetwork from '@hooks/useNetwork';
import Navigation from '@libs/Navigation/Navigation';
import * as SubscriptionUtils from '@libs/SubscriptionUtils';
import * as Expensicons from '@src/components/Icon/Expensicons';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

type FreeTrialBadgeProps = {
type FreeTrialProps = {
badgeStyles?: StyleProp<ViewStyle>;
pressable?: boolean;
};

function FreeTrialBadge({badgeStyles}: FreeTrialBadgeProps) {
function FreeTrial({badgeStyles, pressable = false}: FreeTrialProps) {
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL);
const [lastDayFreeTrial] = useOnyx(ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL);
Expand All @@ -30,7 +35,14 @@ function FreeTrialBadge({badgeStyles}: FreeTrialBadgeProps) {
return null;
}

return (
return pressable ? (
<Button
icon={Expensicons.Star}
success
text={freeTrialText}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)}
/>
) : (
<Badge
success
text={freeTrialText}
Expand All @@ -39,6 +51,6 @@ function FreeTrialBadge({badgeStyles}: FreeTrialBadgeProps) {
);
}

FreeTrialBadge.displayName = 'FreeTrialBadge';
FreeTrial.displayName = 'FreeTrial';

export default FreeTrialBadge;
export default FreeTrial;
Loading