Repository navigation
[Wave Collect][Xero][Advanced] Bill status selector page #41559
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
Merged
lakchote
merged 25 commits into
Expensify:xero-merge-freeze
from
rushatgabhane:bill-status
May 17, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a73a507
add routes
rushatgabhane e266c3e
add screen map
rushatgabhane 102d949
add navigation map
rushatgabhane 37df48a
link to bill status page and add default page
rushatgabhane 7562b7f
add selection screen
rushatgabhane fe9b69b
add selection screen
rushatgabhane b0032de
fix merge
rushatgabhane 6614242
unlink from advanced
rushatgabhane fcd7545
link export page
rushatgabhane dfe0452
fix merge
rushatgabhane 6ad88e3
update route to export
rushatgabhane db7f63e
add lang
rushatgabhane c4fcf6d
fix nav
rushatgabhane d75c756
use updated routes and lang
rushatgabhane 6de73ea
update status name
rushatgabhane 19b1c8c
change order
rushatgabhane c7eb413
change order
rushatgabhane 2380eb7
handle undefined
rushatgabhane 87bae9f
Merge branch 'Expensify:main' into bill-status
rushatgabhane 4d1a0e0
Update src/pages/workspace/accounting/xero/export/XeroPurchaseBillSta…
rushatgabhane bf670dc
Update src/SCREENS.ts
rushatgabhane 7d8a0d1
Merge branch 'main' of github.com:rushatgabhane/exfy into bill-status
rushatgabhane 191b805
Update src/languages/es.ts
rushatgabhane 95b787f
Update src/languages/es.ts
rushatgabhane 2c7c80f
Update src/languages/es.ts
rushatgabhane 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
78 changes: 78 additions & 0 deletions
78
src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx
This file contains hidden or 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,78 @@ | ||
| import _ from 'lodash'; | ||
| 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'; | ||
| import Navigation from '@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'; | ||
|
|
||
| type MenuListItem = ListItem & { | ||
| value: ValueOf<typeof CONST.XERO_CONFIG.INVOICE_STATUS>; | ||
| }; | ||
|
|
||
| function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps) { | ||
| const {translate} = useLocalize(); | ||
| const policyID = policy?.id ?? ''; | ||
| const styles = useThemeStyles(); | ||
| const {billStatus} = policy?.connections?.xero?.config?.export ?? {}; | ||
| const invoiceStatus = billStatus?.purchase; | ||
|
|
||
| const data: MenuListItem[] = Object.values(CONST.XERO_CONFIG.INVOICE_STATUS).map((status) => ({ | ||
| value: status, | ||
| text: translate(`workspace.xero.invoiceStatus.values.${status}`), | ||
| keyForList: status, | ||
| isSelected: invoiceStatus === status, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question, we don't need the check to be case insensitive?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, it's checking against the const values |
||
| })); | ||
|
|
||
| const headerContent = useMemo( | ||
| () => ( | ||
| <View> | ||
| <Text style={[styles.ph5, styles.pb5]}>{translate('workspace.xero.invoiceStatus.description')}</Text> | ||
| </View> | ||
| ), | ||
| [translate, styles.pb5, styles.ph5], | ||
| ); | ||
|
|
||
| const selectPurchaseBillStatus = useCallback( | ||
| (row: MenuListItem) => { | ||
| if (_.isEmpty(billStatus)) { | ||
| return; | ||
| } | ||
| if (row.value !== invoiceStatus) { | ||
| Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.EXPORT, {billStatus: {...billStatus, purchase: row.value}}); | ||
| } | ||
| Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID)); | ||
| }, | ||
| [billStatus, invoiceStatus, policyID], | ||
| ); | ||
|
|
||
| return ( | ||
| <SelectionScreen | ||
| displayName={XeroPurchaseBillStatusSelectorPage.displayName} | ||
| title="workspace.xero.invoiceStatus.label" | ||
| headerContent={headerContent} | ||
| sections={[{data}]} | ||
| listItem={RadioListItem} | ||
| onSelectRow={(selection: SelectorType) => selectPurchaseBillStatus(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_XERO_EXPORT.getRoute(policyID))} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| XeroPurchaseBillStatusSelectorPage.displayName = 'XeroPurchaseBillStatusSelectorPage'; | ||
|
|
||
| export default withPolicyConnections(XeroPurchaseBillStatusSelectorPage); | ||
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.
I couldn't find if there was an order specified in the doc. But I am assuming it's Draft, Awaiting approval and Awaiting payment?
Uh oh!
There was an error while loading. Please reload this page.
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.
yes that it the order as per screenshots in doc