-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wave Collect][Xero][Advanced] Bill Payment Account Selector #41690
Merged
lakchote
merged 11 commits into
Expensify:xero-merge-freeze
from
mananjadhav:xero-advanced-bill-payment-account
May 9, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6a40b76
feat: screen and nav setup
mananjadhav 9352393
feat: connect page
mananjadhav 295cbf2
feat: page setup with api call
mananjadhav d3ca32f
feat: advanced page current selection
mananjadhav 6a0b68b
style: prettier fix
mananjadhav b4c8f72
Merge branch 'main' of github.com:mananjadhav/App into xero-advanced-…
mananjadhav c839dc8
fix: spanish translation
mananjadhav d0b31f2
refactor: merge usememo
mananjadhav dc2e2ce
Merge branch 'main' of github.com:mananjadhav/App into xero-advanced-…
mananjadhav 9281743
fix: qbo charge of accounts padding
mananjadhav 75145eb
refactor: prettier fixes
mananjadhav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
77 changes: 77 additions & 0 deletions
77
src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.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,77 @@ | ||
import React, {useCallback, useMemo} from 'react'; | ||
import {View} from 'react-native'; | ||
import RadioListItem from '@components/SelectionList/RadioListItem'; | ||
import type {SelectorType} from '@components/SelectionScreen'; | ||
import SelectionScreen 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'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; | ||
import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
function XeroBillPaymentAccountSelectorPage({policy}: WithPolicyConnectionsProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
const policyID = policy?.id ?? ''; | ||
const {bankAccounts} = policy?.connections?.xero?.data ?? {}; | ||
|
||
const {reimbursementAccountID, syncReimbursedReports} = policy?.connections?.xero?.config.sync ?? {}; | ||
|
||
const xeroSelectorOptions = useMemo<SelectorType[]>( | ||
() => | ||
(bankAccounts ?? []).map(({id, name}) => ({ | ||
value: id, | ||
text: name, | ||
keyForList: id, | ||
isSelected: reimbursementAccountID === id, | ||
})), | ||
[reimbursementAccountID, bankAccounts], | ||
); | ||
|
||
const listHeaderComponent = useMemo( | ||
() => ( | ||
<View style={[styles.pb2, styles.ph5]}> | ||
<Text style={[styles.pb5, styles.textNormal]}>{translate('workspace.xero.advancedConfig.xeroBillPaymentAccountDescription')}</Text> | ||
</View> | ||
), | ||
[translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], | ||
); | ||
|
||
const initiallyFocusedOptionKey = useMemo(() => xeroSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [xeroSelectorOptions]); | ||
|
||
const updateMode = useCallback( | ||
({value}: SelectorType) => { | ||
Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.SYNC, { | ||
reimbursementAccountID: value, | ||
}); | ||
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID)); | ||
}, | ||
[policyID], | ||
); | ||
|
||
return ( | ||
<SelectionScreen | ||
policyID={policyID} | ||
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} | ||
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} | ||
displayName={XeroBillPaymentAccountSelectorPage.displayName} | ||
sections={[{data: xeroSelectorOptions}]} | ||
listItem={RadioListItem} | ||
shouldBeBlocked={!syncReimbursedReports} | ||
onSelectRow={updateMode} | ||
initiallyFocusedOptionKey={initiallyFocusedOptionKey} | ||
headerContent={listHeaderComponent} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID))} | ||
title="workspace.xero.advancedConfig.xeroBillPaymentAccount" | ||
/> | ||
); | ||
} | ||
|
||
XeroBillPaymentAccountSelectorPage.displayName = 'XeroBillPaymentAccountSelectorPage'; | ||
|
||
export default withPolicyConnections(XeroBillPaymentAccountSelectorPage); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB, we should also add more condition here to address the case when Xero is disconnected
We can do this as a follow up since we will need to update other screens as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This is required in all the screens.