Skip to content

Commit

Permalink
Merge pull request Expensify#46460 from Expensify/revert-45730-fix-45689
Browse files Browse the repository at this point in the history
Revert "fix: redirect to proper place after upgrade"
  • Loading branch information
luacmartins authored Jul 29, 2024
2 parents 48e8017 + fdd2385 commit 82fcf30
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 50 deletions.
4 changes: 1 addition & 3 deletions src/components/ConnectToNetSuiteButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ function ConnectToNetSuiteButton({policyID, shouldDisconnectIntegrationBeforeCon
<Button
onPress={() => {
if (!isControlPolicy(policy)) {
Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.netsuite.alias, ROUTES.POLICY_ACCOUNTING_NETSUITE_TOKEN_INPUT.getRoute(policyID)),
);
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.netsuite.alias));
return;
}

Expand Down
8 changes: 1 addition & 7 deletions src/components/ConnectToSageIntacctButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ function ConnectToSageIntacctButton({policyID, shouldDisconnectIntegrationBefore
<Button
onPress={() => {
if (!isControlPolicy(policy)) {
Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(
policyID,
CONST.UPGRADE_FEATURE_INTRO_MAPPING.intacct.alias,
ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.getRoute(policyID),
),
);
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.intacct.alias));
return;
}

Expand Down
16 changes: 2 additions & 14 deletions src/pages/workspace/categories/CategorySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet
description={translate(`workspace.categories.glCode`)}
onPress={() => {
if (!isControlPolicy(policy)) {
Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(
route.params.policyID,
CONST.UPGRADE_FEATURE_INTRO_MAPPING.glAndPayrollCodes.alias,
ROUTES.WORKSPACE_CATEGORY_GL_CODE.getRoute(route.params.policyID, policyCategory.name),
),
);
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(route.params.policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.glAndPayrollCodes.alias));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_CATEGORY_GL_CODE.getRoute(route.params.policyID, policyCategory.name));
Expand All @@ -162,13 +156,7 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet
description={translate(`workspace.categories.payrollCode`)}
onPress={() => {
if (!isControlPolicy(policy)) {
Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(
route.params.policyID,
CONST.UPGRADE_FEATURE_INTRO_MAPPING.glAndPayrollCodes.alias,
ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.getRoute(route.params.policyID, policyCategory.name),
),
);
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(route.params.policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.glAndPayrollCodes.alias));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.getRoute(route.params.policyID, policyCategory.name));
Expand Down
8 changes: 1 addition & 7 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ function TagSettingsPage({route, policyTags, navigation}: TagSettingsPageProps)

const navigateToEditGlCode = () => {
if (!PolicyUtils.isControlPolicy(policy)) {
Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(
route.params.policyID,
CONST.UPGRADE_FEATURE_INTRO_MAPPING.glCodes.alias,
ROUTES.WORKSPACE_TAG_GL_CODE.getRoute(policy?.id ?? '', route.params.orderWeight, route.params.tagName),
),
);
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(route.params.policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.glCodes.alias));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_TAG_GL_CODE.getRoute(route.params.policyID, route.params.orderWeight, currentPolicyTag.name));
Expand Down
6 changes: 3 additions & 3 deletions src/pages/workspace/upgrade/UpgradeConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import ROUTES from '@src/ROUTES';

type Props = {
policyName: string;
onConfirmUpgrade: () => void;
policyID: string;
};

function UpgradeConfirmation({policyName, onConfirmUpgrade}: Props) {
function UpgradeConfirmation({policyName, policyID}: Props) {
const {translate} = useLocalize();
const styles = useThemeStyles();

Expand All @@ -31,7 +31,7 @@ function UpgradeConfirmation({policyName, onConfirmUpgrade}: Props) {
</>
}
shouldShowButton
onButtonPress={onConfirmUpgrade}
onButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(policyID))}
buttonText={translate('workspace.upgrade.completed.gotIt')}
/>
);
Expand Down
19 changes: 4 additions & 15 deletions src/pages/workspace/upgrade/WorkspaceUpgradePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import {isControlPolicy} from '@libs/PolicyUtils';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import CONST from '@src/CONST';
import * as Policy from '@src/libs/actions/Policy/Policy';
Expand All @@ -27,25 +26,15 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) {
const [policy] = useOnyx(`policy_${policyID}`);
const {isOffline} = useNetwork();

const isUpgraded = React.useMemo(() => isControlPolicy(policy), [policy]);

if (!feature || !policy) {
return <NotFoundPage />;
}

const upgradeToCorporate = () => {
Policy.upgradeToCorporate(policy.id, feature.name);
Policy.upgradeToCorporate(policy.id, feature.id);
};

const confirmUpgrade = () => {
switch (feature.id) {
case CONST.UPGRADE_FEATURE_INTRO_MAPPING.reportFields.id:
Policy.enablePolicyReportFields(policyID, true);
return Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID), CONST.NAVIGATION.TYPE.UP);
default:
return route.params.backTo ? Navigation.navigate(route.params.backTo, CONST.NAVIGATION.TYPE.UP) : Navigation.goBack();
}
};
const isUpgraded = policy.type === CONST.POLICY.TYPE.CORPORATE;

return (
<ScreenWrapper
Expand All @@ -55,11 +44,11 @@ function WorkspaceUpgradePage({route}: WorkspaceUpgradePageProps) {
>
<HeaderWithBackButton
title={translate('common.upgrade')}
onBackButtonPress={() => Navigation.goBack()}
onBackButtonPress={() => Navigation.goBack(route.params.backTo ?? ROUTES.WORKSPACE_PROFILE.getRoute(policyID))}
/>
{isUpgraded && (
<UpgradeConfirmation
onConfirmUpgrade={confirmUpgrade}
policyID={policy.id}
policyName={policy.name}
/>
)}
Expand Down
7 changes: 6 additions & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2762,10 +2762,15 @@ const styles = (theme: ThemeColors) =>
width: 110,
},

workspaceUpgradeIntroBox: ({isExtraSmallScreenWidth}: WorkspaceUpgradeIntroBoxParams): ViewStyle => {
workspaceUpgradeIntroBox: ({isExtraSmallScreenWidth, isSmallScreenWidth}: WorkspaceUpgradeIntroBoxParams): ViewStyle => {
let paddingHorizontal = spacing.ph5;
let paddingVertical = spacing.pv5;

if (isSmallScreenWidth) {
paddingHorizontal = spacing.ph4;
paddingVertical = spacing.pv4;
}

if (isExtraSmallScreenWidth) {
paddingHorizontal = spacing.ph2;
paddingVertical = spacing.pv2;
Expand Down

0 comments on commit 82fcf30

Please sign in to comment.