Skip to content

Commit

Permalink
revert: unsupported connection name
Browse files Browse the repository at this point in the history
  • Loading branch information
mkzie2 committed Oct 16, 2024
1 parent 25c00a1 commit 908e6d2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2435,11 +2435,6 @@ const CONST = {
},
SYNC_STAGE_TIMEOUT_MINUTES: 20,
},
UNSUPPORTED_CONNECTIONS: {
NAME: {
QBO: 'quickbooksDesktop',
},
},
ACCESS_VARIANTS: {
PAID: 'paid',
ADMIN: 'admin',
Expand Down
11 changes: 4 additions & 7 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,13 +985,10 @@ function hasUnsupportedIntegration(policy: Policy | undefined, accountingIntegra
return !(accountingIntegrations ?? Object.values(CONST.POLICY.CONNECTIONS.NAME)).some((integration) => !!policy?.connections?.[integration]);
}

function getCurrentConnectionName(policy: Policy | undefined, includeUnsupportedConnection = false): string | undefined {
const accountingIntegrations: string[] = [...Object.values(CONST.POLICY.CONNECTIONS.NAME)];
if (includeUnsupportedConnection) {
accountingIntegrations.push(...Object.values(CONST.POLICY.UNSUPPORTED_CONNECTIONS.NAME));
}
const connectionKey = accountingIntegrations.find((integration) => policy?.connections && integration in policy.connections);
return connectionKey ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionKey as keyof typeof CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY] : undefined;
function getCurrentConnectionName(policy: Policy | undefined): string | undefined {
const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME);
const connectionKey = accountingIntegrations.find((integration) => !!policy?.connections?.[integration]);
return connectionKey ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionKey] : undefined;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = PolicyUtils.hasSyncError(policy, isSyncInProgress);
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy, true);
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy);

const canSelectMultiple = shouldUseNarrowLayout ? selectionMode?.isEnabled : true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function WorkspaceReportFieldsPage({
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = PolicyUtils.hasSyncError(policy, isSyncInProgress);
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy, true);
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy);

const canSelectMultiple = !hasAccountingConnections && (isSmallScreenWidth ? selectionMode?.isEnabled : true);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = PolicyUtils.hasSyncError(policy, isSyncInProgress);
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy, true);
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy);
const [policyTagLists, isMultiLevelTags] = useMemo(() => [PolicyUtils.getTagLists(policyTags), PolicyUtils.isMultiLevelTags(policyTags)], [policyTags]);
const canSelectMultiple = !isMultiLevelTags && (shouldUseNarrowLayout ? selectionMode?.isEnabled : true);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function WorkspaceTaxesPage({
const hasSyncError = PolicyUtils.hasSyncError(policy, isSyncInProgress);

const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy, true);
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy);
const canSelectMultiple = shouldUseNarrowLayout ? selectionMode?.isEnabled : true;

const fetchTaxes = useCallback(() => {
Expand Down

0 comments on commit 908e6d2

Please sign in to comment.