-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51949 from twilight2294/issuenewpage
New Feature: "When to export" selector for auto-sync for NetSuite
- Loading branch information
Showing
18 changed files
with
274 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/libs/API/parameters/UpdateNetSuiteAccountingMethodParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {CONST as COMMON_CONST} from 'expensify-common'; | ||
import type {ValueOf} from 'type-fest'; | ||
|
||
type UpdateNetSuiteAccountingMethodParams = { | ||
policyID: string; | ||
accountingMethod: ValueOf<typeof COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD>; | ||
}; | ||
|
||
export default UpdateNetSuiteAccountingMethodParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import {CONST as COMMON_CONST} from 'expensify-common'; | ||
import React, {useCallback, useMemo} from 'react'; | ||
import {View} from 'react-native'; | ||
import type {ValueOf} from 'type-fest'; | ||
import RadioListItem from '@components/SelectionList/RadioListItem'; | ||
import type {ListItem} from '@components/SelectionList/types'; | ||
import SelectionScreen from '@components/SelectionScreen'; | ||
import type {SelectorType} from '@components/SelectionScreen'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as Connections from '@libs/actions/connections/NetSuiteCommands'; | ||
import {settingsPendingAction} from '@libs/PolicyUtils'; | ||
import Navigation from '@navigation/Navigation'; | ||
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; | ||
import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
type MenuListItem = ListItem & { | ||
value: ValueOf<typeof COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD>; | ||
}; | ||
|
||
function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) { | ||
const {translate} = useLocalize(); | ||
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, | ||
text: translate(`workspace.netsuite.advancedConfig.accountingMethods.values.${accountingMethodType}` as TranslationPaths), | ||
alternateText: translate(`workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMethodType}` as TranslationPaths), | ||
keyForList: accountingMethodType, | ||
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> | ||
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.netsuite.advancedConfig.accountingMethods.description')}</Text> | ||
</View> | ||
), | ||
[translate, styles.pb5, styles.ph5], | ||
); | ||
|
||
const selectExpenseReportApprovalLevel = useCallback( | ||
(row: MenuListItem) => { | ||
if (row.value !== config?.accountingMethod) { | ||
Connections.updateNetSuiteAccountingMethod(policyID, row.value, config?.accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH); | ||
} | ||
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID)); | ||
}, | ||
[config?.accountingMethod, policyID], | ||
); | ||
|
||
return ( | ||
<SelectionScreen | ||
displayName={NetSuiteAccountingMethodPage.displayName} | ||
title="workspace.netsuite.advancedConfig.accountingMethods.label" | ||
headerContent={headerContent} | ||
sections={[{data}]} | ||
listItem={RadioListItem} | ||
onSelectRow={(selection: SelectorType) => selectExpenseReportApprovalLevel(selection as MenuListItem)} | ||
initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} | ||
policyID={policyID} | ||
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} | ||
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={pendingAction} | ||
/> | ||
); | ||
} | ||
|
||
NetSuiteAccountingMethodPage.displayName = 'NetSuiteExpenseReportApprovalLevelSelectPage'; | ||
|
||
export default withPolicyConnections(NetSuiteAccountingMethodPage); |
Oops, something went wrong.