@@ -2,12 +2,22 @@ import React from 'react';
2
2
import ScreenWrapper from '@components/ScreenWrapper' ;
3
3
import WorkspaceConfirmationForm from '@components/WorkspaceConfirmationForm' ;
4
4
import type { WorkspaceConfirmationSubmitFunctionParams } from '@components/WorkspaceConfirmationForm' ;
5
+ import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
5
6
import { createWorkspaceWithPolicyDraftAndNavigateToIt } from '@libs/actions/App' ;
7
+ import { generatePolicyID } from '@libs/actions/Policy/Policy' ;
6
8
import getCurrentUrl from '@libs/Navigation/currentUrl' ;
9
+ import ROUTES from '@src/ROUTES' ;
7
10
8
11
function WorkspaceConfirmationPage ( ) {
12
+ // It is necessary to use here isSmallScreenWidth because on a wide layout we should always navigate to ROUTES.WORKSPACE_PROFILE.
13
+ // shouldUseNarrowLayout cannot be used to determine that as this screen is displayed in RHP and shouldUseNarrowLayout always returns true.
14
+ // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
15
+ const { isSmallScreenWidth} = useResponsiveLayout ( ) ;
16
+
9
17
const onSubmit = ( params : WorkspaceConfirmationSubmitFunctionParams ) => {
10
- createWorkspaceWithPolicyDraftAndNavigateToIt ( '' , params . name , false , false , '' , params . policyID , params . currency , params . avatarFile as File ) ;
18
+ const policyID = params . policyID || generatePolicyID ( ) ;
19
+ const routeToNavigate = isSmallScreenWidth ? ROUTES . WORKSPACE_INITIAL . getRoute ( policyID ) : ROUTES . WORKSPACE_PROFILE . getRoute ( policyID ) ;
20
+ createWorkspaceWithPolicyDraftAndNavigateToIt ( '' , params . name , false , false , '' , policyID , params . currency , params . avatarFile as File , routeToNavigate ) ;
11
21
} ;
12
22
const currentUrl = getCurrentUrl ( ) ;
13
23
// Approved Accountants and Guides can enter a flow where they make a workspace for other users,
0 commit comments