Skip to content

Commit

Permalink
Fix offline state
Browse files Browse the repository at this point in the history
  • Loading branch information
twilight2294 authored Nov 13, 2024
1 parent 96208e2 commit 357da49
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) {
const policyID = policy?.id ?? '-1';
const styles = useThemeStyles();
const config = policy?.connections?.netsuite?.options?.config;
const autoSyncConfig = policy?.connections?.netsuite?.config;
const accountingMethod = config?.accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH;
const data: MenuListItem[] = Object.values(COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD).map((accountingMethodType) => ({
value: accountingMethodType,
Expand Down Expand Up @@ -69,7 +70,10 @@ 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)}
pendingAction={
settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields) ??
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields)
}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) {
`workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH}` as TranslationPaths,
);
})(),
subscribedSettings: [CONST.NETSUITE_CONFIG.AUTO_SYNC],
subscribedSettings: [CONST.NETSUITE_CONFIG.AUTO_SYNC, CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD],
},
{
type: 'divider',
Expand Down Expand Up @@ -261,10 +261,9 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) {
return (
<OfflineWithFeedback
key={item.description}
pendingAction={settingsPendingAction(
item.subscribedSettings,
item.subscribedSettings?.includes(CONST.NETSUITE_CONFIG.AUTO_SYNC) ? autoSyncConfig?.pendingFields : config?.pendingFields,
)}
pendingAction={
settingsPendingAction(item.subscribedSettings, config?.pendingFields) ?? settingsPendingAction(item.subscribedSettings, autoSyncConfig?.pendingFields)
}
>
<MenuItemWithTopDescription
title={item.title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,19 @@ 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)}
pendingAction={
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields) ??
settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields)
}
errors={ErrorUtils.getLatestErrorField(autoSyncConfig, CONST.NETSUITE_CONFIG.AUTO_SYNC)}
/>
{!!autoSyncConfig?.autoSync?.enabled && (
<OfflineWithFeedback pendingAction={settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields)}>
<OfflineWithFeedback
pendingAction={
settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields) ??
settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields)
}
>
<MenuItemWithTopDescription
title={
accountingMethod === COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.ACCRUAL
Expand Down
Loading

0 comments on commit 357da49

Please sign in to comment.