From 730597012b9e180418e1d6d544d399710414fcd6 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Mon, 22 Apr 2024 19:41:42 +0300 Subject: [PATCH 1/3] Swap from withPolicy to withPolicyConnections for Export Quickbooks pages --- .../export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx | 4 ++-- .../qbo/export/QuickbooksExportConfigurationPage.tsx | 4 ++-- .../accounting/qbo/export/QuickbooksExportDateSelectPage.tsx | 4 ++-- .../qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx | 4 ++-- .../export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx | 4 ++-- .../export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx | 4 ++-- .../export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx | 4 ++-- .../export/QuickbooksPreferredExporterConfigurationPage.tsx | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index d105a3c73dde..f6ebba154e95 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -13,8 +13,8 @@ import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -106,4 +106,4 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps QuickbooksCompanyCardExpenseAccountSelectPage.displayName = 'QuickbooksCompanyCardExpenseAccountSelectPage'; -export default withPolicy(QuickbooksCompanyCardExpenseAccountSelectPage); +export default withPolicyConnections(QuickbooksCompanyCardExpenseAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 429e7afddd32..cb025096edaf 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -13,8 +13,8 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -125,4 +125,4 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { QuickbooksExportConfigurationPage.displayName = 'QuickbooksExportConfigurationPage'; -export default withPolicy(QuickbooksExportConfigurationPage); +export default withPolicyConnections(QuickbooksExportConfigurationPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx index 5db9126f1860..74509c9ec20a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx @@ -12,8 +12,8 @@ import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -69,4 +69,4 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { QuickbooksExportDateSelectPage.displayName = 'QuickbooksExportDateSelectPage'; -export default withPolicy(QuickbooksExportDateSelectPage); +export default withPolicyConnections(QuickbooksExportDateSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index de47ca90527e..7b3013a8bb95 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -11,8 +11,8 @@ import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -81,4 +81,4 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { QuickbooksExportInvoiceAccountSelectPage.displayName = 'QuickbooksExportInvoiceAccountSelectPage'; -export default withPolicy(QuickbooksExportInvoiceAccountSelectPage); +export default withPolicyConnections(QuickbooksExportInvoiceAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 659e42556fcc..536c620be572 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -11,8 +11,8 @@ import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -96,4 +96,4 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps QuickbooksOutOfPocketExpenseAccountSelectPage.displayName = 'QuickbooksOutOfPocketExpenseAccountSelectPage'; -export default withPolicy(QuickbooksOutOfPocketExpenseAccountSelectPage); +export default withPolicyConnections(QuickbooksOutOfPocketExpenseAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 8ee94e675141..0dffef7474ce 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -10,8 +10,8 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -76,4 +76,4 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps QuickbooksOutOfPocketExpenseConfigurationPage.displayName = 'QuickbooksExportOutOfPocketExpensesPage'; -export default withPolicy(QuickbooksOutOfPocketExpenseConfigurationPage); +export default withPolicyConnections(QuickbooksOutOfPocketExpenseConfigurationPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index ee191a9575ca..d0007d23ed5a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -14,8 +14,8 @@ import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -111,4 +111,4 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) QuickbooksOutOfPocketExpenseEntitySelectPage.displayName = 'QuickbooksOutOfPocketExpenseEntitySelectPage'; -export default withPolicy(QuickbooksOutOfPocketExpenseEntitySelectPage); +export default withPolicyConnections(QuickbooksOutOfPocketExpenseEntitySelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 5bad9caca706..05f40d6ef48f 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -12,8 +12,8 @@ import {getAdminEmployees} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -92,4 +92,4 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { QuickBooksExportPreferredExporterPage.displayName = 'QuickBooksExportPreferredExporterPage'; -export default withPolicy(QuickBooksExportPreferredExporterPage); +export default withPolicyConnections(QuickBooksExportPreferredExporterPage); From 534a54fa493e530c32398bdb019b0a02e0c203d9 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 23 Apr 2024 09:55:13 +0300 Subject: [PATCH 2/3] remove drafts --- ...booksCompanyCardExpenseAccountSelectPage.tsx | 9 +-------- ...QuickbooksExportInvoiceAccountSelectPage.tsx | 16 +++------------- ...booksOutOfPocketExpenseAccountSelectPage.tsx | 17 ++++------------- ...kbooksPreferredExporterConfigurationPage.tsx | 14 ++------------ src/types/onyx/Policy.ts | 1 + 5 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index f6ebba154e95..d0f7b42d5f20 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -27,8 +27,6 @@ type Card = {name: string}; function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; - const {exportCompanyCard, syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); @@ -46,12 +44,7 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps ], [translate], ); - const cards = useMemo(() => { - if (creditCards?.length) { - return creditCards; - } - return isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards; - }, [creditCards, isLocationEnabled, defaultCards]); + const cards = useMemo(() => (isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards), [isLocationEnabled, defaultCards]); const data = useMemo( () => diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index 7b3013a8bb95..23763c5b9948 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -25,27 +25,17 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {accountsReceivable} = policy?.connections?.quickbooksOnline?.data ?? {}; const {exportInvoice} = policy?.connections?.quickbooksOnline?.config ?? {}; - // TODO - should be removed after API fully working - const draft = [ - { - name: translate(`workspace.qbo.receivable`), - }, - { - name: translate(`workspace.qbo.archive`), - }, - ]; - const result = accountsReceivable?.length ? accountsReceivable : draft; const policyID = policy?.id ?? ''; const data: CardListItem[] = useMemo( () => - result?.map((account) => ({ + accountsReceivable?.map((account) => ({ value: account.name, text: account.name, keyForList: account.name, isSelected: account.name === exportInvoice, - })), - [exportInvoice, result], + })) ?? [], + [exportInvoice, accountsReceivable], ); const onSelectRow = useCallback( diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 536c620be572..538a8600e19f 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -15,16 +15,7 @@ import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; - -// TODO - should be removed after API fully working -const draft = [ - { - name: 'Accounts Payable (A/P)', - }, - { - name: 'Payroll Accounts', - }, -]; +import type {Account} from '@src/types/onyx/Policy'; type CardListItem = ListItem & { value: string; @@ -38,7 +29,7 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps const {exportEntity, exportAccount} = policy?.connections?.quickbooksOnline?.config ?? {}; const data: CardListItem[] = useMemo(() => { - let result; + let result: Account[] | []; switch (exportEntity) { case CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK: result = bankAccounts ?? []; @@ -50,10 +41,10 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps result = journalEntryAccounts ?? []; break; default: - result = draft; + result = []; } - return (draft ?? result)?.map((card) => ({ + return result?.map((card) => ({ value: card.name, text: card.name, keyForList: card.name, diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 05f40d6ef48f..a3d29b73427c 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -17,15 +17,6 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -// TODO - should be removed after API fully working -const draft = [ - {name: '+14153166423@expensify.sms', currency: 'USD', id: '94', email: '+14153166423@expensify.sms'}, - {name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: 'alberto@expensify213.com'}, - {name: 'Admin Test', currency: 'USD', id: '119', email: 'admin@qbocard.com'}, - {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, - {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, -]; - type CardListItem = ListItem & { value: string; }; @@ -35,12 +26,11 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {exporter} = policy?.connections?.quickbooksOnline?.config ?? {}; const exporters = getAdminEmployees(policy); - const result = exporters?.length ? exporters : draft; const policyID = policy?.id ?? ''; const data: CardListItem[] = useMemo( () => - result.reduce((vendors, vendor) => { + exporters?.reduce((vendors, vendor) => { if (vendor.email) { vendors.push({ value: vendor.email, @@ -51,7 +41,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { } return vendors; }, []), - [result, exporter], + [exporter, exporters], ); const onSelectRow = useCallback( diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7d6bf83bcbf6..8a46485c6460 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -475,4 +475,5 @@ export type { PolicyConnectionSyncProgress, Connections, ConnectionName, + Account, }; From 0d03be43fd8b4895091f95a42871ff12b590a146 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 23 Apr 2024 16:24:19 +0300 Subject: [PATCH 3/3] updates --- ...QuickbooksOutOfPocketExpenseAccountSelectPage.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 538a8600e19f..f2f238e3d9b3 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -29,22 +29,22 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps const {exportEntity, exportAccount} = policy?.connections?.quickbooksOnline?.config ?? {}; const data: CardListItem[] = useMemo(() => { - let result: Account[] | []; + let accounts: Account[]; switch (exportEntity) { case CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK: - result = bankAccounts ?? []; + accounts = bankAccounts ?? []; break; case CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL: - result = accountsPayable ?? []; + accounts = accountsPayable ?? []; break; case CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY: - result = journalEntryAccounts ?? []; + accounts = journalEntryAccounts ?? []; break; default: - result = []; + accounts = []; } - return result?.map((card) => ({ + return accounts.map((card) => ({ value: card.name, text: card.name, keyForList: card.name,