Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2513,7 +2513,12 @@ const ROUTES = {
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: (backTo?: string) => getUrlWithBackToParam(`travel/public-domain-error`, backTo),
},
TRAVEL_WORKSPACE_CONFIRMATION: 'travel/upgrade/workspace/confirmation',
TRAVEL_WORKSPACE_CONFIRMATION: {
route: 'travel/upgrade/workspace/confirmation',

// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
getRoute: (backTo?: string) => getUrlWithBackToParam(`travel/upgrade/workspace/confirmation`, backTo),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to add backTo here because the travel upgrade (the previous page) has a backTo param and I need to preserve it to preserve the current behavior.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, why does the travel upgrade page need to have a backTo param? Could we instead address this by removing it from there?

},
TRAVEL_WORKSPACE_ADDRESS: {
route: 'travel/:domain/workspace-address',

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 @@ -1561,7 +1561,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.TRAVEL.DOMAIN_SELECTOR]: ROUTES.TRAVEL_DOMAIN_SELECTOR.route,
[SCREENS.TRAVEL.DOMAIN_PERMISSION_INFO]: ROUTES.TRAVEL_DOMAIN_PERMISSION_INFO.route,
[SCREENS.TRAVEL.PUBLIC_DOMAIN_ERROR]: ROUTES.TRAVEL_PUBLIC_DOMAIN_ERROR.route,
[SCREENS.TRAVEL.WORKSPACE_CONFIRMATION]: ROUTES.TRAVEL_WORKSPACE_CONFIRMATION,
[SCREENS.TRAVEL.WORKSPACE_CONFIRMATION]: ROUTES.TRAVEL_WORKSPACE_CONFIRMATION.route,
[SCREENS.TRAVEL.WORKSPACE_ADDRESS]: ROUTES.TRAVEL_WORKSPACE_ADDRESS.route,
[SCREENS.TRAVEL.VERIFY_ACCOUNT]: ROUTES.TRAVEL_VERIFY_ACCOUNT.route,
},
Expand Down
5 changes: 4 additions & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,10 @@ type TravelNavigatorParamList = {
[SCREENS.TRAVEL.DOMAIN_PERMISSION_INFO]: {
domain: string;
};
[SCREENS.TRAVEL.WORKSPACE_CONFIRMATION]: undefined;
[SCREENS.TRAVEL.WORKSPACE_CONFIRMATION]: {
// eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md
backTo?: Routes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to add this?

};
[SCREENS.TRAVEL.WORKSPACE_ADDRESS]: {
domain: string;
// eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Travel/TravelUpgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function TravelUpgrade({route}: TravelUpgradeProps) {
}, [groupPaidPolicies.length]);

const openWorkspaceConfirmation = () => {
Navigation.navigate(ROUTES.TRAVEL_WORKSPACE_CONFIRMATION);
Navigation.navigate(ROUTES.TRAVEL_WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute()));
};

return (
Expand All @@ -51,7 +51,7 @@ function TravelUpgrade({route}: TravelUpgradeProps) {
>
<HeaderWithBackButton
title={translate('common.upgrade')}
onBackButtonPress={() => Navigation.goBack(route.params.backTo)}
onBackButtonPress={() => Navigation.goBack(route.params?.backTo)}
/>
<ScrollView contentContainerStyle={styles.flexGrow1}>
{isUpgraded ? (
Expand Down
20 changes: 17 additions & 3 deletions src/pages/Travel/WorkspaceConfirmationForTravelPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React from 'react';
import ScreenWrapper from '@components/ScreenWrapper';
import WorkspaceConfirmationForm from '@components/WorkspaceConfirmationForm';
import type {WorkspaceConfirmationSubmitFunctionParams} from '@components/WorkspaceConfirmationForm';
import useOnyx from '@hooks/useOnyx';
import {createDraftWorkspace, createWorkspace} from '@libs/actions/Policy/Policy';
import Navigation from '@libs/Navigation/Navigation';
import type {TravelNavigatorParamList} from '@libs/Navigation/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

function WorkspaceConfirmationForTravelPage() {
type WorkspaceConfirmationForTravelPageProps = StackScreenProps<TravelNavigatorParamList, typeof SCREENS.TRAVEL.WORKSPACE_CONFIRMATION>;

function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTravelPageProps) {
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});

const goBack = () => {
Navigation.goBack(route.params?.backTo ?? ROUTES.TRAVEL_UPGRADE.route);
};

const onSubmit = (params: WorkspaceConfirmationSubmitFunctionParams) => {
createDraftWorkspace(introSelected, '', false, params.name, params.policyID, params.currency, params.avatarFile as File);
createWorkspace({
Expand All @@ -20,15 +31,18 @@ function WorkspaceConfirmationForTravelPage() {
currency: params.currency,
file: params.avatarFile as File,
});
Navigation.goBack();
goBack();
};

return (
<ScreenWrapper
enableEdgeToEdgeBottomSafeAreaPadding
testID={WorkspaceConfirmationForTravelPage.displayName}
>
<WorkspaceConfirmationForm onSubmit={onSubmit} />
<WorkspaceConfirmationForm
onBackButtonPress={goBack}
onSubmit={onSubmit}
/>
</ScreenWrapper>
);
}
Expand Down
Loading