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

Swap from withPolicy to withPolicyConnections for Export Quickbooks pages #40713

Merged
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
Copy link
Contributor

Choose a reason for hiding this comment

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

We defined defaultCards. Are those drafts only (testing only) or meant to stay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - i think creditCards should be used in the bottom menu item(currently not available) and here should be just used defaults based on the high level doc

Copy link
Contributor

Choose a reason for hiding this comment

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

If creditCards exist on quickbooksOnline.data then I would assume we want to use those

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're discussing this one here and if so, we'll handle it in a follow-up.

Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);

Expand All @@ -46,12 +44,7 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps
],
[translate],
);
const cards = useMemo<Card[]>(() => {
if (creditCards?.length) {
return creditCards;
}
return isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards;
}, [creditCards, isLocationEnabled, defaultCards]);
const cards = useMemo<Card[]>(() => (isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards), [isLocationEnabled, defaultCards]);

const data = useMemo<CardListItem[]>(
() =>
Expand Down Expand Up @@ -106,4 +99,4 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps

QuickbooksCompanyCardExpenseAccountSelectPage.displayName = 'QuickbooksCompanyCardExpenseAccountSelectPage';

export default withPolicy(QuickbooksCompanyCardExpenseAccountSelectPage);
export default withPolicyConnections(QuickbooksCompanyCardExpenseAccountSelectPage);
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -125,4 +125,4 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) {

QuickbooksExportConfigurationPage.displayName = 'QuickbooksExportConfigurationPage';

export default withPolicy(QuickbooksExportConfigurationPage);
export default withPolicyConnections(QuickbooksExportConfigurationPage);
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -69,4 +69,4 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) {

QuickbooksExportDateSelectPage.displayName = 'QuickbooksExportDateSelectPage';

export default withPolicy(QuickbooksExportDateSelectPage);
export default withPolicyConnections(QuickbooksExportDateSelectPage);
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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(
Expand Down Expand Up @@ -81,4 +71,4 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) {

QuickbooksExportInvoiceAccountSelectPage.displayName = 'QuickbooksExportInvoiceAccountSelectPage';

export default withPolicy(QuickbooksExportInvoiceAccountSelectPage);
export default withPolicyConnections(QuickbooksExportInvoiceAccountSelectPage);
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ 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';

// 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;
Expand All @@ -38,7 +29,7 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps
const {exportEntity, exportAccount} = policy?.connections?.quickbooksOnline?.config ?? {};

const data: CardListItem[] = useMemo(() => {
let result;
let result: Account[] | [];
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
switch (exportEntity) {
case CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK:
result = bankAccounts ?? [];
Expand All @@ -50,10 +41,10 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps
result = journalEntryAccounts ?? [];
break;
default:
result = draft;
result = [];
}

return (draft ?? result)?.map((card) => ({
return result?.map((card) => ({
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
value: card.name,
text: card.name,
keyForList: card.name,
Expand Down Expand Up @@ -96,4 +87,4 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps

QuickbooksOutOfPocketExpenseAccountSelectPage.displayName = 'QuickbooksOutOfPocketExpenseAccountSelectPage';

export default withPolicy(QuickbooksOutOfPocketExpenseAccountSelectPage);
export default withPolicyConnections(QuickbooksOutOfPocketExpenseAccountSelectPage);
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -76,4 +76,4 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps

QuickbooksOutOfPocketExpenseConfigurationPage.displayName = 'QuickbooksExportOutOfPocketExpensesPage';

export default withPolicy(QuickbooksOutOfPocketExpenseConfigurationPage);
export default withPolicyConnections(QuickbooksOutOfPocketExpenseConfigurationPage);
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -111,4 +111,4 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps)

QuickbooksOutOfPocketExpenseEntitySelectPage.displayName = 'QuickbooksOutOfPocketExpenseEntitySelectPage';

export default withPolicy(QuickbooksOutOfPocketExpenseEntitySelectPage);
export default withPolicyConnections(QuickbooksOutOfPocketExpenseEntitySelectPage);
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,11 @@ 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';

// 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;
};
Expand All @@ -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<CardListItem[]>((vendors, vendor) => {
exporters?.reduce<CardListItem[]>((vendors, vendor) => {
if (vendor.email) {
vendors.push({
value: vendor.email,
Expand All @@ -51,7 +41,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) {
}
return vendors;
}, []),
[result, exporter],
[exporter, exporters],
);

const onSelectRow = useCallback(
Expand Down Expand Up @@ -92,4 +82,4 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) {

QuickBooksExportPreferredExporterPage.displayName = 'QuickBooksExportPreferredExporterPage';

export default withPolicy(QuickBooksExportPreferredExporterPage);
export default withPolicyConnections(QuickBooksExportPreferredExporterPage);
1 change: 1 addition & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,5 @@ export type {
PolicyConnectionSyncProgress,
Connections,
ConnectionName,
Account,
};
Loading