-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[QBD] Export settings main page #50164
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
Changes from all commits
9a98d28
9581d14
6b01554
edb07a0
256a747
082240d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import React, {useMemo} from 'react'; | ||
| import ConnectionLayout from '@components/ConnectionLayout'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
| import Text from '@components/Text'; | ||
| import TextLink from '@components/TextLink'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import usePermissions from '@hooks/usePermissions'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import * as PolicyUtils from '@libs/PolicyUtils'; | ||
| import Navigation from '@navigation/Navigation'; | ||
| import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; | ||
| import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
| import * as Link from '@userActions/Link'; | ||
| import CONST from '@src/CONST'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
||
| function QuickbooksDesktopExportPage({policy}: WithPolicyConnectionsProps) { | ||
| const {translate} = useLocalize(); | ||
| const styles = useThemeStyles(); | ||
| const policyID = policy?.id ?? '-1'; | ||
| const policyOwner = policy?.owner ?? ''; | ||
| const qbdConfig = policy?.connections?.quickbooksOnline?.config; // TODO: should be updated to use the new connections object | ||
| const errorFields = qbdConfig?.errorFields; | ||
| const {canUseNewDotQBD} = usePermissions(); | ||
|
|
||
| const shouldShowVendorMenuItems = useMemo( | ||
| () => qbdConfig?.nonReimbursableExpensesExportDestination === CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.VENDOR_BILL, | ||
| [qbdConfig?.nonReimbursableExpensesExportDestination], | ||
| ); | ||
| const menuItems = [ | ||
| { | ||
| description: translate('workspace.accounting.preferredExporter'), | ||
| onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), // TODO: should be updated to use new routes | ||
| title: qbdConfig?.export?.exporter ?? policyOwner, | ||
| subscribedSettings: [CONST.QUICKBOOKS_CONFIG.EXPORT], | ||
| }, | ||
| { | ||
| description: translate('workspace.qbo.date'), | ||
| onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), // TODO: should be updated to use new routes | ||
| title: qbdConfig?.exportDate ? translate(`workspace.qbo.exportDate.values.${qbdConfig?.exportDate}.label`) : undefined, | ||
| subscribedSettings: [CONST.QUICKBOOKS_CONFIG.EXPORT_DATE], | ||
| }, | ||
| { | ||
| description: translate('workspace.accounting.exportOutOfPocket'), | ||
| onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), | ||
| title: qbdConfig?.reimbursableExpensesExportDestination ? translate(`workspace.qbo.accounts.${qbdConfig?.reimbursableExpensesExportDestination}`) : undefined, // TODO: should be updated to use new routes | ||
| subscribedSettings: [CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_EXPORT_DESTINATION, CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT], | ||
| }, | ||
| { | ||
| description: translate('workspace.qbo.exportInvoices'), | ||
| onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), // TODO: should be updated to use new routes | ||
| title: qbdConfig?.receivableAccount?.name, | ||
| subscribedSettings: [CONST.QUICKBOOKS_CONFIG.RECEIVABLE_ACCOUNT], | ||
| }, | ||
| { | ||
| description: translate('workspace.accounting.exportCompanyCard'), | ||
| onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT.getRoute(policyID)), // TODO: should be updated to use new routes | ||
| brickRoadIndicator: qbdConfig?.errorFields?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, | ||
| title: qbdConfig?.nonReimbursableExpensesExportDestination ? translate(`workspace.qbo.accounts.${qbdConfig?.nonReimbursableExpensesExportDestination}`) : undefined, | ||
| subscribedSettings: [ | ||
| CONST.QUICKBOOKS_CONFIG.NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION, | ||
| CONST.QUICKBOOKS_CONFIG.NON_REIMBURSABLE_EXPENSE_ACCOUNT, | ||
| ...(shouldShowVendorMenuItems ? [CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR] : []), | ||
| ...(shouldShowVendorMenuItems && qbdConfig?.autoCreateVendor ? [CONST.QUICKBOOKS_CONFIG.NON_REIMBURSABLE_BILL_DEFAULT_VENDOR] : []), | ||
| ], | ||
| }, | ||
| { | ||
| description: translate('workspace.qbo.exportExpensifyCard'), | ||
| title: translate('workspace.qbo.accounts.credit_card'), | ||
| shouldShowRightIcon: false, | ||
| interactive: false, | ||
| }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <ConnectionLayout | ||
| displayName={QuickbooksDesktopExportPage.displayName} | ||
| headerTitle="workspace.accounting.export" | ||
| title="workspace.qbd.exportDescription" | ||
| accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} | ||
|
Contributor
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. Should we modify this, to gate access to users who are on the beta for QBD too?
Contributor
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. Good idea |
||
| policyID={policyID} | ||
| featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} | ||
| contentContainerStyle={styles.pb2} | ||
| titleStyle={styles.ph5} | ||
| shouldBeBlocked={!canUseNewDotQBD} // TODO: remove it once the QBD beta is done | ||
| connectionName={CONST.POLICY.CONNECTIONS.NAME.QBO} // TODO: should be updated to use the new connection | ||
| onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING.getRoute(policyID))} | ||
|
Contributor
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. Looks like having a fallback to the which was fixed by removing the fallback, more details in the proposed solution.
Contributor
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. Thanks for the heads up @ikevin127. cc @ZhenjaHorbach @hoangzinh for visibility |
||
| > | ||
| {menuItems.map((menuItem) => ( | ||
| <OfflineWithFeedback | ||
| key={menuItem.description} | ||
| pendingAction={PolicyUtils.settingsPendingAction(menuItem?.subscribedSettings, qbdConfig?.pendingFields)} | ||
| > | ||
| <MenuItemWithTopDescription | ||
| title={menuItem.title} | ||
| interactive={menuItem?.interactive ?? true} | ||
| description={menuItem.description} | ||
| shouldShowRightIcon={menuItem?.shouldShowRightIcon ?? true} | ||
| onPress={menuItem?.onPress} | ||
| brickRoadIndicator={PolicyUtils.areSettingsInErrorFields(menuItem?.subscribedSettings, errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| ))} | ||
| <Text style={[styles.mutedNormalTextLabel, styles.ph5, styles.pb5, styles.mt2]}> | ||
| <Text style={[styles.mutedNormalTextLabel]}>{translate('workspace.qbo.deepDiveExpensifyCard')}</Text> | ||
| <TextLink | ||
| onPress={() => Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} | ||
| style={[styles.mutedNormalTextLabel, styles.link]} | ||
| > | ||
| {` ${translate('workspace.qbo.deepDiveExpensifyCardIntegration')}`} | ||
| </TextLink> | ||
| </Text> | ||
| </ConnectionLayout> | ||
| ); | ||
| } | ||
|
|
||
| QuickbooksDesktopExportPage.displayName = 'QuickbooksDesktopExportPage'; | ||
|
|
||
| export default withPolicyConnections(QuickbooksDesktopExportPage); | ||
Uh oh!
There was an error while loading. Please reload this page.