-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Display error messages for Xero Import page #41917
Merged
lakchote
merged 12 commits into
Expensify:main
from
software-mansion-labs:@szymczak/error-messages-xero-import
May 15, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2684a5d
display error message on XeroImport
SzymczakJ 87d28ef
refactor ToggleSettingOptionRow
SzymczakJ c2f3ad9
add error/offline state to Import subpages
SzymczakJ a6dad75
delete pending action on XeroImportPage subviews
SzymczakJ 814e016
Merge branch 'main' into @szymczak/error-messages-xero-import
SzymczakJ 9e0df9c
fix lint
SzymczakJ 73614fb
Merge branch 'main' into @szymczak/error-messages-xero-import
SzymczakJ 44c69ae
fix PR comments
SzymczakJ e0e839c
Merge branch 'main' into @szymczak/error-messages-xero-import
SzymczakJ ef10ca8
fix typecheck
SzymczakJ cc5ec33
Merge branch 'main' into @szymczak/error-messages-xero-import
SzymczakJ 9ebd3ab
delete pending action from XeroChartOfAccountsPage
SzymczakJ 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
60 changes: 21 additions & 39 deletions
60
src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.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
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 |
---|---|---|
|
@@ -3,17 +3,16 @@ import {View} from 'react-native'; | |
import ConnectionLayout from '@components/ConnectionLayout'; | ||
import type {MenuItemProps} from '@components/MenuItem'; | ||
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
import Switch from '@components/Switch'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as Connections from '@libs/actions/connections'; | ||
import {getTrackingCategory} from '@libs/actions/connections/ConnectToXero'; | ||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {WithPolicyProps} from '@pages/workspace/withPolicy'; | ||
import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
import variables from '@styles/variables'; | ||
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; | ||
import * as Policy from '@userActions/Policy'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
@@ -22,7 +21,8 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { | |
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const policyID = policy?.id ?? ''; | ||
const {importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; | ||
const xeroConfig = policy?.connections?.xero?.config; | ||
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. same suggestion as above |
||
const isSwitchOn = !!xeroConfig?.importTrackingCategories; | ||
|
||
const menuItems: MenuItemProps[] = useMemo(() => { | ||
const availableCategories = []; | ||
|
@@ -59,30 +59,22 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { | |
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} | ||
contentContainerStyle={[styles.pb2, styles.ph5]} | ||
> | ||
<View> | ||
<View style={[styles.flexRow, styles.mb4, styles.alignItemsCenter, styles.justifyContentBetween]}> | ||
<View style={styles.flex1}> | ||
<Text fontSize={variables.fontSizeNormal}>{translate('workspace.accounting.import')}</Text> | ||
</View> | ||
<OfflineWithFeedback pendingAction={pendingFields?.importTrackingCategories}> | ||
<View style={[styles.flex1, styles.alignItemsEnd, styles.pl3]}> | ||
<Switch | ||
accessibilityLabel={translate('workspace.xero.trackingCategories')} | ||
isOn={Boolean(importTrackingCategories)} | ||
onToggle={() => | ||
Connections.updatePolicyConnectionConfig( | ||
policyID, | ||
CONST.POLICY.CONNECTIONS.NAME.XERO, | ||
CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES, | ||
!importTrackingCategories, | ||
) | ||
} | ||
/> | ||
</View> | ||
</OfflineWithFeedback> | ||
</View> | ||
</View> | ||
{importTrackingCategories && ( | ||
<ToggleSettingOptionRow | ||
title={translate('workspace.accounting.import')} | ||
switchAccessibilityLabel={translate('workspace.xero.trackingCategories')} | ||
isActive={isSwitchOn} | ||
onToggle={() => | ||
Connections.updatePolicyConnectionConfig( | ||
policyID, | ||
CONST.POLICY.CONNECTIONS.NAME.XERO, | ||
CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES, | ||
!xeroConfig?.importTrackingCategories, | ||
) | ||
} | ||
errors={ErrorUtils.getLatestErrorField(xeroConfig ?? {}, CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES)} | ||
onCloseError={() => Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES)} | ||
/> | ||
{xeroConfig?.importTrackingCategories && ( | ||
<View> | ||
{menuItems.map((menuItem: MenuItemProps) => ( | ||
<MenuItemWithTopDescription | ||
|
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
Oops, something went wrong.
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.
And you don't have to add empty object in each place later