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/54842 #54920

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
12 changes: 2 additions & 10 deletions src/pages/workspace/upgrade/GenericFeaturesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import * as Illustrations from '@components/Icon/Illustrations';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import usePreferredCurrency from '@hooks/usePreferredCurrency';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {convertToShortDisplayString} from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
Expand All @@ -18,14 +16,14 @@ type GenericFeaturesViewProps = {
buttonDisabled?: boolean;
loading?: boolean;
onUpgrade: () => void;
formattedPrice: string;
policyID?: string;
};

function GenericFeaturesView({onUpgrade, buttonDisabled, loading, policyID}: GenericFeaturesViewProps) {
function GenericFeaturesView({onUpgrade, buttonDisabled, loading, formattedPrice, policyID}: GenericFeaturesViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isExtraSmallScreenWidth} = useResponsiveLayout();
const preferredCurrency = usePreferredCurrency();

const benefits = [
translate('workspace.upgrade.commonFeatures.benefits.benefit1'),
Expand All @@ -34,12 +32,6 @@ function GenericFeaturesView({onUpgrade, buttonDisabled, loading, policyID}: Gen
translate('workspace.upgrade.commonFeatures.benefits.benefit4'),
];

const formattedPrice = React.useMemo(() => {
const upgradeCurrency = Object.hasOwn(CONST.SUBSCRIPTION_PRICES, preferredCurrency) ? preferredCurrency : CONST.PAYMENT_CARD_CURRENCY.USD;
const upgradePrice = CONST.SUBSCRIPTION_PRICES[upgradeCurrency][CONST.POLICY.TYPE.CORPORATE][CONST.SUBSCRIPTION.TYPE.ANNUAL];
return `${convertToShortDisplayString(upgradePrice, upgradeCurrency)} `;
}, [preferredCurrency]);

return (
<View style={[styles.m5, styles.workspaceUpgradeIntroBox({isExtraSmallScreenWidth})]}>
<View style={[styles.mb3]}>
Expand Down
8 changes: 5 additions & 3 deletions src/pages/workspace/upgrade/UpgradeIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ function UpgradeIntro({feature, onUpgrade, buttonDisabled, loading, isCategorizi
const preferredCurrency = usePreferredCurrency();

const formattedPrice = React.useMemo(() => {
const upgradePlan = isCategorizing ? CONST.POLICY.TYPE.TEAM : CONST.POLICY.TYPE.CORPORATE;
const upgradeCurrency = Object.hasOwn(CONST.SUBSCRIPTION_PRICES, preferredCurrency) ? preferredCurrency : CONST.PAYMENT_CARD_CURRENCY.USD;
const upgradePrice = CONST.SUBSCRIPTION_PRICES[upgradeCurrency][upgradePlan][CONST.SUBSCRIPTION.TYPE.ANNUAL];
return `${convertToShortDisplayString(upgradePrice, upgradeCurrency)} `;
return `${convertToShortDisplayString(
CONST.SUBSCRIPTION_PRICES[upgradeCurrency][isCategorizing ? CONST.POLICY.TYPE.TEAM : CONST.POLICY.TYPE.CORPORATE][CONST.SUBSCRIPTION.TYPE.ANNUAL],
upgradeCurrency,
)} `;
}, [preferredCurrency, isCategorizing]);

/**
Expand All @@ -58,6 +59,7 @@ function UpgradeIntro({feature, onUpgrade, buttonDisabled, loading, isCategorizi
<GenericFeaturesView
onUpgrade={onUpgrade}
buttonDisabled={buttonDisabled}
formattedPrice={formattedPrice}
loading={loading}
policyID={policyID}
/>
Expand Down
Loading