Skip to content

Commit f642499

Browse files
committed
fix: go to navigation
1 parent db7c765 commit f642499

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/components/ImportSpreadsheet.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ type ImportSpreadsheetProps = {
3535
// The route to navigate to after the file import is completed.
3636
goTo: Routes;
3737

38+
// If true, replace the current route after import instead of pushing on top.
39+
shouldForceReplaceNavigation?: boolean;
40+
3841
/** Whether the spreadsheet is importing multi-level tags */
3942
isImportingMultiLevelTags?: boolean;
4043
};
4144

42-
function ImportSpreadsheet({backTo, goTo, isImportingMultiLevelTags}: ImportSpreadsheetProps) {
45+
function ImportSpreadsheet({backTo, goTo, shouldForceReplaceNavigation = false, isImportingMultiLevelTags}: ImportSpreadsheetProps) {
4346
const [importedSpreadsheet] = useOnyx(ONYXKEYS.IMPORTED_SPREADSHEET);
4447
const icons = useMemoizedLazyExpensifyIcons(['SpreadsheetComputer']);
4548
const styles = useThemeStyles();
@@ -145,7 +148,7 @@ function ImportSpreadsheet({backTo, goTo, isImportingMultiLevelTags}: ImportSpre
145148
);
146149
})
147150
.then(() => {
148-
Navigation.navigate(goTo);
151+
Navigation.navigate(goTo, {forceReplace: shouldForceReplaceNavigation});
149152
})
150153
.catch(() => {
151154
showUploadFileError('spreadsheet.importFailedTitle', 'spreadsheet.invalidFileMessage');

src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ const OPTIONS_PER_SCREEN: Partial<Record<Screen, PlatformStackNavigationOptions>
110110
[SCREENS.MULTIFACTOR_AUTHENTICATION.NOT_FOUND]: {
111111
animationTypeForReplace: 'push',
112112
},
113+
[SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORTED]: {
114+
animationTypeForReplace: 'push',
115+
},
113116
};
114117

115118
/**

src/pages/workspace/categories/ImportCategoriesPage.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type {RouteProp} from '@react-navigation/native';
21
import React from 'react';
32
import ImportSpreadsheet from '@components/ImportSpreadsheet';
43
import useDynamicBackPath from '@hooks/useDynamicBackPath';
54
import usePolicy from '@hooks/usePolicy';
65
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
6+
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
77
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
88
import {goBackFromInvalidPolicy, hasAccountingConnections as hasAccountingConnectionsUtil} from '@libs/PolicyUtils';
99
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
@@ -13,9 +13,9 @@ import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
1313
import SCREENS from '@src/SCREENS';
1414
import {isEmptyObject} from '@src/types/utils/EmptyObject';
1515

16-
type ImportCategoriesPageProps = {
17-
route: RouteProp<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORT | typeof SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORT>;
18-
};
16+
type ImportCategoriesPageProps =
17+
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.DYNAMIC_CATEGORIES_IMPORT>
18+
| PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS_CATEGORIES.SETTINGS_CATEGORIES_IMPORT>;
1919

2020
function ImportCategoriesPage({route}: ImportCategoriesPageProps) {
2121
const policyID = route.params.policyID;
@@ -41,6 +41,7 @@ function ImportCategoriesPage({route}: ImportCategoriesPageProps) {
4141
<ImportSpreadsheet
4242
backTo={isQuickSettingsFlow ? backTo : workspaceCategoriesListBackPath}
4343
goTo={isQuickSettingsFlow ? ROUTES.SETTINGS_CATEGORIES_IMPORTED.getRoute(policyID, backTo) : workspaceGoToImportedPath}
44+
shouldForceReplaceNavigation={!isQuickSettingsFlow}
4445
/>
4546
</AccessOrNotFoundWrapper>
4647
);

0 commit comments

Comments
 (0)