-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathNSQSImportPage.tsx
76 lines (72 loc) · 4.35 KB
/
NSQSImportPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import noop from 'lodash/noop';
import React from 'react';
import {View} from 'react-native';
import ConnectionLayout from '@components/ConnectionLayout';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import {areSettingsInErrorFields, settingsPendingAction} from '@libs/PolicyUtils';
import type {WithPolicyProps} from '@pages/workspace/withPolicy';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
function NSQSImportPage({policy}: WithPolicyProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const customersImportType = nsqsConfig?.syncOptions?.mapping?.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const projectsImportType = nsqsConfig?.syncOptions?.mapping?.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
return (
<ConnectionLayout
policyID={policyID}
displayName={NSQSImportPage.displayName}
headerTitle="workspace.accounting.import"
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
contentContainerStyle={[styles.pb2, styles.ph5, styles.gap6]}
connectionName={CONST.POLICY.CONNECTIONS.NAME.NSQS}
>
<ToggleSettingOptionRow
title={translate('workspace.nsqs.import.expenseCategories')}
subtitle={translate('workspace.nsqs.import.expenseCategoriesDescription')}
switchAccessibilityLabel={translate('workspace.nsqs.import.expenseCategories')}
shouldPlaceSubtitleBelowSwitch
isActive
disabled
onToggle={noop}
/>
<View>
<OfflineWithFeedback pendingAction={settingsPendingAction([CONST.NSQS_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS], nsqsConfig?.pendingFields)}>
<MenuItemWithTopDescription
title={translate(`workspace.accounting.importTypes.${customersImportType}`)}
description={translate('workspace.nsqs.import.importFields.customers.title')}
wrapperStyle={[styles.sectionMenuItemTopDescription]}
shouldShowRightIcon
onPress={policyID ? () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NSQS_IMPORT_CUSTOMERS.getRoute(policyID)) : undefined}
brickRoadIndicator={
areSettingsInErrorFields([CONST.NSQS_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS], nsqsConfig?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined
}
/>
</OfflineWithFeedback>
<OfflineWithFeedback pendingAction={settingsPendingAction([CONST.NSQS_CONFIG.SYNC_OPTIONS.MAPPING.PROJECTS], nsqsConfig?.pendingFields)}>
<MenuItemWithTopDescription
title={translate(`workspace.accounting.importTypes.${projectsImportType}`)}
description={translate('workspace.nsqs.import.importFields.projects.title')}
wrapperStyle={[styles.sectionMenuItemTopDescription]}
shouldShowRightIcon
onPress={policyID ? () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NSQS_IMPORT_PROJECTS.getRoute(policyID)) : undefined}
brickRoadIndicator={
areSettingsInErrorFields([CONST.NSQS_CONFIG.SYNC_OPTIONS.MAPPING.PROJECTS], nsqsConfig?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined
}
/>
</OfflineWithFeedback>
</View>
</ConnectionLayout>
);
}
NSQSImportPage.displayName = 'NSQSImportPage';
export default withPolicyConnections(NSQSImportPage);