-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56561 from ikevin127/ikevin127-expensifyCardPromo…
…tion Add Expensify Card promoting banner to Company cards page
- Loading branch information
Showing
8 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
assets/images/simple-illustrations/simple-illustration__creditcards--green.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
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
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
71 changes: 71 additions & 0 deletions
71
src/pages/workspace/companyCards/WorkspaceCompanyCardExpensifyCardPromotionBanner.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,71 @@ | ||
import React, {useCallback, useMemo} from 'react'; | ||
import {View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import Button from '@components/Button'; | ||
import {CreditCardsNewGreen} from '@components/Icon/Illustrations'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import {enableExpensifyCard} from '@libs/actions/Policy/Policy'; | ||
import {navigateToExpensifyCardPage} from '@libs/PolicyUtils'; | ||
import BillingBanner from '@pages/settings/Subscription/CardSection/BillingBanner/BillingBanner'; | ||
import type {Policy} from '@src/types/onyx'; | ||
|
||
type WorkspaceCompanyCardExpensifyCardPromotionBannerProps = { | ||
policy: OnyxEntry<Policy>; | ||
}; | ||
|
||
function WorkspaceCompanyCardExpensifyCardPromotionBanner({policy}: WorkspaceCompanyCardExpensifyCardPromotionBannerProps) { | ||
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const StyleUtils = useStyleUtils(); | ||
const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
const policyID = policy?.id; | ||
const areExpensifyCardsEnabled = policy?.areExpensifyCardsEnabled; | ||
|
||
const handleLearnMore = useCallback(() => { | ||
if (!policyID) { | ||
return; | ||
} | ||
|
||
if (areExpensifyCardsEnabled) { | ||
navigateToExpensifyCardPage(policyID); | ||
return; | ||
} | ||
|
||
enableExpensifyCard(policyID, true, true); | ||
}, [policyID, areExpensifyCardsEnabled]); | ||
|
||
const rightComponent = useMemo(() => { | ||
const smallScreenStyle = shouldUseNarrowLayout ? [styles.flex0, styles.flexBasis100, styles.justifyContentCenter] : []; | ||
return ( | ||
<View style={[styles.flexRow, styles.gap2, smallScreenStyle]}> | ||
<Button | ||
success | ||
onPress={handleLearnMore} | ||
style={shouldUseNarrowLayout && styles.flex1} | ||
text={translate('workspace.moreFeatures.companyCards.expensifyCardBannerLearnMoreButton')} | ||
/> | ||
</View> | ||
); | ||
}, [styles, shouldUseNarrowLayout, translate, handleLearnMore]); | ||
|
||
return ( | ||
<View style={[styles.ph4, styles.mb4]}> | ||
<BillingBanner | ||
icon={CreditCardsNewGreen} | ||
title={translate('workspace.moreFeatures.companyCards.expensifyCardBannerTitle')} | ||
titleStyle={StyleUtils.getTextColorStyle(theme.text)} | ||
subtitle={translate('workspace.moreFeatures.companyCards.expensifyCardBannerSubtitle')} | ||
subtitleStyle={[styles.mt1, styles.textLabel]} | ||
style={[styles.borderRadiusComponentLarge]} | ||
rightComponent={rightComponent} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
export default WorkspaceCompanyCardExpensifyCardPromotionBanner; |
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