From 4d1245b357a05bc8dab06d695cf2ff8dfd697e31 Mon Sep 17 00:00:00 2001 From: Rutika Pawar Date: Wed, 13 Nov 2024 11:31:00 +0000 Subject: [PATCH] improve code redability --- .../advanced/NetSuiteAccountingMethodPage.tsx | 8 ++++---- .../netsuite/advanced/NetSuiteAutoSyncPage.tsx | 14 ++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx index 4a75c261c7cf..a5c1872158e9 100644 --- a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx +++ b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx @@ -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( () => ( @@ -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} /> ); } diff --git a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx index 83fb40fdc038..e75496caa451 100644 --- a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx +++ b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx @@ -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 ( 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 && ( - +