-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #48764 from shubham1206agra/sage-intacct-new-struc…
…ture New page structure for export Sage Intacct
- Loading branch information
Showing
11 changed files
with
371 additions
and
229 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
69 changes: 69 additions & 0 deletions
69
...workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesDestinationPage.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,69 @@ | ||
import React, {useCallback} from 'react'; | ||
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 useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||
import {settingsPendingAction} from '@libs/PolicyUtils'; | ||
import Navigation from '@navigation/Navigation'; | ||
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; | ||
import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
import {updateSageIntacctNonreimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct'; | ||
import * as Policy from '@userActions/Policy/Policy'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
type MenuListItem = ListItem & { | ||
value: ValueOf<typeof CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE>; | ||
}; | ||
|
||
function SageIntacctNonReimbursableExpensesDestinationPage({policy}: WithPolicyConnectionsProps) { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const policyID = policy?.id ?? '-1'; | ||
const {config} = policy?.connections?.intacct ?? {}; | ||
|
||
const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ | ||
value: expenseType, | ||
text: translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${expenseType}`), | ||
keyForList: expenseType, | ||
isSelected: config?.export.nonReimbursable === expenseType, | ||
})); | ||
|
||
const selectDestination = useCallback( | ||
(row: MenuListItem) => { | ||
if (row.value !== config?.export.nonReimbursable) { | ||
updateSageIntacctNonreimbursableExpensesExportDestination(policyID, row.value, config?.export.nonReimbursable); | ||
} | ||
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); | ||
}, | ||
[config?.export.nonReimbursable, policyID], | ||
); | ||
|
||
return ( | ||
<SelectionScreen | ||
displayName={SageIntacctNonReimbursableExpensesDestinationPage.displayName} | ||
title="workspace.accounting.exportAs" | ||
sections={[{data}]} | ||
listItem={RadioListItem} | ||
onSelectRow={(selection: SelectorType) => selectDestination(selection as MenuListItem)} | ||
initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} | ||
policyID={policyID} | ||
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} | ||
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} | ||
connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} | ||
pendingAction={settingsPendingAction([CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE], config?.pendingFields)} | ||
errors={ErrorUtils.getLatestErrorField(config, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE)} | ||
errorRowStyles={[styles.ph5, styles.pv3]} | ||
onClose={() => Policy.clearSageIntacctErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE)} | ||
/> | ||
); | ||
} | ||
|
||
SageIntacctNonReimbursableExpensesDestinationPage.displayName = 'SageIntacctNonReimbursableExpensesDestinationPage'; | ||
|
||
export default withPolicyConnections(SageIntacctNonReimbursableExpensesDestinationPage); |
Oops, something went wrong.