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

[Free trial] Implement and show Trial Ended banner, Expensify DM GBR and custom Expensify DM chat item in the App after Free Trial ends #44483

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1c35f4d
feat: add trial ended banner and update related UI
pac-guerreiro Jun 26, 2024
d6e2f36
refactor: remove unnecessary text wrapper
pac-guerreiro Jun 26, 2024
8fc1eba
Merge branch 'pac-guerreiro/feature/43672-implement-and-show-free-tri…
pac-guerreiro Jun 27, 2024
ace1c18
Merge branch 'pac-guerreiro/feature/43672-implement-and-show-free-tri…
pac-guerreiro Jun 27, 2024
978af7e
Merge branch 'pac-guerreiro/feature/43672-implement-and-show-free-tri…
pac-guerreiro Jun 28, 2024
d3dc428
Merge branch 'pac-guerreiro/feature/43672-implement-and-show-free-tri…
pac-guerreiro Jul 1, 2024
a2f0e84
refactor: apply suggestions
pac-guerreiro Jul 2, 2024
21554b9
Merge branch 'pac-guerreiro/feature/43672-implement-and-show-free-tri…
pac-guerreiro Jul 2, 2024
5e8e967
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 3, 2024
222e524
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 4, 2024
a36a47c
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 4, 2024
bc13f9a
fix: free trial ended not showing as report last message in LHN
pac-guerreiro Jul 4, 2024
38a11b6
fix: GBR not showing in concierge chat option in LHN
pac-guerreiro Jul 4, 2024
174c48b
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 8, 2024
bc06a92
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 10, 2024
3e1992a
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 11, 2024
16dd7a2
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 11, 2024
79b3671
refactor: add isConciergeChat property to OptionData and check for it
pac-guerreiro Jul 11, 2024
cfb59ee
Merge branch 'main' into pac-guerreiro/feature/43671-trial-ended-bann…
pac-guerreiro Jul 11, 2024
531e0be
chore: fix linter issue
pac-guerreiro Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ const CONST = {
LIMIT: 50,
// OldDot Actions render getMessage from Web-Expensify/lib/Report/Action PHP files via getMessageOfOldDotReportAction in ReportActionsUtils.ts
TYPE: {
ACTIONABLE_ADD_PAYMENT_CARD: 'ACTIONABLEADDPAYMENTCARD',
ACTIONABLE_JOIN_REQUEST: 'ACTIONABLEJOINREQUEST',
ACTIONABLE_MENTION_WHISPER: 'ACTIONABLEMENTIONWHISPER',
ACTIONABLE_REPORT_MENTION_WHISPER: 'ACTIONABLEREPORTMENTIONWHISPER',
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import SubscriptionPPU from '@assets/images/simple-illustrations/simple-illustra
import Tag from '@assets/images/simple-illustrations/simple-illustration__tag.svg';
import TeachersUnite from '@assets/images/simple-illustrations/simple-illustration__teachers-unite.svg';
import ThumbsUpStars from '@assets/images/simple-illustrations/simple-illustration__thumbsupstars.svg';
import Tire from '@assets/images/simple-illustrations/simple-illustration__tire.svg';
import TrackShoe from '@assets/images/simple-illustrations/simple-illustration__track-shoe.svg';
import TrashCan from '@assets/images/simple-illustrations/simple-illustration__trashcan.svg';
import TreasureChest from '@assets/images/simple-illustrations/simple-illustration__treasurechest.svg';
Expand Down Expand Up @@ -194,4 +195,5 @@ export {
CheckmarkCircle,
CreditCardEyes,
LockClosedOrange,
Tire,
};
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3306,6 +3306,10 @@ export default {
title: ({numOfDays}) => `Free trial: ${numOfDays} ${numOfDays === 1 ? 'day' : 'days'} left!`,
subtitle: 'Add a payment card below to continue using all of your favorite features.',
},
trialEnded: {
title: 'Your free trial has ended',
subtitle: 'Add a payment card below to continue using all of your favorite features.',
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
},
},
cardSection: {
title: 'Payment',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3806,6 +3806,10 @@ export default {
title: ({numOfDays}) => `Prueba gratuita: ¡${numOfDays === 1 ? `queda 1 día` : `quedan ${numOfDays} días`}!`,
subtitle: 'Añade una tarjeta de pago para seguir utilizando tus funciones favoritas.',
},
trialEnded: {
title: 'Tu prueba gratuita ha terminado',
subtitle: 'Añade una tarjeta de pago para seguir utilizando tus funciones favoritas.',
},
},
cardSection: {
title: 'Pago',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,10 @@ function getIOUActionForReportID(reportID: string, transactionID: string): OnyxE
return action;
}

function isActionableAddPaymentCard(reportAction: OnyxEntry<ReportAction>): reportAction is ReportAction & OriginalMessage<'ACTIONABLEADDPAYMENTCARD'> {
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_ADD_PAYMENT_CARD;
}

export {
extractLinksFromMessageHtml,
getDismissedViolationMessageText,
Expand Down Expand Up @@ -1462,6 +1466,7 @@ export {
getTextFromHtml,
isTripPreview,
getIOUActionForReportID,
isActionableAddPaymentCard,
};

export type {LastVisibleMessage};
5 changes: 5 additions & 0 deletions src/libs/shouldRenderAppPaymentCard/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type ShouldRenderAddPaymentCard = () => boolean;
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved

const shouldRenderAddPaymentCard: ShouldRenderAddPaymentCard = () => false;

export default shouldRenderAddPaymentCard;
5 changes: 5 additions & 0 deletions src/libs/shouldRenderAppPaymentCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type ShouldRenderAddPaymentCard = () => boolean;

const shouldRenderAddPaymentCard: ShouldRenderAddPaymentCard = () => true;

export default shouldRenderAddPaymentCard;
15 changes: 15 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import SelectionScraper from '@libs/SelectionScraper';
import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard';
import {ReactionListContext} from '@pages/home/ReportScreenContext';
import * as BankAccounts from '@userActions/BankAccounts';
import * as EmojiPickerAction from '@userActions/EmojiPickerAction';
Expand Down Expand Up @@ -399,6 +400,20 @@ function ReportActionItem({
return [];
}

if (ReportActionsUtils.isActionableAddPaymentCard(action) && shouldRenderAddPaymentCard()) {
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
return [
{
text: 'subscription.cardSection.addCardButton',
key: `${action.reportActionID}-actionableAddPaymentCard-submit`,
onPress: () => {
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION);
},
isMediumSized: true,
isPrimary: true,
},
];
}

if (ReportActionsUtils.isActionableTrackExpense(action)) {
const transactionID = ReportActionsUtils.getOriginalMessage(action)?.transactionID;
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import * as Illustrations from '@components/Icon/Illustrations';
import useLocalize from '@hooks/useLocalize';
import BillingBanner from './BillingBanner';

function TrialEndedBillingBanner() {
const {translate} = useLocalize();

return (
<BillingBanner
title={translate('subscription.billingBanner.trialEnded.title')}
subtitle={translate('subscription.billingBanner.trialEnded.subtitle')}
icon={Illustrations.Tire}
/>
);
}

TrialEndedBillingBanner.displayName = 'TrialEndedBillingBanner';

export default TrialEndedBillingBanner;
12 changes: 11 additions & 1 deletion src/pages/settings/Subscription/CardSection/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import PreTrialBillingBanner from './BillingBanner/PreTrialBillingBanner';
import TrialEndedBillingBanner from './BillingBanner/TrialEndedBillingBanner';
import TrialStartedBillingBanner from './BillingBanner/TrialStartedBillingBanner';
import CardSectionActions from './CardSectionActions';
import CardSectionDataEmpty from './CardSectionDataEmpty';
Expand All @@ -37,7 +38,16 @@ function CardSection() {
const nextPaymentDate = !isEmptyObject(privateSubscription) ? CardSectionUtils.getNextBillingDate() : undefined;

const sectionSubtitle = defaultCard && !!nextPaymentDate ? translate('subscription.cardSection.cardNextPayment', {nextPaymentDate}) : translate('subscription.cardSection.subtitle');
const BillingBanner = SubscriptionUtils.isUserOnFreeTrial() ? <TrialStartedBillingBanner /> : <PreTrialBillingBanner />;

let BillingBanner = <PreTrialBillingBanner />;

if (SubscriptionUtils.isUserOnFreeTrial()) {
BillingBanner = <TrialStartedBillingBanner />;
}

if (SubscriptionUtils.hasUserFreeTrialEnded()) {
BillingBanner = <TrialEndedBillingBanner />;
}

return (
<Section
Expand Down
7 changes: 7 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,15 @@ type OriginalMessageApproved = {
expenseReportID: string;
};

/**
* Model of `Add payment card` report action
*/
type OriginalMessageAddPaymentCard = Record<string, never>;

/** The map type of original message */
type OriginalMessageMap = {
/** */
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_ADD_PAYMENT_CARD]: OriginalMessageAddPaymentCard;
/** */
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST]: OriginalMessageJoinPolicyChangeLog;
/** */
Expand Down
Loading