Skip to content

Commit a23be73

Browse files
committed
Revert changes different from the workflows page.
1 parent b9aed8e commit a23be73

20 files changed

Lines changed: 154 additions & 423 deletions

src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import React, {useEffect, useMemo} from 'react';
2-
import {useSharedValue} from 'react-native-reanimated';
3-
import Accordion from '@components/Accordion';
1+
import React, {useMemo} from 'react';
42
import ConnectionLayout from '@components/ConnectionLayout';
53
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
64
import OfflineWithFeedback from '@components/OfflineWithFeedback';
@@ -35,11 +33,6 @@ function SageIntacctAdvancedPage({policy}: WithPolicyProps) {
3533

3634
const {importEmployees, autoSync, sync, pendingFields, errorFields} = policy?.connections?.intacct?.config ?? {};
3735
const {data, config} = policy?.connections?.intacct ?? {};
38-
const isAccordionExpanded = useSharedValue(!!sync?.syncReimbursedReports);
39-
40-
useEffect(() => {
41-
isAccordionExpanded.set(!!sync?.syncReimbursedReports);
42-
}, [isAccordionExpanded, sync?.syncReimbursedReports]);
4336

4437
const toggleSections = useMemo(
4538
() => [
@@ -120,23 +113,20 @@ function SageIntacctAdvancedPage({policy}: WithPolicyProps) {
120113
/>
121114
))}
122115

123-
<Accordion
124-
isExpanded={isAccordionExpanded}
125-
style={styles.overflowHidden}
126-
>
116+
{!!sync?.syncReimbursedReports && (
127117
<OfflineWithFeedback
128118
key={translate('workspace.sageIntacct.paymentAccount')}
129119
pendingAction={settingsPendingAction([CONST.SAGE_INTACCT_CONFIG.REIMBURSEMENT_ACCOUNT_ID], pendingFields)}
130120
>
131121
<MenuItemWithTopDescription
132-
title={getReimbursedAccountName(data?.bankAccounts ?? [], sync?.reimbursementAccountID) ?? translate('workspace.sageIntacct.notConfigured')}
122+
title={getReimbursedAccountName(data?.bankAccounts ?? [], sync.reimbursementAccountID) ?? translate('workspace.sageIntacct.notConfigured')}
133123
description={translate('workspace.sageIntacct.paymentAccount')}
134124
shouldShowRightIcon
135125
onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PAYMENT_ACCOUNT.getRoute(policyID))}
136126
brickRoadIndicator={areSettingsInErrorFields([CONST.SAGE_INTACCT_CONFIG.REIMBURSEMENT_ACCOUNT_ID], errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
137127
/>
138128
</OfflineWithFeedback>
139-
</Accordion>
129+
)}
140130
</ConnectionLayout>
141131
);
142132
}

src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx

Lines changed: 29 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React from 'react';
2-
import {useSharedValue} from 'react-native-reanimated';
3-
import Accordion from '@components/Accordion';
42
import ConnectionLayout from '@components/ConnectionLayout';
53
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
64
import OfflineWithFeedback from '@components/OfflineWithFeedback';
@@ -9,9 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
97
import * as ErrorUtils from '@libs/ErrorUtils';
108
import Navigation from '@libs/Navigation/Navigation';
119
import {areSettingsInErrorFields, getSageIntacctNonReimbursableActiveDefaultVendor, settingsPendingAction} from '@libs/PolicyUtils';
12-
import type {AccordionItem, MenuItemWithSubscribedSettings, ToggleItem} from '@pages/workspace/accounting/intacct/types';
13-
import {MenuItem} from '@pages/workspace/accounting/intacct/types';
14-
import {shouldHideCustomFormIDOptions} from '@pages/workspace/accounting/netsuite/utils';
10+
import type {MenuItem, ToggleItem} from '@pages/workspace/accounting/intacct/types';
1511
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
1612
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
1713
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
@@ -21,6 +17,8 @@ import CONST from '@src/CONST';
2117
import ROUTES from '@src/ROUTES';
2218
import {getDefaultVendorName} from './utils';
2319

20+
type MenuItemWithSubscribedSettings = Pick<MenuItem, 'type' | 'description' | 'title' | 'onPress' | 'shouldHide'> & {subscribedSettings?: string[]};
21+
2422
type ToggleItemWithKey = ToggleItem & {key: string};
2523

2624
function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyConnectionsProps) {
@@ -31,31 +29,8 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyConnectionsP
3129

3230
const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy);
3331
const defaultVendorName = getDefaultVendorName(activeDefaultVendor, intacctData?.vendors);
34-
const shouldExpand = useSharedValue(
35-
!(
36-
!config?.export.nonReimbursable ||
37-
(config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && !config?.export.nonReimbursableCreditCardChargeDefaultVendor)
38-
),
39-
);
4032

