Skip to content

Commit

Permalink
Merge pull request #44119 from mananjadhav/mj-subscription-payment-hi…
Browse files Browse the repository at this point in the history
…story
  • Loading branch information
blimpich authored Jun 26, 2024
2 parents e7e9304 + a182d24 commit 04f6598
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3300,6 +3300,7 @@ export default {
changeCurrency: 'Change payment currency',
cardNotFound: 'No payment card added',
retryPaymentButton: 'Retry payment',
viewPaymentHistory: 'View payment history',
},
yourPlan: {
title: 'Your plan',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3804,6 +3804,7 @@ export default {
changeCurrency: 'Cambiar moneda de pago',
cardNotFound: 'No se ha añadido ninguna tarjeta de pago',
retryPaymentButton: 'Reintentar el pago',
viewPaymentHistory: 'Ver historial de pagos',
},
yourPlan: {
title: 'Tu plan',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,32 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) {
const {stateToRender, searchRoute} = useMemo(() => {
const routes = reduceCentralPaneRoutes(state.routes);

// On narrow layout, if we are on /search route we want to hide the search central pane route.
if (isSmallScreenWidth) {
const isSearchCentralPane = (route: RouteProp<ParamListBase>) => getTopmostCentralPaneRoute({routes: [route]} as State<RootStackParamList>)?.name === SCREENS.SEARCH.CENTRAL_PANE;

const lastRoute = routes[routes.length - 1];
const lastSearchCentralPane = isSearchCentralPane(lastRoute) ? lastRoute : undefined;
const filteredRoutes = routes.filter((route) => !isSearchCentralPane(route));

// On narrow layout, if we are on /search route we want to hide all central pane routes and show only the bottom tab navigator.
if (lastSearchCentralPane) {
return {
stateToRender: {
...state,
index: 0,
routes: [filteredRoutes[0]],
},
searchRoute: lastSearchCentralPane,
};
}

return {
stateToRender: {
...state,
index: filteredRoutes.length - 1,
routes: filteredRoutes,
},
searchRoute: lastSearchCentralPane,
searchRoute: undefined,
};
}

Expand Down
18 changes: 18 additions & 0 deletions src/pages/settings/Subscription/CardSection/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItem from '@components/MenuItem';
import Section from '@components/Section';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import DateUtils from '@libs/DateUtils';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import PreTrialBillingBanner from './BillingBanner/PreTrialBillingBanner';
import CardSectionActions from './CardSectionActions';
Expand All @@ -21,6 +25,7 @@ function CardSection() {
const styles = useThemeStyles();
const theme = useTheme();
const [fundList] = useOnyx(ONYXKEYS.FUND_LIST);
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);

const defaultCard = useMemo(() => Object.values(fundList ?? {}).find((card) => card.isDefault), [fundList]);
Expand Down Expand Up @@ -67,6 +72,19 @@ function CardSection() {
)}
{isEmptyObject(defaultCard?.accountData) && <CardSectionDataEmpty />}
</View>
{!!account?.hasPurchases && (
<MenuItem
shouldShowRightIcon
icon={Expensicons.History}
iconStyles={[]}
wrapperStyle={styles.sectionMenuItemTopDescription}
style={styles.mt5}
title={translate('subscription.cardSection.viewPaymentHistory')}
titleStyle={styles.textStrong}
onPress={() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH.TAB.ALL))}
hoverAndPressStyle={styles.hoveredComponentBG}
/>
)}
</Section>
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type Account = {

/** Indicates whether the user can downgrade current subscription plan */
canDowngrade?: boolean;

/** Indicates whether the user has at least one previous purchase */
hasPurchases?: boolean;
};

export default Account;
Expand Down

0 comments on commit 04f6598

Please sign in to comment.