-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Home Page] [Release 2] Create TimeSensitiveSection Component #80951
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
Changes from all commits
4788d0d
2cf3edf
ad49459
32638c1
fdcfd69
f82b6f7
bf3f005
add941e
54d5c5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import WidgetContainer from '@components/WidgetContainer'; | ||
| import useHasTeam2025Pricing from '@hooks/useHasTeam2025Pricing'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useSubscriptionPlan from '@hooks/useSubscriptionPlan'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getEarlyDiscountInfo, shouldShowDiscountBanner} from '@libs/SubscriptionUtils'; | ||
| import variables from '@styles/variables'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import Offer25off from './items/Offer25off'; | ||
| import Offer50off from './items/Offer50off'; | ||
|
|
||
| function TimeSensitiveSection() { | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const {translate} = useLocalize(); | ||
| const icons = useMemoizedLazyExpensifyIcons(['Stopwatch'] as const); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL, {canBeMissing: true}); | ||
| const [lastDayFreeTrial] = useOnyx(ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL, {canBeMissing: true}); | ||
| const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID, {canBeMissing: true}); | ||
| const hasTeam2025Pricing = useHasTeam2025Pricing(); | ||
| const subscriptionPlan = useSubscriptionPlan(); | ||
|
|
||
| // Use the same logic as the subscription page to determine if discount banner should be shown | ||
| const shouldShowDiscount = shouldShowDiscountBanner(hasTeam2025Pricing, subscriptionPlan, firstDayFreeTrial, lastDayFreeTrial, userBillingFundID); | ||
| const discountInfo = getEarlyDiscountInfo(firstDayFreeTrial); | ||
|
|
||
| if (!shouldShowDiscount || !discountInfo) { | ||
| return null; | ||
|
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The desceription will be udpated |
||
| } | ||
|
|
||
| // Determine which offer to show based on discount type (they are mutually exclusive) | ||
| const shouldShow50off = discountInfo.discountType === 50; | ||
| const shouldShow25off = discountInfo.discountType === 25; | ||
|
Comment on lines
+32
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is edge case we do not have to worry about |
||
|
|
||
| return ( | ||
| <WidgetContainer | ||
| icon={icons.Stopwatch} | ||
| iconWidth={variables.iconSizeNormal} | ||
| iconHeight={variables.iconSizeNormal} | ||
| iconFill={theme.danger} | ||
| title={translate('homePage.timeSensitiveSection.title')} | ||
| titleColor={theme.danger} | ||
| > | ||
| <View style={styles.getForYouSectionContainerStyle(shouldUseNarrowLayout)}> | ||
| {shouldShow50off && <Offer50off firstDayFreeTrial={firstDayFreeTrial} />} | ||
| {shouldShow25off && <Offer25off days={discountInfo.days} />} | ||
| </View> | ||
| </WidgetContainer> | ||
| ); | ||
| } | ||
|
|
||
| export default TimeSensitiveSection; | ||
Uh oh!
There was an error while loading. Please reload this page.