Skip to content

Commit

Permalink
Merge pull request #41446 from Expensify/hayata-show-error
Browse files Browse the repository at this point in the history
Show an error on the More Features page if the admin tries to disconnect the Accounting feature while there is an active accounting connection while the device is offline
  • Loading branch information
aldo-expensify authored May 2, 2024
2 parents 8b3def3 + 2e8162a commit 729c9ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import useNetwork from '@hooks/useNetwork';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as ErrorUtils from '@libs/ErrorUtils';
import type {WorkspacesCentralPaneNavigatorParamList} from '@libs/Navigation/types';
import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import type SCREENS from '@src/SCREENS';
import type {PendingAction} from '@src/types/onyx/OnyxCommon';
import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type IconAsset from '@src/types/utils/IconAsset';
import AccessOrNotFoundWrapper from './AccessOrNotFoundWrapper';
Expand All @@ -35,6 +36,8 @@ type Item = {
disabled?: boolean;
action: (isEnabled: boolean) => void;
pendingAction: PendingAction | undefined;
errors?: Errors;
onCloseError?: () => void;
};

type SectionObject = {
Expand Down Expand Up @@ -120,6 +123,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
action: (isEnabled: boolean) => {
Policy.enablePolicyConnections(policy?.id ?? '', isEnabled);
},
errors: ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED),
onCloseError: () => Policy.clearPolicyErrorField(policy?.id ?? '', CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED),
},
];

Expand Down Expand Up @@ -158,6 +163,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
pendingAction={item.pendingAction}
onToggle={item.action}
disabled={item.disabled}
errors={item.errors}
onCloseError={item.onCloseError}
/>
</View>
),
Expand Down

0 comments on commit 729c9ac

Please sign in to comment.