41-
const renderDefault = (item: MenuItemWithSubscribedSettings) => {
42-
return (
43-
<OfflineWithFeedback
44-
key={item.description}
45-
pendingAction={settingsPendingAction(item.subscribedSettings, config?.pendingFields)}
46-
>
47-
<MenuItemWithTopDescription
48-
title={item.title}
49-
description={item.description}
50-
shouldShowRightIcon
51-
onPress={item?.onPress}
52-
brickRoadIndicator={areSettingsInErrorFields(item.subscribedSettings, config?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
53-
/>
54-
</OfflineWithFeedback>
55-
);
56-
};
57-
58-
const menuItems: Array<MenuItemWithSubscribedSettings | ToggleItemWithKey | AccordionItem> = [
33+
const menuItems: Array<MenuItemWithSubscribedSettings | ToggleItemWithKey> = [
5934
{
6035
type: 'menuitem',
6136
title: config?.export.nonReimbursable
@@ -87,36 +62,27 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyConnectionsP
8762
onToggle: (enabled) => {
8863
const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? '' : '';
8964
updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor, config?.export.nonReimbursableCreditCardChargeDefaultVendor);
90-
shouldExpand.set(enabled);
9165
},
9266
onCloseError: () => Policy.clearSageIntacctErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR),
9367
pendingAction: settingsPendingAction([CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR], config?.pendingFields),
9468
errors: ErrorUtils.getLatestErrorField(config, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR),
9569
shouldHide: config?.export.nonReimbursable !== CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE,
9670
},
9771
{
98-
type: 'accordion',
99-
children: [
100-
{
101-
type: 'menuitem',
102-
title: defaultVendorName && defaultVendorName !== '' ? defaultVendorName : translate('workspace.sageIntacct.notConfigured'),
103-
description: translate('workspace.sageIntacct.defaultVendor'),
104-
onPress: () => {
105-
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE.toLowerCase()));
106-
},
107-
subscribedSettings: [
108-
config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL
109-
? CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR
110-
: CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR,
111-
],
112-
shouldHide:
113-
!config?.export.nonReimbursable ||
114-
(config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE &&
115-
!config?.export.nonReimbursableCreditCardChargeDefaultVendor),
116-
},
72+
type: 'menuitem',
73+
title: defaultVendorName && defaultVendorName !== '' ? defaultVendorName : translate('workspace.sageIntacct.notConfigured'),
74+
description: translate('workspace.sageIntacct.defaultVendor'),
75+
onPress: () => {
76+
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE.toLowerCase()));
77+
},
78+
subscribedSettings: [
79+
config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL
80+
? CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR
81+
: CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR,
11782
],
118-
shouldHide: false,
119-
shouldExpand,
83+
shouldHide:
84+
!config?.export.nonReimbursable ||
85+
(config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && !config?.export.nonReimbursableCreditCardChargeDefaultVendor),
12086
},
12187
];
12288

@@ -148,17 +114,21 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyConnectionsP
148114
wrapperStyle={[styles.mv3, styles.ph5]}
149115
/>
150116
);
151-
case 'accordion':
117+
default:
152118
return (
153-
<Accordion
154-
isExpanded={item.shouldExpand}
155-
style={styles.overflowHidden}
119+
<OfflineWithFeedback
120+
key={item.description}
121+
pendingAction={settingsPendingAction(item.subscribedSettings, config?.pendingFields)}
156122
>
157-
{item.children.map((child) => renderDefault(child))}
158-
</Accordion>
123+
<MenuItemWithTopDescription
124+
title={item.title}
125+
description={item.description}
126+
shouldShowRightIcon
127+
onPress={item?.onPress}
128+
brickRoadIndicator={areSettingsInErrorFields(item.subscribedSettings, config?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
129+
/>
130+
</OfflineWithFeedback>
159131
);
160-
default:
161-
return renderDefault(item);
162132
}
163133
})}
164134
</ConnectionLayout>

src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React from 'react';
2-
import {useSharedValue} from 'react-native-reanimated';
3-
import Accordion from '@components/Accordion';
42
import ConnectionLayout from '@components/ConnectionLayout';
53
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
64
import OfflineWithFeedback from '@components/OfflineWithFeedback';
@@ -9,7 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
97
import * as ErrorUtils from '@libs/ErrorUtils';
108
import Navigation from '@libs/Navigation/Navigation';
119
import {areSettingsInErrorFields, settingsPendingAction} from '@libs/PolicyUtils';
12-
import type {AccordionItem, MenuItemWithSubscribedSettings, ToggleItem} from '@pages/workspace/accounting/intacct/types';
10+
import type {MenuItem, ToggleItem} from '@pages/workspace/accounting/intacct/types';
1311
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
1412
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
1513
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
@@ -19,6 +17,8 @@ import CONST from '@src/CONST';
1917
import ROUTES from '@src/ROUTES';
2018
import {getDefaultVendorName} from './utils';
2119

