Skip to content

Commit

Permalink
improve code redability
Browse files Browse the repository at this point in the history
  • Loading branch information
twilight2294 authored Nov 13, 2024
1 parent 06f1170 commit 4d1245b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) {
isSelected: accountingMethod === accountingMethodType,
}));

const pendingAction =
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields) ?? settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields);

const headerContent = useMemo(
() => (
<View>
Expand Down Expand Up @@ -70,10 +73,7 @@ function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) {
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID))}
connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE}
pendingAction={
settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields) ??
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields)
}
pendingAction={pendingAction}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function NetSuiteAutoSyncPage({policy, route}: WithPolicyConnectionsProps) {
const autoSyncConfig = policy?.connections?.netsuite?.config;
const policyID = route.params.policyID ?? '-1';
const accountingMethod = policy?.connections?.netsuite?.options?.config?.accountingMethod;
const pendingAction =
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields) ?? settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields);

return (
<AccessOrNotFoundWrapper
Expand All @@ -52,19 +54,11 @@ function NetSuiteAutoSyncPage({policy, route}: WithPolicyConnectionsProps) {
shouldPlaceSubtitleBelowSwitch
onCloseError={() => Policy.clearNetSuiteAutoSyncErrorField(policyID)}
onToggle={(isEnabled) => Connections.updateNetSuiteAutoSync(policyID, isEnabled)}
pendingAction={
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields) ??
settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields)
}
pendingAction={pendingAction}
errors={ErrorUtils.getLatestErrorField(autoSyncConfig, CONST.NETSUITE_CONFIG.AUTO_SYNC)}
/>
{!!autoSyncConfig?.autoSync?.enabled && (
<OfflineWithFeedback
pendingAction={
settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields) ??
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields)
}
>
<OfflineWithFeedback pendingAction={pendingAction}>
<MenuItemWithTopDescription
title={
accountingMethod === COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.ACCRUAL
Expand Down

0 comments on commit 4d1245b

Please sign in to comment.