11import React from 'react' ;
2- import type { ValueOf } from 'type-fest' ;
32import ConnectionLayout from '@components/ConnectionLayout' ;
43import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription' ;
54import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
@@ -13,16 +12,6 @@ import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnec
1312import withPolicyConnections from '@pages/workspace/withPolicyConnections' ;
1413import CONST from '@src/CONST' ;
1514import ROUTES , { DYNAMIC_ROUTES } from '@src/ROUTES' ;
16- import type { PendingAction } from '@src/types/onyx/OnyxCommon' ;
17-
18- type XeroSectionType = {
19- title ?: string ;
20- description ?: string ;
21- onPress : ( ) => void ;
22- subscribedSettings : string [ ] ;
23- pendingAction ?: PendingAction ;
24- brickRoadIndicator ?: ValueOf < typeof CONST . BRICK_ROAD_INDICATOR_STATUS > ;
25- } ;
2615
2716const payableAccountSetting = [ CONST . XERO_CONFIG . TRAVEL_INVOICING_PAYABLE_ACCOUNT ] ;
2817
@@ -38,22 +27,6 @@ function XeroTravelInvoicingConfigurationPage({policy}: WithPolicyConnectionsPro
3827 const { bankAccounts} = policy ?. connections ?. xero ?. data ?? { } ;
3928 const travelPayableAccount = bankAccounts ?. find ( ( account ) => account . id === config ?. export ?. travelInvoicingPayableAccountID ) ;
4029
41- const sections : XeroSectionType [ ] = [
42- {
43- title : travelPayableAccount ?. name ,
44- description : translate ( 'workspace.common.travelInvoicingPayableAccount' ) ,
45- onPress : ( ) => {
46- if ( ! policyID ) {
47- return ;
48- }
49- Navigation . navigate ( createDynamicRoute ( DYNAMIC_ROUTES . POLICY_ACCOUNTING_XERO_TRAVEL_INVOICING_PAYABLE_ACCOUNT_SELECT . path , travelInvoicingPath ) ) ;
50- } ,
51- subscribedSettings : payableAccountSetting ,
52- pendingAction : settingsPendingAction ( payableAccountSetting , config ?. pendingFields ) ,
53- brickRoadIndicator : areSettingsInErrorFields ( payableAccountSetting , config ?. errorFields ) ? CONST . BRICK_ROAD_INDICATOR_STATUS . ERROR : undefined ,
54- } ,
55- ] ;
56-
5730 return (
5831 < ConnectionLayout
5932 displayName = "XeroTravelInvoicingConfigurationPage"
@@ -66,21 +39,23 @@ function XeroTravelInvoicingConfigurationPage({policy}: WithPolicyConnectionsPro
6639 connectionName = { CONST . POLICY . CONNECTIONS . NAME . XERO }
6740 onBackButtonPress = { ( ) => Navigation . goBack ( backPath ) }
6841 >
69- { sections . map ( ( section ) => (
70- < OfflineWithFeedback
71- pendingAction = { section . pendingAction }
72- key = { section . subscribedSettings . at ( 0 ) }
73- errorRowStyles = { [ styles . ph5 ] }
74- >
75- < MenuItemWithTopDescription
76- title = { section . title }
77- description = { section . description }
78- onPress = { section . onPress }
79- shouldShowRightIcon
80- brickRoadIndicator = { section . brickRoadIndicator }
81- />
82- </ OfflineWithFeedback >
83- ) ) }
42+ < OfflineWithFeedback
43+ pendingAction = { settingsPendingAction ( payableAccountSetting , config ?. pendingFields ) }
44+ errorRowStyles = { [ styles . ph5 ] }
45+ >
46+ < MenuItemWithTopDescription
47+ title = { travelPayableAccount ?. name }
48+ description = { translate ( 'workspace.common.travelInvoicingPayableAccount' ) }
49+ onPress = { ( ) => {
50+ if ( ! policyID ) {
51+ return ;
52+ }
53+ Navigation . navigate ( createDynamicRoute ( DYNAMIC_ROUTES . POLICY_ACCOUNTING_XERO_TRAVEL_INVOICING_PAYABLE_ACCOUNT_SELECT . path , travelInvoicingPath ) ) ;
54+ } }
55+ shouldShowRightIcon
56+ brickRoadIndicator = { areSettingsInErrorFields ( payableAccountSetting , config ?. errorFields ) ? CONST . BRICK_ROAD_INDICATOR_STATUS . ERROR : undefined }
57+ />
58+ </ OfflineWithFeedback >
8459 </ ConnectionLayout >
8560 ) ;
8661}
0 commit comments