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
5 changes: 2 additions & 3 deletions src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPol
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
import variables from '@styles/variables';
import {setIssueNewCardStepAndData} from '@userActions/Card';
import {clearWorkspaceOwnerChangeFlow, isApprover as isApproverUserAction, openPolicyMemberProfilePage, removeMembers, requestWorkspaceOwnerChange} from '@userActions/Policy/Member';
import {clearWorkspaceOwnerChangeFlow, isApprover as isApproverUserAction, openPolicyMemberProfilePage, removeMembers} from '@userActions/Policy/Member';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -290,9 +290,8 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM

const startChangeOwnershipFlow = useCallback(() => {
clearWorkspaceOwnerChangeFlow(policyID);
requestWorkspaceOwnerChange(policyID, currentUserPersonalDetails.accountID, currentUserPersonalDetails.login ?? '');
Navigation.navigate(ROUTES.WORKSPACE_OWNER_CHANGE_CHECK.getRoute(policyID, accountID, 'amountOwed' as ValueOf<typeof CONST.POLICY.OWNERSHIP_ERRORS>));
}, [accountID, currentUserPersonalDetails.accountID, currentUserPersonalDetails.login, policyID]);
}, [accountID, policyID]);

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, {useCallback} from 'react';
import React, {useCallback, useRef} from 'react';
import {View} from 'react-native';
import Button from '@components/Button';
import FixedFooter from '@components/FixedFooter';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';

Check warning on line 7 in src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details

Check warning on line 7 in src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used. Direct imports from @components/Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import RenderHTML from '@components/RenderHTML';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import Navigation from '@navigation/Navigation';
Expand All @@ -30,19 +31,23 @@
const backTo = route.params.backTo;

const closePage = useCallback(() => {
clearWorkspaceOwnerChangeFlow(policyID);
if (backTo) {
Navigation.goBack(backTo);
} else {
Navigation.goBack();
Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID));
}
clearWorkspaceOwnerChangeFlow(policyID);
}, [accountID, backTo, policyID]);

const policy = usePolicy(policyID);
const shouldShowRef = useRef(!policy?.errorFields && policy?.isChangeOwnerFailed);

return (
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
shouldBeBlocked={!shouldShowRef.current}
>
<ScreenWrapper
testID="WorkspaceOwnerChangeErrorPage"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, {useCallback} from 'react';
import React, {useCallback, useRef} from 'react';
import ConfirmationPage from '@components/ConfirmationPage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import LottieAnimations from '@components/LottieAnimations';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import Navigation from '@navigation/Navigation';
Expand All @@ -25,19 +26,23 @@ function WorkspaceOwnerChangeSuccessPage({route}: WorkspaceOwnerChangeSuccessPag
const backTo = route.params.backTo;

const closePage = useCallback(() => {
clearWorkspaceOwnerChangeFlow(policyID);
if (backTo) {
Navigation.goBack(backTo);
} else {
Navigation.goBack();
Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID));
}
clearWorkspaceOwnerChangeFlow(policyID);
}, [accountID, backTo, policyID]);

const policy = usePolicy(policyID);
const shouldShowRef = useRef(!policy?.errorFields?.changeOwner && policy?.isChangeOwnerSuccessful);
Comment thread
daledah marked this conversation as resolved.
Resolved

return (
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
shouldBeBlocked={!shouldShowRef.current}
>
<ScreenWrapper testID="WorkspaceOwnerChangeSuccessPage">
<HeaderWithBackButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {View} from 'react-native';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -14,7 +15,7 @@ import CardAuthenticationModal from '@pages/settings/Subscription/CardAuthentica
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import withPolicy from '@pages/workspace/withPolicy';
import type {WithPolicyOnyxProps} from '@pages/workspace/withPolicy';
import {clearWorkspaceOwnerChangeFlow} from '@userActions/Policy/Member';
import {clearWorkspaceOwnerChangeFlow, requestWorkspaceOwnerChange} from '@userActions/Policy/Member';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand All @@ -33,9 +34,18 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr
const accountID = Number(route.params.accountID);
const error = route.params.error;
const backTo = route.params.backTo;
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const isAuthRequired = privateStripeCustomerID?.status === CONST.STRIPE_SCA_AUTH_STATUSES.CARD_AUTHENTICATION_REQUIRED;
const shouldShowPaymentCardForm = error === CONST.POLICY.OWNERSHIP_ERRORS.NO_BILLING_CARD || isAuthRequired;

useEffect(() => {
if (policy?.isChangeOwnerFailed || policy?.isChangeOwnerSuccessful) {
return;
}
requestWorkspaceOwnerChange(policyID, currentUserPersonalDetails.accountID, currentUserPersonalDetails.login ?? '');
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@daledah Can you please give a reason why we use only policyID as dependency here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This effect is meant to call ⁨requestWorkspaceOwnerChange⁩ once on page mount, so I only use ⁨policyID⁩ as a dependency.

}, [policyID]);

useEffect(() => {
if (!policy || policy?.isLoading) {
return;
Expand Down
Loading