diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index 3c3e239d90d7..a106fbeff510 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -1,7 +1,25 @@ import Onyx from 'react-native-onyx'; +import type {OnyxUpdate} from 'react-native-onyx'; +import * as API from '@libs/API'; +import type { + AssignCompanyCardParams, + OpenPolicyCompanyCardsFeedParams, + OpenPolicyExpensifyCardsPageParams, + RequestFeedSetupParams, + SetCompanyCardExportAccountParams, + UpdateCompanyCardNameParams, +} from '@libs/API/parameters'; +import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import * as NetworkStore from '@libs/Network/NetworkStore'; +import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import * as ReportUtils from '@libs/ReportUtils'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {AssignCard} from '@src/types/onyx/AssignCard'; -import type {AddNewCardFeedData, AddNewCardFeedStep} from '@src/types/onyx/CardFeeds'; +import type {AssignCard, AssignCardData} from '@src/types/onyx/AssignCard'; +import type {AddNewCardFeedData, AddNewCardFeedStep, CompanyCardFeed} from '@src/types/onyx/CardFeeds'; +import type {OnyxData} from '@src/types/onyx/Request'; type AddNewCompanyCardFlowData = { /** Step to be set in Onyx */ @@ -33,4 +51,542 @@ function clearAddNewCardFlow() { }); } -export {setAddNewCompanyCardStepAndData, clearAddNewCardFlow, setAssignCardStepAndData, clearAssignCardStepAndData}; +function addNewCompanyCardsFeed(policyID: string, feedType: string, feedDetails: string) { + const authToken = NetworkStore.getAuthToken(); + + if (!authToken) { + return; + } + + const parameters: RequestFeedSetupParams = { + policyID, + authToken, + feedType, + feedDetails, + }; + + API.write(WRITE_COMMANDS.REQUEST_FEED_SETUP, parameters); +} + +function setWorkspaceCompanyCardFeedName(policyID: string, workspaceAccountID: number, bankName: string, userDefinedName: string) { + const authToken = NetworkStore.getAuthToken(); + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + settings: { + companyCardNicknames: { + [bankName]: userDefinedName, + }, + }, + }, + }, + ], + }; + + const parameters = { + authToken, + policyID, + bankName, + userDefinedName, + }; + + API.write(WRITE_COMMANDS.SET_COMPANY_CARD_FEED_NAME, parameters, onyxData); +} + +function setWorkspaceCompanyCardTransactionLiability(workspaceAccountID: number, policyID: string, bankName: string, liabilityType: string) { + const authToken = NetworkStore.getAuthToken(); + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + settings: { + companyCards: { + [bankName]: {liabilityType}, + }, + }, + }, + }, + ], + }; + + const parameters = { + authToken, + policyID, + bankName, + liabilityType, + }; + + API.write(WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY, parameters, onyxData); +} + +function deleteWorkspaceCompanyCardFeed(policyID: string, workspaceAccountID: number, bankName: string) { + const authToken = NetworkStore.getAuthToken(); + + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + settings: { + companyCards: { + [bankName]: null, + }, + companyCardNicknames: { + [bankName]: null, + }, + }, + }, + }, + ], + }; + + const parameters = { + authToken, + policyID, + bankName, + }; + + API.write(WRITE_COMMANDS.DELETE_COMPANY_CARD_FEED, parameters, onyxData); +} + +function assignWorkspaceCompanyCard(policyID: string, data?: Partial) { + if (!data) { + return; + } + const {bankName = '', email = '', encryptedCardNumber = '', startDate = ''} = data; + const assigneeDetails = PersonalDetailsUtils.getPersonalDetailByEmail(email); + const optimisticCardAssignedReportAction = ReportUtils.buildOptimisticCardAssignedReportAction(assigneeDetails?.accountID ?? -1); + + const parameters: AssignCompanyCardParams = { + policyID, + bankName, + encryptedCardNumber, + email, + startDate, + reportActionID: optimisticCardAssignedReportAction.reportActionID, + }; + const policy = PolicyUtils.getPolicy(policyID); + const policyExpenseChat = ReportUtils.getPolicyExpenseChat(policy?.ownerAccountID ?? -1, policyID); + + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${policyExpenseChat?.reportID}`, + value: { + [optimisticCardAssignedReportAction.reportActionID]: optimisticCardAssignedReportAction, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${policyExpenseChat?.reportID}`, + value: {[optimisticCardAssignedReportAction.reportActionID]: {pendingAction: null}}, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${policyExpenseChat?.reportID}`, + value: { + [optimisticCardAssignedReportAction.reportActionID]: { + pendingAction: null, + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + ], + }; + + API.write(WRITE_COMMANDS.ASSIGN_COMPANY_CARD, parameters, onyxData); +} + +function unassignWorkspaceCompanyCard(workspaceAccountID: number, cardID: string, bankName: string) { + const authToken = NetworkStore.getAuthToken(); + + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: null, + }, + }, + ], + }; + + const parameters = { + authToken, + cardID, + }; + + API.write(WRITE_COMMANDS.UNASSIGN_COMPANY_CARD, parameters, onyxData); +} + +function updateWorkspaceCompanyCard(workspaceAccountID: number, cardID: string, bankName: string) { + const authToken = NetworkStore.getAuthToken(); + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + isLoadingLastUpdated: true, + pendingFields: { + lastScrape: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + lastScrape: null, + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.CARD_LIST, + value: { + [cardID]: { + isLoadingLastUpdated: true, + pendingFields: { + lastScrape: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + lastScrape: null, + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + settings: { + companyCards: { + [bankName]: { + errors: null, + }, + }, + }, + }, + }, + ]; + + const finallyData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + isLoadingLastUpdated: false, + pendingFields: { + lastScrape: null, + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.CARD_LIST, + value: { + [cardID]: { + isLoadingLastUpdated: false, + pendingFields: { + lastScrape: null, + }, + }, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + isLoadingLastUpdated: false, + pendingFields: { + lastScrape: null, + }, + errorFields: { + lastScrape: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.CARD_LIST, + value: { + [cardID]: { + isLoadingLastUpdated: false, + pendingFields: { + lastScrape: null, + }, + errorFields: { + lastScrape: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + settings: { + companyCards: { + [bankName]: { + errors: {error: CONST.COMPANY_CARDS.CONNECTION_ERROR}, + }, + }, + }, + }, + }, + ]; + + const parameters = { + authToken, + cardID, + }; + + API.write(WRITE_COMMANDS.UPDATE_COMPANY_CARD, parameters, {optimisticData, finallyData, failureData}); +} + +function updateCompanyCardName(workspaceAccountID: number, cardID: string, newCardTitle: string, bankName: string, oldCardTitle?: string) { + const authToken = NetworkStore.getAuthToken(); + + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + nameValuePairs: { + cardTitle: newCardTitle, + pendingFields: { + cardTitle: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + cardTitle: null, + }, + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES, + value: {[cardID]: newCardTitle}, + }, + ]; + + const finallyData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + nameValuePairs: { + pendingFields: { + cardTitle: null, + }, + }, + }, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + nameValuePairs: { + pendingFields: { + cardTitle: null, + }, + errorFields: { + cardTitle: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES, + value: {[cardID]: oldCardTitle}, + }, + ]; + + const parameters: UpdateCompanyCardNameParams = { + authToken, + cardID: Number(cardID), + cardName: newCardTitle, + }; + + API.write(WRITE_COMMANDS.UPDATE_COMPANY_CARD_NAME, parameters, {optimisticData, finallyData, failureData}); +} + +function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bankName: string) { + const authToken = NetworkStore.getAuthToken(); + + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + nameValuePairs: { + pendingFields: { + exportAccountDetails: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + exportAccountDetails: null, + }, + exportAccountDetails: { + [accountKey]: newAccount, + }, + }, + }, + }, + }, + ]; + + const finallyData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + nameValuePairs: { + pendingFields: { + exportAccountDetails: null, + }, + }, + }, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + value: { + [cardID]: { + nameValuePairs: { + pendingFields: { + exportAccountDetails: null, + }, + errorFields: { + exportAccountDetails: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + }, + ]; + + const parameters: SetCompanyCardExportAccountParams = { + authToken, + cardID: Number(cardID), + exportAccountDetails: {[accountKey]: newAccount}, + }; + + API.write(WRITE_COMMANDS.SET_CARD_EXPORT_ACCOUNT, parameters, {optimisticData, finallyData, failureData}); +} + +function clearCompanyCardErrorField(workspaceAccountID: number, cardID: string, bankName: string, fieldName: string, isRootLevel?: boolean) { + if (isRootLevel) { + Onyx.merge(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, { + [cardID]: { + errorFields: {[fieldName]: null}, + }, + }); + return; + } + Onyx.merge(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, { + [cardID]: { + nameValuePairs: { + errorFields: {[fieldName]: null}, + }, + }, + }); +} + +function openPolicyCompanyCardsPage(policyID: string, workspaceAccountID: number) { + const authToken = NetworkStore.getAuthToken(); + + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + isLoading: true, + }, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + isLoading: false, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, + value: { + isLoading: false, + }, + }, + ]; + + const params: OpenPolicyExpensifyCardsPageParams = { + policyID, + authToken, + }; + + API.read(READ_COMMANDS.OPEN_POLICY_COMPANY_CARDS_PAGE, params, {optimisticData, successData, failureData}); +} + +function openPolicyCompanyCardsFeed(policyID: string, feed: CompanyCardFeed) { + const parameters: OpenPolicyCompanyCardsFeedParams = { + policyID, + feed, + }; + + API.read(READ_COMMANDS.OPEN_POLICY_COMPANY_CARDS_FEED, parameters); +} + +export { + setWorkspaceCompanyCardFeedName, + deleteWorkspaceCompanyCardFeed, + setWorkspaceCompanyCardTransactionLiability, + openPolicyCompanyCardsPage, + openPolicyCompanyCardsFeed, + addNewCompanyCardsFeed, + assignWorkspaceCompanyCard, + unassignWorkspaceCompanyCard, + updateWorkspaceCompanyCard, + updateCompanyCardName, + setCompanyCardExportAccount, + clearCompanyCardErrorField, + setAddNewCompanyCardStepAndData, + clearAddNewCardFlow, + setAssignCardStepAndData, + clearAssignCardStepAndData, +}; diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index c517439aeda2..5728c671c8b1 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -9,7 +9,6 @@ import * as API from '@libs/API'; import type { AddBillingCardAndRequestWorkspaceOwnerChangeParams, AddPaymentCardParams, - AssignCompanyCardParams, CreateWorkspaceFromIOUPaymentParams, CreateWorkspaceParams, DeleteWorkspaceAvatarParams, @@ -27,7 +26,6 @@ import type { EnablePolicyWorkflowsParams, LeavePolicyParams, OpenDraftWorkspaceRequestParams, - OpenPolicyCompanyCardsFeedParams, OpenPolicyEditCardLimitTypePageParams, OpenPolicyExpensifyCardsPageParams, OpenPolicyInitialPageParams, @@ -38,8 +36,6 @@ import type { OpenWorkspaceInvitePageParams, OpenWorkspaceParams, RequestExpensifyCardLimitIncreaseParams, - RequestFeedSetupParams, - SetCompanyCardExportAccountParams, SetPolicyAutomaticApprovalLimitParams, SetPolicyAutomaticApprovalRateParams, SetPolicyAutoReimbursementLimitParams, @@ -53,7 +49,6 @@ import type { SetWorkspaceAutoReportingMonthlyOffsetParams, SetWorkspacePayerParams, SetWorkspaceReimbursementParams, - UpdateCompanyCardNameParams, UpdatePolicyAddressParams, UpdateWorkspaceAvatarParams, UpdateWorkspaceDescriptionParams, @@ -82,7 +77,6 @@ import * as PersistedRequests from '@userActions/PersistedRequests'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type { - CompanyCardFeed, InvitedEmailsToAccountIDs, PersonalDetailsList, Policy, @@ -94,7 +88,6 @@ import type { TaxRatesWithDefault, Transaction, } from '@src/types/onyx'; -import type {AssignCardData} from '@src/types/onyx/AssignCard'; import type {Errors} from '@src/types/onyx/OnyxCommon'; import type {Attributes, CompanyAddress, CustomUnit, NetSuiteCustomList, NetSuiteCustomSegment, Rate, TaxRate} from '@src/types/onyx/Policy'; import type {OnyxData} from '@src/types/onyx/Request'; @@ -2004,56 +1997,6 @@ function openPolicyTaxesPage(policyID: string) { API.read(READ_COMMANDS.OPEN_POLICY_TAXES_PAGE, params); } -function openPolicyCompanyCardsFeed(policyID: string, feed: CompanyCardFeed) { - const parameters: OpenPolicyCompanyCardsFeedParams = { - policyID, - feed, - }; - - API.read(READ_COMMANDS.OPEN_POLICY_COMPANY_CARDS_FEED, parameters); -} - -function openPolicyCompanyCardsPage(policyID: string, workspaceAccountID: number) { - const authToken = NetworkStore.getAuthToken(); - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - isLoading: true, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - isLoading: false, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - isLoading: false, - }, - }, - ]; - - const params: OpenPolicyExpensifyCardsPageParams = { - policyID, - authToken, - }; - - API.read(READ_COMMANDS.OPEN_POLICY_COMPANY_CARDS_PAGE, params, {optimisticData, successData, failureData}); -} - function openPolicyExpensifyCardsPage(policyID: string, workspaceAccountID: number) { const authToken = NetworkStore.getAuthToken(); @@ -4435,477 +4378,6 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean) }); } -function addNewCompanyCardsFeed(policyID: string, feedType: string, feedDetails: string) { - const authToken = NetworkStore.getAuthToken(); - - if (!authToken) { - return; - } - - const parameters: RequestFeedSetupParams = { - policyID, - authToken, - feedType, - feedDetails, - }; - - API.write(WRITE_COMMANDS.REQUEST_FEED_SETUP, parameters); -} - -function setWorkspaceCompanyCardFeedName(policyID: string, workspaceAccountID: number, bankName: string, userDefinedName: string) { - const authToken = NetworkStore.getAuthToken(); - const onyxData: OnyxData = { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - settings: { - companyCardNicknames: { - [bankName]: userDefinedName, - }, - }, - }, - }, - ], - }; - - const parameters = { - authToken, - policyID, - bankName, - userDefinedName, - }; - - API.write(WRITE_COMMANDS.SET_COMPANY_CARD_FEED_NAME, parameters, onyxData); -} - -function setWorkspaceCompanyCardTransactionLiability(workspaceAccountID: number, policyID: string, bankName: string, liabilityType: string) { - const authToken = NetworkStore.getAuthToken(); - const onyxData: OnyxData = { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - settings: { - companyCards: { - [bankName]: {liabilityType}, - }, - }, - }, - }, - ], - }; - - const parameters = { - authToken, - policyID, - bankName, - liabilityType, - }; - - API.write(WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY, parameters, onyxData); -} - -function deleteWorkspaceCompanyCardFeed(policyID: string, workspaceAccountID: number, bankName: string) { - const authToken = NetworkStore.getAuthToken(); - - const onyxData: OnyxData = { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - settings: { - companyCards: { - [bankName]: null, - }, - companyCardNicknames: { - [bankName]: null, - }, - }, - }, - }, - ], - }; - - const parameters = { - authToken, - policyID, - bankName, - }; - - API.write(WRITE_COMMANDS.DELETE_COMPANY_CARD_FEED, parameters, onyxData); -} - -function assignWorkspaceCompanyCard(policyID: string, data?: Partial) { - if (!data) { - return; - } - const {bankName = '', email = '', encryptedCardNumber = '', startDate = ''} = data; - const assigneeDetails = PersonalDetailsUtils.getPersonalDetailByEmail(email); - const optimisticCardAssignedReportAction = ReportUtils.buildOptimisticCardAssignedReportAction(assigneeDetails?.accountID ?? -1); - - const parameters: AssignCompanyCardParams = { - policyID, - bankName, - encryptedCardNumber, - email, - startDate, - reportActionID: optimisticCardAssignedReportAction.reportActionID, - }; - const policy = getPolicy(policyID); - const policyExpenseChat = ReportUtils.getPolicyExpenseChat(policy?.ownerAccountID ?? -1, policyID); - - const onyxData: OnyxData = { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${policyExpenseChat?.reportID}`, - value: { - [optimisticCardAssignedReportAction.reportActionID]: optimisticCardAssignedReportAction, - }, - }, - ], - successData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${policyExpenseChat?.reportID}`, - value: {[optimisticCardAssignedReportAction.reportActionID]: {pendingAction: null}}, - }, - ], - failureData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${policyExpenseChat?.reportID}`, - value: { - [optimisticCardAssignedReportAction.reportActionID]: { - pendingAction: null, - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), - }, - }, - }, - ], - }; - - API.write(WRITE_COMMANDS.ASSIGN_COMPANY_CARD, parameters, onyxData); -} - -function unassignWorkspaceCompanyCard(workspaceAccountID: number, cardID: string, bankName: string) { - const authToken = NetworkStore.getAuthToken(); - - const onyxData: OnyxData = { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: null, - }, - }, - ], - }; - - const parameters = { - authToken, - cardID, - }; - - API.write(WRITE_COMMANDS.UNASSIGN_COMPANY_CARD, parameters, onyxData); -} - -function updateWorkspaceCompanyCard(workspaceAccountID: number, cardID: string, bankName: string) { - const authToken = NetworkStore.getAuthToken(); - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - isLoadingLastUpdated: true, - pendingFields: { - lastScrape: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - }, - errorFields: { - lastScrape: null, - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.CARD_LIST, - value: { - [cardID]: { - isLoadingLastUpdated: true, - pendingFields: { - lastScrape: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - }, - errorFields: { - lastScrape: null, - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - settings: { - companyCards: { - [bankName]: { - errors: null, - }, - }, - }, - }, - }, - ]; - - const finallyData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - isLoadingLastUpdated: false, - pendingFields: { - lastScrape: null, - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.CARD_LIST, - value: { - [cardID]: { - isLoadingLastUpdated: false, - pendingFields: { - lastScrape: null, - }, - }, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - isLoadingLastUpdated: false, - pendingFields: { - lastScrape: null, - }, - errorFields: { - lastScrape: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.CARD_LIST, - value: { - [cardID]: { - isLoadingLastUpdated: false, - pendingFields: { - lastScrape: null, - }, - errorFields: { - lastScrape: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: { - settings: { - companyCards: { - [bankName]: { - errors: {error: CONST.COMPANY_CARDS.CONNECTION_ERROR}, - }, - }, - }, - }, - }, - ]; - - const parameters = { - authToken, - cardID, - }; - - API.write(WRITE_COMMANDS.UPDATE_COMPANY_CARD, parameters, {optimisticData, finallyData, failureData}); -} - -function updateCompanyCardName(workspaceAccountID: number, cardID: string, newCardTitle: string, bankName: string, oldCardTitle?: string) { - const authToken = NetworkStore.getAuthToken(); - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - nameValuePairs: { - cardTitle: newCardTitle, - pendingFields: { - cardTitle: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - }, - errorFields: { - cardTitle: null, - }, - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES, - value: {[cardID]: newCardTitle}, - }, - ]; - - const finallyData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - nameValuePairs: { - pendingFields: { - cardTitle: null, - }, - }, - }, - }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - nameValuePairs: { - pendingFields: { - cardTitle: null, - }, - errorFields: { - cardTitle: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), - }, - }, - }, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES, - value: {[cardID]: oldCardTitle}, - }, - ]; - - const parameters: UpdateCompanyCardNameParams = { - authToken, - cardID: Number(cardID), - cardName: newCardTitle, - }; - - API.write(WRITE_COMMANDS.UPDATE_COMPANY_CARD_NAME, parameters, {optimisticData, finallyData, failureData}); -} - -function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bankName: string) { - const authToken = NetworkStore.getAuthToken(); - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - nameValuePairs: { - pendingFields: { - exportAccountDetails: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - }, - errorFields: { - exportAccountDetails: null, - }, - exportAccountDetails: { - [accountKey]: newAccount, - }, - }, - }, - }, - }, - ]; - - const finallyData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - nameValuePairs: { - pendingFields: { - exportAccountDetails: null, - }, - }, - }, - }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, - value: { - [cardID]: { - nameValuePairs: { - pendingFields: { - exportAccountDetails: null, - }, - errorFields: { - exportAccountDetails: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), - }, - }, - }, - }, - }, - ]; - - const parameters: SetCompanyCardExportAccountParams = { - authToken, - cardID: Number(cardID), - exportAccountDetails: {[accountKey]: newAccount}, - }; - - API.write(WRITE_COMMANDS.SET_CARD_EXPORT_ACCOUNT, parameters, {optimisticData, finallyData, failureData}); -} - -function clearCompanyCardErrorField(workspaceAccountID: number, cardID: string, bankName: string, fieldName: string, isRootLevel?: boolean) { - if (isRootLevel) { - Onyx.merge(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, { - [cardID]: { - errorFields: {[fieldName]: null}, - }, - }); - return; - } - Onyx.merge(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, { - [cardID]: { - nameValuePairs: { - errorFields: {[fieldName]: null}, - }, - }, - }); -} - function clearAllPolicies() { if (!allPolicies) { return; @@ -5006,18 +4478,6 @@ export { setPolicyBillableMode, disableWorkspaceBillableExpenses, setWorkspaceEReceiptsEnabled, - setWorkspaceCompanyCardFeedName, - deleteWorkspaceCompanyCardFeed, - setWorkspaceCompanyCardTransactionLiability, - openPolicyCompanyCardsPage, - openPolicyCompanyCardsFeed, - addNewCompanyCardsFeed, - assignWorkspaceCompanyCard, - unassignWorkspaceCompanyCard, - updateWorkspaceCompanyCard, - updateCompanyCardName, - setCompanyCardExportAccount, - clearCompanyCardErrorField, verifySetupIntentAndRequestPolicyOwnerChange, }; diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx index 3df8598fde2d..59a3e848de94 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx @@ -12,11 +12,11 @@ import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Policy from '@libs/actions/Policy/Policy'; import * as PolicyUtils from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; +import * as CompanyCards from '@userActions/CompanyCards'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -57,7 +57,7 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard if (!exportMenuItem?.exportType) { return; } - Policy.setCompanyCardExportAccount(workspaceAccountID, cardID, exportMenuItem.exportType, value, bank); + CompanyCards.setCompanyCardExportAccount(workspaceAccountID, cardID, exportMenuItem.exportType, value, bank); Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, cardID, bank)); }, diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx index e6036da6dc20..41ffd1222342 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx @@ -17,7 +17,6 @@ import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Policy from '@libs/actions/Policy/Policy'; import * as CardUtils from '@libs/CardUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -28,6 +27,7 @@ import Navigation from '@navigation/Navigation'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import variables from '@styles/variables'; +import * as CompanyCards from '@userActions/CompanyCards'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -62,12 +62,12 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag const unassignCard = () => { setIsUnassignModalVisible(false); - Policy.unassignWorkspaceCompanyCard(workspaceAccountID, cardID, bank); + CompanyCards.unassignWorkspaceCompanyCard(workspaceAccountID, cardID, bank); Navigation.goBack(); }; const updateCard = () => { - Policy.updateWorkspaceCompanyCard(workspaceAccountID, cardID, bank); + CompanyCards.updateWorkspaceCompanyCard(workspaceAccountID, cardID, bank); }; if (!card && !isLoadingOnyxValue(allBankCardsMetadata)) { @@ -118,7 +118,7 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag pendingAction={card?.nameValuePairs?.pendingFields?.cardTitle} errorRowStyles={[styles.ph5, styles.mb3]} errors={ErrorUtils.getLatestErrorField(card?.nameValuePairs ?? {}, 'cardTitle')} - onClose={() => Policy.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'cardTitle')} + onClose={() => CompanyCards.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'cardTitle')} > Policy.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'exportAccountDetails')} + onClose={() => CompanyCards.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'exportAccountDetails')} > Policy.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'lastScrape', true)} + onClose={() => CompanyCards.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'lastScrape', true)} > ) => { - Policy.updateCompanyCardName(workspaceAccountID, cardID, values[INPUT_IDS.NAME], bank, defaultValue); + CompanyCards.updateCompanyCardName(workspaceAccountID, cardID, values[INPUT_IDS.NAME], bank, defaultValue); Navigation.goBack(); }; diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx index 14c7322e9c19..4d3e5a347266 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx @@ -12,7 +12,7 @@ import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; import * as PolicyUtils from '@libs/PolicyUtils'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections'; -import * as Policy from '@userActions/Policy/Policy'; +import * as CompanyCards from '@userActions/CompanyCards'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; @@ -42,7 +42,7 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) { const isFeedAdded = !isPending && !isNoFeed; const fetchCompanyCards = useCallback(() => { - Policy.openPolicyCompanyCardsPage(policyID, workspaceAccountID); + CompanyCards.openPolicyCompanyCardsPage(policyID, workspaceAccountID); }, [policyID, workspaceAccountID]); useFocusEffect(fetchCompanyCards); @@ -52,7 +52,7 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) { return; } - Policy.openPolicyCompanyCardsFeed(policyID, selectedFeed); + CompanyCards.openPolicyCompanyCardsFeed(policyID, selectedFeed); }, [selectedFeed, isLoading, policyID, isPending]); return ( diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx index fb9eeb9e87c1..d456276d921a 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx @@ -13,12 +13,12 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Policy from '@libs/actions/Policy/Policy'; import * as CardUtils from '@libs/CardUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import * as ValidationUtils from '@libs/ValidationUtils'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import * as CompanyCards from '@userActions/CompanyCards'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -58,7 +58,7 @@ function WorkspaceCompanyCardsSettingsFeedNamePage({ ); const submit = ({name}: WorkspaceCompanyCardFeedName) => { - Policy.setWorkspaceCompanyCardFeedName(policyID, workspaceAccountID, selectedFeed, name); + CompanyCards.setWorkspaceCompanyCardFeedName(policyID, workspaceAccountID, selectedFeed, name); Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS.getRoute(policyID)); }; diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx index 331a14825616..d72869d012f7 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx @@ -13,12 +13,12 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Policy from '@libs/actions/Policy/Policy'; import * as CardUtils from '@libs/CardUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import * as CompanyCards from '@userActions/CompanyCards'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -49,13 +49,13 @@ function WorkspaceCompanyCardsSettingsPage({ }; const deleteCompanyCardFeed = () => { - Policy.deleteWorkspaceCompanyCardFeed(policyID, workspaceAccountID, selectedFeed); + CompanyCards.deleteWorkspaceCompanyCardFeed(policyID, workspaceAccountID, selectedFeed); setDeleteCompanyCardConfirmModalVisible(false); Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack); }; const onToggleLiability = (isOn: boolean) => { - Policy.setWorkspaceCompanyCardTransactionLiability( + CompanyCards.setWorkspaceCompanyCardTransactionLiability( workspaceAccountID, policyID, selectedFeed, diff --git a/src/pages/workspace/companyCards/addNew/DetailsStep.tsx b/src/pages/workspace/companyCards/addNew/DetailsStep.tsx index 87c819b074b6..2c719acd47d8 100644 --- a/src/pages/workspace/companyCards/addNew/DetailsStep.tsx +++ b/src/pages/workspace/companyCards/addNew/DetailsStep.tsx @@ -12,7 +12,6 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Policy from '@libs/actions/Policy/Policy'; import * as ValidationUtils from '@libs/ValidationUtils'; import Navigation from '@navigation/Navigation'; import * as CompanyCards from '@userActions/CompanyCards'; @@ -49,7 +48,7 @@ function DetailsStep({policyID}: DetailsStepProps) { .map(([key, value]) => `${key}: ${value}`) .join(', '); - Policy.addNewCompanyCardsFeed(policyID, addNewCard.data.feedType, feedDetails); + CompanyCards.addNewCompanyCardsFeed(policyID, addNewCard.data.feedType, feedDetails); Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID)); }; diff --git a/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx b/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx index e365b9be4e9d..ff766a1e7d70 100644 --- a/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx +++ b/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx @@ -10,7 +10,6 @@ import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useSafePaddingBottomStyle from '@hooks/useSafePaddingBottomStyle'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Policy from '@libs/actions/Policy/Policy'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import Navigation from '@navigation/Navigation'; import * as CompanyCards from '@userActions/CompanyCards'; @@ -39,7 +38,7 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) { const data = assignCard?.data; const submit = () => { - Policy.assignWorkspaceCompanyCard(policyID, data); + CompanyCards.assignWorkspaceCompanyCard(policyID, data); Navigation.navigate(backTo ?? ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID)); CompanyCards.clearAssignCardStepAndData(); }; diff --git a/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx b/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx index 822bef628799..8f5c9b2994cd 100644 --- a/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx +++ b/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx @@ -33,8 +33,8 @@ import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPol import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; import variables from '@styles/variables'; import * as Card from '@userActions/Card'; +import * as CompanyCards from '@userActions/CompanyCards'; import * as Member from '@userActions/Policy/Member'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -85,7 +85,7 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM const paymentAccountID = cardSettings?.paymentBankAccountID ?? 0; useEffect(() => { - Policy.openPolicyCompanyCardsPage(policyID, workspaceAccountID); + CompanyCards.openPolicyCompanyCardsPage(policyID, workspaceAccountID); }, [policyID, workspaceAccountID]); const memberCards = useMemo(() => {