From c03a41404b49d7ddc0b0202352e1c1ee053d9441 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 28 Aug 2024 17:51:32 +0300 Subject: [PATCH 1/8] Feed Settings --- src/CONST.ts | 6 + src/ONYXKEYS.ts | 5 +- src/ROUTES.ts | 12 ++ src/SCREENS.ts | 3 + src/languages/en.ts | 18 +++ src/languages/es.ts | 18 +++ src/languages/types.ts | 3 + .../API/parameters/DeleteCompanyCardFeed.ts | 7 ++ .../API/parameters/SetCompanyCardFeedName.ts | 8 ++ .../SetCompanyCardTransactionLiability.ts | 7 ++ src/libs/API/parameters/index.ts | 3 + src/libs/API/types.ts | 6 + .../ModalStackNavigators/index.tsx | 4 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 6 +- src/libs/Navigation/linkingConfig/config.ts | 9 ++ src/libs/Navigation/types.ts | 9 ++ src/libs/actions/Policy/Policy.ts | 82 +++++++++++++ .../WorkspaceCompanyCardsPage.tsx | 51 ++++++++ ...kspaceCompanyCardsSettingsFeedNamePage.tsx | 110 +++++++++++++++++ .../WorkspaceCompanyCardsSettingsPage.tsx | 111 ++++++++++++++++++ ...yCardsSettingsTransactionLiabilityPage.tsx | 98 ++++++++++++++++ .../form/WorkspaceCompanyCardFeedName.ts | 18 +++ src/types/form/index.ts | 1 + src/types/onyx/CompanyCards.ts | 45 +++---- src/types/onyx/index.ts | 4 +- 25 files changed, 614 insertions(+), 30 deletions(-) create mode 100644 src/libs/API/parameters/DeleteCompanyCardFeed.ts create mode 100644 src/libs/API/parameters/SetCompanyCardFeedName.ts create mode 100644 src/libs/API/parameters/SetCompanyCardTransactionLiability.ts create mode 100644 src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx create mode 100644 src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx create mode 100644 src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsTransactionLiabilityPage.tsx create mode 100644 src/types/form/WorkspaceCompanyCardFeedName.ts diff --git a/src/CONST.ts b/src/CONST.ts index 175aa8cd3c16..ee5fcf1b3d35 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2330,6 +2330,12 @@ const CONST = { PAYPERUSE: 'monthly2018', }, }, + COMPANY_CARDS: { + DELETE_TRANSACTIONS: { + RESTRICT: 'corporate', + ALLOW: 'personal', + }, + }, REGEX: { SPECIAL_CHARS_WITHOUT_NEWLINE: /((?!\n)[()-\s\t])/g, DIGITS_AND_PLUS: /^\+?[0-9]*$/, diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 101656ae1ea1..4aa1869fc644 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -495,6 +495,8 @@ const ONYXKEYS = { WORKSPACE_RATE_AND_UNIT_FORM_DRAFT: 'workspaceRateAndUnitFormDraft', WORKSPACE_TAX_CUSTOM_NAME: 'workspaceTaxCustomName', WORKSPACE_TAX_CUSTOM_NAME_DRAFT: 'workspaceTaxCustomNameDraft', + WORKSPACE_COMPANY_CARD_FEED_NAME: 'workspaceCompanyCardFeedName', + WORKSPACE_COMPANY_CARD_FEED_NAME_DRAFT: 'workspaceCompanyCardFeedNameDraft', WORKSPACE_REPORT_FIELDS_FORM: 'workspaceReportFieldForm', WORKSPACE_REPORT_FIELDS_FORM_DRAFT: 'workspaceReportFieldFormDraft', POLICY_CREATE_DISTANCE_RATE_FORM: 'policyCreateDistanceRateForm', @@ -645,6 +647,7 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.WORKSPACE_TAG_FORM]: FormTypes.WorkspaceTagForm; [ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM]: FormTypes.WorkspaceRateAndUnitForm; [ONYXKEYS.FORMS.WORKSPACE_TAX_CUSTOM_NAME]: FormTypes.WorkspaceTaxCustomName; + [ONYXKEYS.FORMS.WORKSPACE_COMPANY_CARD_FEED_NAME]: FormTypes.WorkspaceCompanyCardFeedName; [ONYXKEYS.FORMS.WORKSPACE_REPORT_FIELDS_FORM]: FormTypes.WorkspaceReportFieldForm; [ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM]: FormTypes.CloseAccountForm; [ONYXKEYS.FORMS.PROFILE_SETTINGS_FORM]: FormTypes.ProfileSettingsForm; @@ -762,7 +765,7 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS]: OnyxTypes.PolicyConnectionSyncProgress; [ONYXKEYS.COLLECTION.SNAPSHOT]: OnyxTypes.SearchResults; [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END]: OnyxTypes.BillingGraceEndPeriod; - [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER]: OnyxTypes.CompanyCards; + [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER]: OnyxTypes.CardFeeds; [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS]: OnyxTypes.ExpensifyCardSettings; [ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST]: OnyxTypes.WorkspaceCardsList; [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 2db861121375..dcacf7ed34e5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -932,6 +932,18 @@ const ROUTES = { route: 'settings/workspaces/:policyID/company-cards', getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards` as const, }, + WORKSPACE_COMPANY_CARDS_SETTINGS: { + route: 'settings/workspaces/:policyID/company-cards/settings', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings` as const, + }, + WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME: { + route: 'settings/workspaces/:policyID/company-cards/settings/feed-name', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings/feed-name` as const, + }, + WORKSPACE_COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY: { + route: 'settings/workspaces/:policyID/company-cards/settings/transaction-liability', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings/transaction-liability` as const, + }, WORKSPACE_RULES: { route: 'settings/workspaces/:policyID/rules', getRoute: (policyID: string) => `settings/workspaces/${policyID}/rules` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 7ffca6889688..dfff6de0c20c 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -365,6 +365,9 @@ const SCREENS = { RATE_AND_UNIT_RATE: 'Workspace_RateAndUnit_Rate', RATE_AND_UNIT_UNIT: 'Workspace_RateAndUnit_Unit', COMPANY_CARDS: 'Workspace_CompanyCards', + COMPANY_CARDS_SETTINGS: 'Workspace_CompanyCards_Settings', + COMPANY_CARDS_SETTINGS_FEED_NAME: 'Workspace_CompanyCards_Settings_Feed_Name', + COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY: 'Workspace_CompanyCards_Settings_Transaction_Liability', EXPENSIFY_CARD: 'Workspace_ExpensifyCard', EXPENSIFY_CARD_DETAILS: 'Workspace_ExpensifyCard_Details', EXPENSIFY_CARD_LIMIT: 'Workspace_ExpensifyCard_Limit', diff --git a/src/languages/en.ts b/src/languages/en.ts index 0878b4875f29..58d134adcb57 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -18,6 +18,7 @@ import type { ChangePolicyParams, ChangeTypeParams, CharacterLimitParams, + CompanyCardFeedNameParams, ConfirmHoldExpenseParams, ConfirmThatParams, DateShouldBeAfterParams, @@ -2888,6 +2889,23 @@ export default { disableCardTitle: 'Disable Company Cards', disableCardPrompt: 'You can’t disable company cards because this feature is in use. Reach out to the Concierge for next steps.', disableCardButton: 'Chat with Concierge', + assignCard: 'Assign card', + cardFeedName: 'Card feed name', + cardFeedNameDescription: 'Give the card feed a unique name so you can tell it apart from the others.', + cardFeedTransaction: 'Delete transactions', + cardFeedTransactionDescription: 'Choose whether cardholders can delete card transactions. New transactions will follow these rules.', + cardFeedRestrictDeletingTransaction: 'Restrict deleting transactions', + cardFeedAllowDeletingTransaction: 'Allow deleting transactions', + removeCardFeed: 'Remove card feed', + removeCardFeedTitle: ({feedName}: CompanyCardFeedNameParams) => `Remove ${feedName} feed`, + removeCardFeedDescription: 'Are you sure you want to remove this card feed? This will unassign all cards.', + error: { + feedNameRequired: 'Card feed name is required.', + }, + corporate: 'Restrict deleting transactions', + personal: 'Allow deleting transactions', + setFeedNameDescription: 'Give the card feed a unique name so you can tell it apart from the others.', + setTransactionLiabilityDescription: 'Choose whether cardholders can delete card transactions. New transactions will follow these rules.', }, workflows: { title: 'Workflows', diff --git a/src/languages/es.ts b/src/languages/es.ts index 660ab88cb92c..aff5b1ae5d59 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -16,6 +16,7 @@ import type { ChangePolicyParams, ChangeTypeParams, CharacterLimitParams, + CompanyCardFeedNameParams, ConfirmHoldExpenseParams, ConfirmThatParams, DateShouldBeAfterParams, @@ -2934,6 +2935,23 @@ export default { disableCardTitle: 'Deshabilitar tarjetas de empresa', disableCardPrompt: 'No puedes deshabilitar las tarjetas de empresa porque esta función está en uso. Por favor, contacta a Concierge para los próximos pasos.', disableCardButton: 'Chatear con Concierge', + assignCard: 'Asignar tarjeta', + cardFeedName: 'Nombre del feed de tarjeta', + cardFeedNameDescription: 'Dale al feed de tarjeta un nombre único para que puedas distinguirlo de los demás.', + cardFeedTransaction: 'Eliminar transacciones', + cardFeedTransactionDescription: 'Elige si los titulares de tarjetas pueden eliminar transacciones de tarjetas. Las nuevas transacciones seguirán estas reglas.', + cardFeedRestrictDeletingTransaction: 'Restringir eliminación de transacciones', + cardFeedAllowDeletingTransaction: 'Permitir eliminación de transacciones', + removeCardFeed: 'Quitar la alimentación de tarjetas', + removeCardFeedTitle: ({feedName}: CompanyCardFeedNameParams) => `Eliminar el feed de ${feedName}`, + removeCardFeedDescription: '¿Estás seguro de que deseas eliminar esta fuente de tarjetas? Esto anulará la asignación de todas las tarjetas.', + error: { + feedNameRequired: 'Se requiere el nombre de la fuente de la tarjeta.', + }, + corporate: 'Restringir eliminación de transacciones', + personal: 'Permitir eliminación de transacciones', + setFeedNameDescription: 'Dale al feed de tarjeta un nombre único para que puedas distinguirlo de los demás.', + setTransactionLiabilityDescription: 'Elige si los titulares de tarjetas pueden eliminar transacciones de tarjetas. Las nuevas transacciones seguirán estas reglas.', }, distanceRates: { title: 'Tasas de distancia', diff --git a/src/languages/types.ts b/src/languages/types.ts index d1d44fdf9962..fb396a3f64ea 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -120,6 +120,8 @@ type PayerOwesAmountParams = {payer: string; amount: number | string; comment?: type PayerOwesParams = {payer: string}; +type CompanyCardFeedNameParams = {feedName: string}; + type PayerPaidAmountParams = {payer?: string; amount: number | string}; type ApprovedAmountParams = {amount: number | string}; @@ -372,6 +374,7 @@ export type { CharacterLimitParams, ConfirmHoldExpenseParams, ConfirmThatParams, + CompanyCardFeedNameParams, DateShouldBeAfterParams, DateShouldBeBeforeParams, DeleteActionParams, diff --git a/src/libs/API/parameters/DeleteCompanyCardFeed.ts b/src/libs/API/parameters/DeleteCompanyCardFeed.ts new file mode 100644 index 000000000000..aaf5a1c4ffc3 --- /dev/null +++ b/src/libs/API/parameters/DeleteCompanyCardFeed.ts @@ -0,0 +1,7 @@ +type DeleteCompanyCardFeed = { + authToken?: string | null; + policyID: string; + bankName: string; +}; + +export default DeleteCompanyCardFeed; diff --git a/src/libs/API/parameters/SetCompanyCardFeedName.ts b/src/libs/API/parameters/SetCompanyCardFeedName.ts new file mode 100644 index 000000000000..3db87f52bff2 --- /dev/null +++ b/src/libs/API/parameters/SetCompanyCardFeedName.ts @@ -0,0 +1,8 @@ +type SetCompanyCardFeedName = { + authToken?: string | null; + policyID: string; + bankName: string; + userDefinedName: string; +}; + +export default SetCompanyCardFeedName; diff --git a/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts b/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts new file mode 100644 index 000000000000..277a9d9bbdbf --- /dev/null +++ b/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts @@ -0,0 +1,7 @@ +type SetCompanyCardTransactionLiability = { + authToken?: string | null; + bankName: string; + liabilityType: string; +}; + +export default SetCompanyCardTransactionLiability; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 7083823d871e..c0f39ba35f51 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -286,3 +286,6 @@ export type {default as EnablePolicyCompanyCardsParams} from './EnablePolicyComp export type {default as ToggleCardContinuousReconciliationParams} from './ToggleCardContinuousReconciliationParams'; export type {default as UpdateExpensifyCardLimitTypeParams} from './UpdateExpensifyCardLimitTypeParams'; export type {default as UpdateXeroGenericTypeParams} from './UpdateXeroGenericTypeParams'; +export type {default as SetCompanyCardFeedName} from './SetCompanyCardFeedName'; +export type {default as DeleteCompanyCardFeed} from './DeleteCompanyCardFeed'; +export type {default as SetCompanyCardTransactionLiability} from './SetCompanyCardTransactionLiability'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 4e55de0640b3..baf3284c418b 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -345,6 +345,9 @@ const WRITE_COMMANDS = { UPDATE_XERO_IMPORT_TAX_RATES: 'UpdateXeroImportTaxRates', UPDATE_XERO_TENANT_ID: 'UpdateXeroTenantID', UPDATE_XERO_MAPPING: 'UpdateXeroMappings', + SET_COMPANY_CARD_FEED_NAME: 'SetFeedName', + DELETE_COMPANY_CARD_FEED: 'RemoveFeed', + SET_COMPANY_CARD_TRANSACTION_LIABILITY: 'SetFeedTransactionLiability', } as const; type WriteCommand = ValueOf; @@ -401,6 +404,9 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_STATUS]: Parameters.UpdateStatusParams; [WRITE_COMMANDS.CLEAR_STATUS]: null; [WRITE_COMMANDS.UPDATE_PERSONAL_DETAILS_FOR_WALLET]: Parameters.UpdatePersonalDetailsForWalletParams; + [WRITE_COMMANDS.SET_COMPANY_CARD_FEED_NAME]: Parameters.SetCompanyCardFeedName; + [WRITE_COMMANDS.DELETE_COMPANY_CARD_FEED]: Parameters.DeleteCompanyCardFeed; + [WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY]: Parameters.SetCompanyCardTransactionLiability; [WRITE_COMMANDS.VERIFY_IDENTITY]: Parameters.VerifyIdentityParams; [WRITE_COMMANDS.ACCEPT_WALLET_TERMS]: Parameters.AcceptWalletTermsParams; [WRITE_COMMANDS.ANSWER_QUESTIONS_FOR_WALLET]: Parameters.AnswerQuestionsForWalletParams; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 40e8d5a106ef..1a96cbbb62ab 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -430,6 +430,10 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/expensifyCard/WorkspaceEditCardNamePage').default, [SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT]: () => require('../../../../pages/workspace/expensifyCard/WorkspaceEditCardLimitPage').default, [SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT_TYPE]: () => require('../../../../pages/workspace/expensifyCard/WorkspaceEditCardLimitTypePage').default, + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS]: () => require('../../../../pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage').default, + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: () => require('../../../../pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage').default, + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY]: () => + require('../../../../pages/workspace/companyCards/WorkspaceCompanyCardsSettingsTransactionLiabilityPage').default, [SCREENS.SETTINGS.SAVE_THE_WORLD]: () => require('../../../../pages/TeachersUnite/SaveTheWorldPage').default, [SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_PAYMENT_CURRENCY]: () => require('../../../../pages/settings/PaymentCard/ChangeCurrency').default, [SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_BILLING_CURRENCY]: () => require('../../../../pages/settings/Subscription/PaymentCard/ChangeBillingCurrency').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index c7939268fa12..29c0e9e97f5c 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -160,7 +160,11 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.REPORT_FIELDS_EDIT_INITIAL_VALUE, ], [SCREENS.WORKSPACE.INVOICES]: [SCREENS.WORKSPACE.INVOICES_COMPANY_NAME, SCREENS.WORKSPACE.INVOICES_COMPANY_WEBSITE], - [SCREENS.WORKSPACE.COMPANY_CARDS]: [], + [SCREENS.WORKSPACE.COMPANY_CARDS]: [ + SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS, + SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME, + SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY, + ], [SCREENS.WORKSPACE.EXPENSIFY_CARD]: [ SCREENS.WORKSPACE.EXPENSIFY_CARD_ISSUE_NEW, SCREENS.WORKSPACE.EXPENSIFY_CARD_BANK_ACCOUNT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 43e7ece014eb..9ef58e64d6b9 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -505,6 +505,15 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.EXPENSIFY_CARD_SETTINGS_ACCOUNT]: { path: ROUTES.WORKSPACE_EXPENSIFY_CARD_SETTINGS_ACCOUNT.route, }, + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS]: { + path: ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS.route, + }, + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: { + path: ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME.route, + }, + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY]: { + path: ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY.route, + }, [SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS]: { path: ROUTES.WORKSPACE_EXPENSIFY_CARD_DETAILS.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 40b3d3fb335d..4eb11c302b61 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -686,6 +686,15 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.EXPENSIFY_CARD_SETTINGS_FREQUENCY]: { policyID: string; }; + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS]: { + policyID: string; + }; + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: { + policyID: string; + }; + [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_TRANSACTION_LIABILITY]: { + policyID: string; + }; [SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS]: { policyID: string; cardID: string; diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 1299129d808e..746b6379a28d 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -3715,6 +3715,85 @@ function getAdminPoliciesConnectedToNetSuite(): Policy[] { return Object.values(allPolicies ?? {}).filter((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.netsuite); } +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: { + companyCardNicknames: { + [bankName]: userDefinedName, + }, + }, + }, + ], + }; + + const parameters = { + authToken, + policyID, + bankName, + userDefinedName, + }; + + API.write(WRITE_COMMANDS.SET_COMPANY_CARD_FEED_NAME, parameters, onyxData); +} + +function setWorkspaceCompanyCardTransactionLiability(workspaceAccountID: number, 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: { + companyCards: { + [bankName]: {liabilityType}, + }, + }, + }, + ], + }; + + const parameters = { + authToken, + 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: { + companyCards: { + [bankName]: null, + }, + companyCardNicknames: { + [bankName]: null, + }, + }, + }, + ], + }; + + const parameters = { + authToken, + policyID, + bankName, + }; + + API.write(WRITE_COMMANDS.DELETE_COMPANY_CARD_FEED, parameters, onyxData); +} + function clearAllPolicies() { if (!allPolicies) { return; @@ -3806,6 +3885,9 @@ export { setPolicyMaxExpenseAge, setPolicyBillableMode, setWorkspaceEReceiptsEnabled, + setWorkspaceCompanyCardFeedName, + deleteWorkspaceCompanyCardFeed, + setWorkspaceCompanyCardTransactionLiability, }; export type {NewCustomUnit}; diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx index 1945cf99a001..fdce6690285e 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx @@ -1,14 +1,21 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; import {View} from 'react-native'; +// import Onyx from 'react-native-onyx'; +import Button from '@components/Button'; +import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import useLocalize from '@hooks/useLocalize'; +// import usePolicy from '@hooks/usePolicy'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; +import Navigation from '@navigation/Navigation'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections'; import CONST from '@src/CONST'; +// import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; type WorkspaceCompanyCardPageProps = StackScreenProps; @@ -17,6 +24,48 @@ function WorkspaceCompanyCardPage({route}: WorkspaceCompanyCardPageProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); + const policyID = route.params.policyID; + // const policy = usePolicy(policyID); + // const workspaceAccountID = policy?.workspaceAccountID ?? -1; + + // useEffect(() => { + // Onyx.set(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, { + // companyCards: { + // cdfbmo: { + // pending: false, + // asrEnabled: true, + // forceReimbursable: 'force_no', + // liabilityType: 'corporate', + // preferredPolicy: '', + // reportTitleFormat: '{report:card}{report:bank}{report:submit:from}{report:total}{report:enddate:MMMM}', + // statementPeriodEndDay: 'LAST_DAY_OF_MONTH', + // }, + // }, + // companyCardNicknames: { + // cdfbmo: 'BMO MasterCard', + // }, + // }); + // }, [workspaceAccountID]); + + const getHeaderButtons = () => ( + +