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

[navigation] fix wrong navigation in subscription flow #56840

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const ROUTES = {
SETTINGS_TIMEZONE_SELECT: 'settings/profile/timezone/select',
SETTINGS_PRONOUNS: 'settings/profile/pronouns',
SETTINGS_PREFERENCES: 'settings/preferences',
SETTINGS_SUBSCRIPTION: 'settings/subscription',
SETTINGS_SUBSCRIPTION: {route: 'settings/subscription', getRoute: (backTo?: string) => getUrlWithBackToParam('settings/subscription', backTo)},
SETTINGS_SUBSCRIPTION_SIZE: {
route: 'settings/subscription/subscription-size',
getRoute: (canChangeSize: 0 | 1) => `settings/subscription/subscription-size?canChangeSize=${canChangeSize as number}` as const,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Navigation/DebugTabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ function getSettingsRoute(status: IndicatorStatus | undefined, reimbursementAcco
getReimbursementAccountRouteForCurrentStep(reimbursementAccount?.achData?.currentStep ?? CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT),
);
case CONST.INDICATOR_STATUS.HAS_SUBSCRIPTION_ERRORS:
return ROUTES.SETTINGS_SUBSCRIPTION;
return ROUTES.SETTINGS_SUBSCRIPTION.route;
case CONST.INDICATOR_STATUS.HAS_SUBSCRIPTION_INFO:
return ROUTES.SETTINGS_SUBSCRIPTION;
return ROUTES.SETTINGS_SUBSCRIPTION.route;
case CONST.INDICATOR_STATUS.HAS_SYNC_ERRORS:
return ROUTES.WORKSPACE_ACCOUNTING.getRoute(policyIDWithErrors);
case CONST.INDICATOR_STATUS.HAS_USER_WALLET_ERRORS:
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
exact: true,
},
[SCREENS.SETTINGS.SAVE_THE_WORLD]: ROUTES.SETTINGS_SAVE_THE_WORLD,
[SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: ROUTES.SETTINGS_SUBSCRIPTION,
[SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: {path: ROUTES.SETTINGS_SUBSCRIPTION.route},
[SCREENS.SETTINGS.PREFERENCES.ROOT]: {
path: ROUTES.SETTINGS_PREFERENCES,
// exact: true,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ type SettingsNavigatorParamList = {
tagName: string;
backTo?: Routes;
};
[SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: undefined;
[SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: {backTo?: Routes};
[SCREENS.SETTINGS.SUBSCRIPTION.SIZE]: {
canChangeSize: 0 | 1;
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
brickRoadIndicator: !!privateSubscription?.errors || hasSubscriptionRedDotError() ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
badgeText: freeTrialText,
badgeStyle: freeTrialText ? styles.badgeSuccess : undefined,
action: () => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION),
action: () => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.route),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function EarlyDiscountBanner({isSubscriptionPage}: EarlyDiscountBannerProps) {
success
style={shouldUseNarrowLayout && styles.flex1}
text={translate('subscription.billingBanner.earlyDiscount.claimOffer')}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()))}
/>
{discountInfo?.discountType === 25 && (
<Button
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Subscription/FreeTrial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function FreeTrial({badgeStyles, pressable = false, addSpacing = false, success
icon={Star}
success={success}
text={freeTrialText}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()))}
/>
) : (
<Badge
Expand Down
10 changes: 8 additions & 2 deletions src/pages/settings/Subscription/SubscriptionSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@
import useSubscriptionPlan from '@hooks/useSubscriptionPlan';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import * as Subscription from '@userActions/Subscription';

Check failure on line 17 in src/pages/settings/Subscription/SubscriptionSettingsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import CardSection from './CardSection/CardSection';
import ReducedFunctionalityMessage from './ReducedFunctionalityMessage';
import SubscriptionDetails from './SubscriptionDetails';
import SubscriptionPlan from './SubscriptionPlan';
import SubscriptionSettings from './SubscriptionSettings';

function SubscriptionSettingsPage() {
type SubscriptionSettingsPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.SUBSCRIPTION.ROOT>;

function SubscriptionSettingsPage({route}: SubscriptionSettingsPageProps) {
const backTo = route?.params?.backTo;
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand All @@ -45,7 +51,7 @@
>
<HeaderWithBackButton
title={translate('workspace.common.subscription')}
onBackButtonPress={() => Navigation.goBack()}
onBackButtonPress={() => Navigation.goBack(backTo)}
shouldShowBackButton={shouldUseNarrowLayout}
shouldDisplaySearchRouter
icon={Illustrations.CreditCardsNew}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/WorkspaceProfilePlanTypePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ function WorkspaceProfilePlanTypePage({policy}: WithPolicyProps) {
count: privateSubscription?.userCount ?? 1,
annualSubscriptionEndDate: autoRenewalDate,
})}{' '}
<TextLink onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)}>{translate('workspace.planTypePage.subscriptions')}</TextLink>.
<TextLink onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()))}>
{translate('workspace.planTypePage.subscriptions')}
</TextLink>
.
</Text>
) : (
<Text style={[styles.mh5, styles.mv3]}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/upgrade/GenericFeaturesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function GenericFeaturesView({onUpgrade, buttonDisabled, loading, policyID}: Gen
{translate('workspace.upgrade.commonFeatures.benefits.perMember')}{' '}
<TextLink
style={[styles.link]}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()))}
>
{translate('workspace.upgrade.commonFeatures.benefits.learnMore')}
</TextLink>{' '}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/upgrade/UpgradeConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function UpgradeConfirmation({policyName, onConfirmUpgrade, isCategorizing, isTr
{translate('workspace.upgrade.completed.successMessage', {policyName})}{' '}
<TextLink
style={styles.link}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()))}
>
{translate('workspace.upgrade.completed.viewSubscription')}
</TextLink>{' '}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/upgrade/UpgradeIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function UpgradeIntro({feature, onUpgrade, buttonDisabled, loading, isCategorizi
openLink(CONST.PLAN_TYPES_AND_PRICING_HELP_URL, environmentURL);
return;
}
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION);
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION.getRoute(Navigation.getActiveRoute()));
}}
>
{translate('workspace.upgrade.note.learnMore')}
Expand Down
Loading