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

[NO QA] Feature: Implement SCA support to transfer owner #49411

Merged
merged 20 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -1,5 +1,4 @@
type VerifySetupIntentAndRequestPolicyOwnerChangeParams = {
accountID: number;
policyID: string;
};
export default VerifySetupIntentAndRequestPolicyOwnerChangeParams;
4 changes: 2 additions & 2 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@
* Properly updates the nvp_privateStripeCustomerID onyx data for 3DS payment
*
*/
function verifySetupIntentAndRequestPolicyOwnerChange(accountID: number, policyID: string) {
function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -915,8 +915,8 @@
isChangeOwnerFailed: true,
},
},
];

Check failure on line 918 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / typecheck

Object literal may only specify known properties, and 'sessionAccountID' does not exist in type 'VerifySetupIntentAndRequestPolicyOwnerChangeParams'.
API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {accountID, policyID}, {optimisticData, successData, failureData});
API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {sessionAccountID, policyID}, {optimisticData, successData, failureData});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function CardAuthenticationModal({headerTitle, policyID}: CardAuthenticationModa
const message = event.data;
if (message === CONST.GBP_AUTHENTICATION_COMPLETE) {
if (policyID) {
PolicyActions.verifySetupIntentAndRequestPolicyOwnerChange(session?.accountID ?? -1, policyID);
PolicyActions.verifySetupIntentAndRequestPolicyOwnerChange(policyID);
} else {
PaymentMethods.verifySetupIntent(session?.accountID ?? -1, true);
}
Expand Down
25 changes: 17 additions & 8 deletions src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {StackScreenProps} from '@react-navigation/stack';
import isEmpty from 'lodash/isEmpty';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
Expand All @@ -24,6 +25,7 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CardUtils from '@libs/CardUtils';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import getPlatform from '@libs/getPlatform';
import * as PolicyUtils from '@libs/PolicyUtils';
import Navigation from '@navigation/Navigation';
import type {SettingsNavigatorParamList} from '@navigation/types';
Expand Down Expand Up @@ -80,6 +82,11 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM
const policyOwnerDisplayName = ownerDetails.displayName ?? policy?.owner ?? '';
const companyCards = CardUtils.getMemberCards(policy, allCardsList, accountID);

// To render correctly transfer owner button
const [fundList] = useOnyx(ONYXKEYS.FUND_LIST, {initialValue: {}});
const isNative = getPlatform() === CONST.PLATFORM.IOS || getPlatform() === CONST.PLATFORM.ANDROID;
waterim marked this conversation as resolved.
Show resolved Hide resolved
const shouldShowTransferButton = !isNative || (isNative && !isEmpty(fundList));

// TODO: for now enabled for testing purposes. Change this to check for the actual multiple feeds when API is ready
const hasMultipleFeeds = policy?.areCompanyCardsEnabled;

Expand Down Expand Up @@ -240,14 +247,16 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM
</Text>
)}
{isSelectedMemberOwner && isCurrentUserAdmin && !isCurrentUserOwner ? (
<Button
text={translate('workspace.people.transferOwner')}
onPress={startChangeOwnershipFlow}
isDisabled={isOffline}
icon={Expensicons.Transfer}
iconStyles={StyleUtils.getTransformScaleStyle(0.8)}
style={styles.mv5}
/>
shouldShowTransferButton && (
<Button
text={translate('workspace.people.transferOwner')}
onPress={startChangeOwnershipFlow}
isDisabled={isOffline}
icon={Expensicons.Transfer}
iconStyles={StyleUtils.getTransformScaleStyle(0.8)}
style={styles.mv5}
/>
)
) : (
<Button
text={translate('workspace.people.removeWorkspaceMemberButtonTitle')}
Expand Down
Loading