20+
type MenuItemWithSubscribedSettings = Pick<MenuItem, 'type' | 'description' | 'title' | 'onPress' | 'shouldHide'> & {subscribedSettings?: string[]};
21+
2222
type ToggleItemWithKey = ToggleItem & {key: string};
2323

2424
function SageIntacctReimbursableExpensesPage({policy}: WithPolicyConnectionsProps) {
@@ -30,24 +30,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyConnectionsProp
3030

3131
const defaultVendorName = getDefaultVendorName(reimbursableExpenseReportDefaultVendor, intacctData?.vendors);
3232

33-
const shouldExpand = useSharedValue(!(reimbursable !== CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT || !reimbursableExpenseReportDefaultVendor));
34-
const renderDefault = (item: MenuItemWithSubscribedSettings) => {
35-
return (
36-
<OfflineWithFeedback
37-
key={item.description}
38-
pendingAction={settingsPendingAction(item.subscribedSettings, config?.pendingFields)}
39-
>
40-
<MenuItemWithTopDescription
41-
title={item.title}
42-
description={item.description}
43-
shouldShowRightIcon
44-
onPress={item?.onPress}
45-
brickRoadIndicator={areSettingsInErrorFields(item.subscribedSettings, config?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
46-
/>
47-
</OfflineWithFeedback>
48-
);
49-
};
50-
const menuItems: Array<(MenuItemWithSubscribedSettings | ToggleItemWithKey) | AccordionItem> = [
33+
const menuItems: Array<MenuItemWithSubscribedSettings | ToggleItemWithKey> = [
5134
{
5235
type: 'menuitem',
5336
title: reimbursable ? translate(`workspace.sageIntacct.reimbursableExpenses.values.${reimbursable}`) : translate('workspace.sageIntacct.notConfigured'),
@@ -67,29 +50,21 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyConnectionsProp
6750
onToggle: (enabled) => {
6851
const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? '' : '';
6952
updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor, config?.export.reimbursableExpenseReportDefaultVendor);
70-
shouldExpand.set(enabled);
7153
},
7254
onCloseError: () => Policy.clearSageIntacctErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR),
7355
pendingAction: settingsPendingAction([CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR], config?.pendingFields),
7456
errors: ErrorUtils.getLatestErrorField(config, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR),
7557
shouldHide: reimbursable !== CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT,
7658
},
7759
{
78-
type: 'accordion',
79-
children: [
80-
{
81-
type: 'menuitem',
82-
title: defaultVendorName && defaultVendorName !== '' ? defaultVendorName : translate('workspace.sageIntacct.notConfigured'),
83-
description: translate('workspace.sageIntacct.defaultVendor'),
84-
onPress: () => {
85-
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE));
86-
},
87-
subscribedSettings: [CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR],
88-
shouldHide: reimbursable !== CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT || !reimbursableExpenseReportDefaultVendor,
89-
},
90-
],
91-
shouldHide: false,
92-
shouldExpand: shouldExpand,
60+
type: 'menuitem',
61+
title: defaultVendorName && defaultVendorName !== '' ? defaultVendorName : translate('workspace.sageIntacct.notConfigured'),
62+
description: translate('workspace.sageIntacct.defaultVendor'),
63+
onPress: () => {
64+
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE));
65+
},
66+
subscribedSettings: [CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR],
67+
shouldHide: reimbursable !== CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT || !reimbursableExpenseReportDefaultVendor,
9368
},
9469
];
9570

@@ -121,17 +96,21 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyConnectionsProp
12196
wrapperStyle={[styles.mv3, styles.ph5]}
12297
/>
12398
);
124-
case 'accordion':
99+
default:
125100
return (
126-
<Accordion
127-
isExpanded={item.shouldExpand}
128-
style={styles.overflowHidden}
101+
<OfflineWithFeedback
102+
key={item.description}
103+
pendingAction={settingsPendingAction(item.subscribedSettings, config?.pendingFields)}
129104
>
130-
{item.children.map((child) => renderDefault(child))}
131-
</Accordion>
105+
<MenuItemWithTopDescription
106+
title={item.title}
107+
description={item.description}
108+
shouldShowRightIcon
109+
onPress={item?.onPress}
110+
brickRoadIndicator={areSettingsInErrorFields(item.subscribedSettings, config?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
111+
/>
112+
</OfflineWithFeedback>
132113
);
133-
default:
134-
return renderDefault(item);
135114
}
136115
})}
137116
</ConnectionLayout>

0 commit comments

Comments
 (0)