Skip to content

Commit

Permalink
Merge pull request #45089 from JKobrynski/replaceSubscriptionsMenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
blimpich authored Jul 11, 2024
2 parents 075e9fc + 2505320 commit c53bd5c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export default {
saveTheWorld: 'Save the world',
},
allSettingsScreen: {
subscriptions: 'Subscriptions',
subscription: 'Subscription',
cardsAndDomains: 'Cards & Domains',
},
tabSelector: {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ export default {
saveTheWorld: 'Salvar el mundo',
},
allSettingsScreen: {
subscriptions: 'Suscripciones',
subscription: 'Suscripcion',
cardsAndDomains: 'Tarjetas y Dominios',
},
tabSelector: {
Expand Down
8 changes: 0 additions & 8 deletions src/libs/shouldShowSubscriptionsMenu/index.native.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/libs/shouldShowSubscriptionsMenu/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/libs/shouldShowSubscriptionsMenu/types.tsx

This file was deleted.

11 changes: 6 additions & 5 deletions src/pages/home/sidebar/AllSettingsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useMemo} from 'react';
import type {OnyxCollection} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx, withOnyx} from 'react-native-onyx';
import Breadcrumbs from '@components/Breadcrumbs';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItemList from '@components/MenuItemList';
Expand All @@ -11,7 +11,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Navigation from '@libs/Navigation/Navigation';
import shouldShowSubscriptionsMenu from '@libs/shouldShowSubscriptionsMenu';
import {hasGlobalWorkspaceSettingsRBR} from '@libs/WorkspacesSettingsUtils';
import * as Link from '@userActions/Link';
import CONST from '@src/CONST';
Expand All @@ -32,6 +31,8 @@ function AllSettingsScreen({policies}: AllSettingsScreenProps) {
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();

const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);

/**
* Retuns a list of menu items data for All workspaces settings
* @returns {Object} object with translationKey, style and items
Expand All @@ -49,10 +50,10 @@ function AllSettingsScreen({policies}: AllSettingsScreenProps) {
focused: !isSmallScreenWidth,
brickRoadIndicator: hasGlobalWorkspaceSettingsRBR(policies) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
},
...(shouldShowSubscriptionsMenu
...(privateSubscription
? [
{
translationKey: 'allSettingsScreen.subscriptions',
translationKey: 'allSettingsScreen.subscription',
icon: Expensicons.MoneyBag,
action: () => {
Link.openOldDotLink(CONST.OLDDOT_URLS.ADMIN_POLICIES_URL);
Expand Down Expand Up @@ -89,7 +90,7 @@ function AllSettingsScreen({policies}: AllSettingsScreenProps) {
hoverAndPressStyle: styles.hoveredComponentBG,
brickRoadIndicator: item.brickRoadIndicator,
}));
}, [isSmallScreenWidth, styles.hoveredComponentBG, styles.sectionMenuItem, translate, waitForNavigate, policies]);
}, [isSmallScreenWidth, policies, privateSubscription, waitForNavigate, translate, styles]);

return (
<ScreenWrapper
Expand Down
21 changes: 9 additions & 12 deletions src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, use
import type {GestureResponderEvent, ScrollView as RNScrollView, ScrollViewProps, StyleProp, ViewStyle} from 'react-native';
import {NativeModules, View} from 'react-native';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx, withOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import AvatarWithImagePicker from '@components/AvatarWithImagePicker';
import ConfirmModal from '@components/ConfirmModal';
Expand All @@ -29,7 +29,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import shouldShowSubscriptionsMenu from '@libs/shouldShowSubscriptionsMenu';
import * as SubscriptionUtils from '@libs/SubscriptionUtils';
import * as UserUtils from '@libs/UserUtils';
import {hasGlobalWorkspaceSettingsRBR} from '@libs/WorkspacesSettingsUtils';
Expand Down Expand Up @@ -108,6 +107,8 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa
const activeRoute = useActiveRoute();
const emojiCode = currentUserPersonalDetails?.status?.emojiCode ?? '';

const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);

const [shouldShowSignoutConfirmModal, setShouldShowSignoutConfirmModal] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -202,16 +203,12 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa
},
];

if (shouldShowSubscriptionsMenu) {
if (privateSubscription) {
items.splice(1, 0, {
translationKey: 'allSettingsScreen.subscriptions',
icon: Expensicons.MoneyBag,
action: () => {
Link.openOldDotLink(CONST.OLDDOT_URLS.ADMIN_POLICIES_URL);
},
shouldShowRightIcon: true,
iconRight: Expensicons.NewWindow,
link: () => Link.buildOldDotURL(CONST.OLDDOT_URLS.ADMIN_POLICIES_URL),
translationKey: 'allSettingsScreen.subscription',
icon: Expensicons.CreditCard,
routeName: ROUTES.SETTINGS_SUBSCRIPTION,
brickRoadIndicator: !!privateSubscription?.errors || SubscriptionUtils.hasSubscriptionRedDotError() ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
badgeText: SubscriptionUtils.isUserOnFreeTrial() ? translate('subscription.badge.freeTrial', {numOfDays: SubscriptionUtils.calculateRemainingFreeTrialDays()}) : undefined,
badgeStyle: SubscriptionUtils.isUserOnFreeTrial() ? styles.badgeSuccess : undefined,
});
Expand All @@ -222,7 +219,7 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa
sectionTranslationKey: 'common.workspaces',
items,
};
}, [policies, styles.badgeSuccess, styles.workspaceSettingsSectionContainer, translate]);
}, [policies, privateSubscription, styles.badgeSuccess, styles.workspaceSettingsSectionContainer, translate]);

/**
* Retuns a list of menu items data for general section
Expand Down
5 changes: 5 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,11 @@ const styles = (theme: ThemeColors) =>
flex: 1,
},

lhnSuccessText: {
color: theme.success,
fontWeight: FontUtils.fontWeight.bold,
},

signInPageHeroCenter: {
position: 'absolute',
top: 0,
Expand Down

0 comments on commit c53bd5c

Please sign in to comment.