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

[Advanced Approval Workflows]: The Back button in the confirm page close RHP #47845

Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function ApprovalWorkflowEditor({approvalWorkflow, removeApprovalWorkflow, polic

const editMembers = useCallback(() => {
const backTo = approvalWorkflow.action === CONST.APPROVAL_WORKFLOW.ACTION.CREATE ? ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(policyID) : undefined;
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_EXPENSES_FROM.getRoute(policyID, backTo));
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_EXPENSES_FROM.getRoute(policyID, backTo), CONST.NAVIGATION.ACTION_TYPE.PUSH);
}, [approvalWorkflow.action, policyID]);

const editApprover = useCallback(
(approverIndex: number) => {
const backTo = approvalWorkflow.action === CONST.APPROVAL_WORKFLOW.ACTION.CREATE ? ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(policyID) : undefined;
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_APPROVER.getRoute(policyID, approverIndex, backTo));
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_APPROVER.getRoute(policyID, approverIndex, backTo), CONST.NAVIGATION.ACTION_TYPE.PUSH);
},
[approvalWorkflow.action, policyID],
);
Expand All @@ -101,7 +101,10 @@ function ApprovalWorkflowEditor({approvalWorkflow, removeApprovalWorkflow, polic
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.alias, Navigation.getActiveRoute()));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_APPROVER.getRoute(policyID, approvalWorkflow.approvers.length, ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(policyID)));
Navigation.navigate(
ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_APPROVER.getRoute(policyID, approvalWorkflow.approvers.length, ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(policyID)),
CONST.NAVIGATION.ACTION_TYPE.PUSH,
);
}, [approvalWorkflow.approvers.length, policy, policyID]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ function WorkspaceWorkflowsApprovalsApproverPageBeta({policy, personalDetails, i
}

if (approvalWorkflow?.action === CONST.APPROVAL_WORKFLOW.ACTION.CREATE) {
Navigation.goBack();
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(route.params.policyID), CONST.NAVIGATION.TYPE.UP);
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_NEW.getRoute(route.params.policyID));
} else {
const firstApprover = approvalWorkflow?.approvers?.[0]?.email ?? '';
Navigation.goBack(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_EDIT.getRoute(route.params.policyID, firstApprover));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPol
import * as Workflow from '@userActions/Workflow';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import ApprovalWorkflowEditor from './ApprovalWorkflowEditor';
Expand All @@ -45,7 +44,7 @@ function WorkspaceWorkflowsApprovalsCreatePage({policy, isLoadingReportData = tr
}

Workflow.createApprovalWorkflow(route.params.policyID, approvalWorkflow);
Navigation.goBack(ROUTES.WORKSPACE_WORKFLOWS.getRoute(route.params.policyID));
Navigation.dismissModal();
}, [approvalWorkflow, route.params.policyID]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true

const membersToRemove = initialApprovalWorkflow.members.filter((initialMember) => !approvalWorkflow.members.some((member) => member.email === initialMember.email));
Workflow.updateApprovalWorkflow(route.params.policyID, approvalWorkflow, membersToRemove);
Navigation.goBack();
Navigation.dismissModal();
}, [approvalWorkflow, initialApprovalWorkflow, route.params.policyID]);

const removeApprovalWorkflow = useCallback(() => {
Expand All @@ -61,7 +61,7 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true

// Remove the approval workflow using the initial data as it could be already edited
Workflow.removeApprovalWorkflow(route.params.policyID, initialApprovalWorkflow);
Navigation.goBack();
Navigation.dismissModal();
}, [initialApprovalWorkflow, route.params.policyID]);

// Set the initial approval workflow when the page is loaded
Expand Down
Loading