-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 Pre-Trial banner in the App during Pre-Trial #43982
Merged
chiragsalian
merged 8 commits into
Expensify:main
from
fabioh8010:feature/free-trials/pre-trial
Jun 20, 2024
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5541d19
Refactor BillingBanner to be more flexible and generic
fabioh8010 f69c96f
Implement PreTrialBillingBanner
fabioh8010 df45942
Remove export
fabioh8010 a92688b
Minor changes to BillingBanner
fabioh8010 a053fb3
Merge remote-tracking branch 'origin/main' into feature/free-trials/p…
fabioh8010 0abe98a
Merge branch 'main' into feature/free-trials/pre-trial
fabioh8010 e2edcce
Improve isChatUsedForOnboarding() comment
fabioh8010 90480b7
Address comments
fabioh8010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 59 additions & 1 deletion
60
assets/images/simple-illustrations/simple-illustration__treasurechest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
src/pages/settings/Subscription/CardSection/BillingBanner.tsx
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
src/pages/settings/Subscription/CardSection/BillingBanner/BillingBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import type {StyleProp, TextStyle, ViewStyle} from 'react-native'; | ||
import {View} from 'react-native'; | ||
import type {ValueOf} from 'type-fest'; | ||
import Icon from '@components/Icon'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import Text from '@components/Text'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import variables from '@styles/variables'; | ||
import CONST from '@src/CONST'; | ||
import type IconAsset from '@src/types/utils/IconAsset'; | ||
|
||
type BillingBannerProps = { | ||
/** The title of the banner. */ | ||
title: string | React.ReactNode; | ||
|
||
/** The subtitle of the banner. */ | ||
subtitle: string | React.ReactNode; | ||
|
||
/** The icon to display in the banner. */ | ||
icon: IconAsset; | ||
|
||
/** The type of brick road indicator to show. */ | ||
brickRoadIndicator?: ValueOf<typeof CONST.BRICK_ROAD_INDICATOR_STATUS>; | ||
|
||
/** Styles to apply to the container. */ | ||
style?: StyleProp<ViewStyle>; | ||
|
||
/** Styles to apply to the title. */ | ||
titleStyle?: StyleProp<TextStyle>; | ||
|
||
/** Styles to apply to the subtitle. */ | ||
subtitleStyle?: StyleProp<TextStyle>; | ||
}; | ||
|
||
function BillingBanner({title, subtitle, icon, brickRoadIndicator, style, titleStyle, subtitleStyle}: BillingBannerProps) { | ||
const styles = useThemeStyles(); | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<View style={[styles.pv4, styles.ph5, styles.flexRow, styles.gap3, styles.w100, styles.alignItemsCenter, styles.trialBannerBackgroundColor, style]}> | ||
<Icon | ||
src={icon} | ||
width={variables.menuIconSize} | ||
height={variables.menuIconSize} | ||
/> | ||
|
||
<View style={[styles.flex1, styles.justifyContentCenter]}> | ||
{typeof title === 'string' ? <Text style={[styles.textStrong, titleStyle]}>{title}</Text> : title} | ||
{typeof subtitle === 'string' ? <Text style={subtitleStyle}>{subtitle}</Text> : subtitle} | ||
</View> | ||
|
||
{!!brickRoadIndicator && ( | ||
<Icon | ||
src={Expensicons.DotIndicator} | ||
fill={brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR ? theme.danger : theme.success} | ||
/> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
||
BillingBanner.displayName = 'BillingBanner'; | ||
|
||
export default BillingBanner; |
49 changes: 49 additions & 0 deletions
49
src/pages/settings/Subscription/CardSection/BillingBanner/PreTrialBillingBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import * as Illustrations from '@components/Icon/Illustrations'; | ||
import Text from '@components/Text'; | ||
import TextLink from '@components/TextLink'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as Report from '@libs/actions/Report'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import ROUTES from '@src/ROUTES'; | ||
import BillingBanner from './BillingBanner'; | ||
|
||
function PreTrialBillingBanner() { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
|
||
const navigateToChat = () => { | ||
const reportUsedForOnboarding = ReportUtils.getChatUsedForOnboarding(); | ||
|
||
if (!reportUsedForOnboarding) { | ||
return; | ||
fabioh8010 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
Report.openReport(reportUsedForOnboarding.reportID); | ||
fabioh8010 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportUsedForOnboarding.reportID)); | ||
}; | ||
|
||
return ( | ||
<BillingBanner | ||
title={translate('subscription.billingBanner.preTrial.title')} | ||
subtitle={ | ||
<Text> | ||
{translate('subscription.billingBanner.preTrial.subtitle')} | ||
<TextLink | ||
style={styles.link} | ||
onPress={navigateToChat} | ||
> | ||
{translate('subscription.billingBanner.preTrial.subtitleLink')} | ||
</TextLink> | ||
</Text> | ||
} | ||
icon={Illustrations.TreasureChest} | ||
/> | ||
); | ||
} | ||
|
||
PreTrialBillingBanner.displayName = 'PreTrialBillingBanner'; | ||
|
||
export default PreTrialBillingBanner; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late comment, but just checking to see if we wanted to have a period at the end of this? cc @jamesdeanexpensify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, great catch! After
here
please!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. We will integrate this change during implementation of issue here
cc @fabioh8010