forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#41377 from hungvu193/feat/xero-import-cu…
…stomer Feat/xero import customer
- Loading branch information
Showing
13 changed files
with
149 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {PolicyAccessVariant} from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import type {PolicyFeatureName} from '@src/types/onyx/Policy'; | ||
import HeaderWithBackButton from './HeaderWithBackButton'; | ||
import ScreenWrapper from './ScreenWrapper'; | ||
import ScrollView from './ScrollView'; | ||
import Text from './Text'; | ||
|
||
type ConnectionLayoutProps = { | ||
/** Used to set the testID for tests */ | ||
displayName: string; | ||
/** Header title for the connection */ | ||
headerTitle: TranslationPaths; | ||
/** React nodes that will be shown */ | ||
children?: React.ReactNode; | ||
/** Title of the connection component */ | ||
title?: TranslationPaths; | ||
/** Subtitle of the connection */ | ||
subtitle?: TranslationPaths; | ||
/** The current policyID */ | ||
policyID: string; | ||
/** Defines which types of access should be verified */ | ||
accessVariants?: PolicyAccessVariant[]; | ||
/** The current feature name that the user tries to get access to */ | ||
featureName?: PolicyFeatureName; | ||
}; | ||
|
||
function ConnectionLayout({displayName, headerTitle, children, title, subtitle, policyID, accessVariants, featureName}: ConnectionLayoutProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<AccessOrNotFoundWrapper | ||
policyID={policyID} | ||
accessVariants={accessVariants} | ||
featureName={featureName} | ||
> | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnableMaxHeight | ||
testID={displayName} | ||
> | ||
<HeaderWithBackButton | ||
title={translate(headerTitle)} | ||
onBackButtonPress={() => Navigation.goBack()} | ||
/> | ||
<ScrollView contentContainerStyle={[styles.pb2, styles.ph5]}> | ||
<View style={[styles.pb2]}>{title && <Text style={styles.pb5}>{translate(title)}</Text>}</View> | ||
{subtitle && <Text style={styles.textLabelSupporting}>{translate(subtitle)}</Text>} | ||
{children} | ||
</ScrollView> | ||
</ScreenWrapper> | ||
</AccessOrNotFoundWrapper> | ||
); | ||
} | ||
|
||
ConnectionLayout.displayName = 'ConnectionLayout'; | ||
export default ConnectionLayout; |
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
65 changes: 65 additions & 0 deletions
65
src/pages/workspace/accounting/xero/import/XeroCustomerConfigurationPage.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,65 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import ConnectionLayout from '@components/ConnectionLayout'; | ||
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 type {WithPolicyProps} from '@pages/workspace/withPolicy'; | ||
import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
import variables from '@styles/variables'; | ||
import CONST from '@src/CONST'; | ||
|
||
function XeroCustomerConfigurationPage({policy}: WithPolicyProps) { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const policyID = policy?.id ?? ''; | ||
const {importCustomers, pendingFields} = policy?.connections?.xero?.config ?? {}; | ||
|
||
const isSwitchOn = Boolean(importCustomers); | ||
|
||
return ( | ||
<ConnectionLayout | ||
displayName={XeroCustomerConfigurationPage.displayName} | ||
headerTitle="workspace.xero.customers" | ||
title="workspace.xero.customersDescription" | ||
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} | ||
policyID={policyID} | ||
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} | ||
> | ||
<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?.importCustomers}> | ||
<View style={[styles.flex1, styles.alignItemsEnd, styles.pl3]}> | ||
<Switch | ||
accessibilityLabel={translate('workspace.xero.customers')} | ||
isOn={isSwitchOn} | ||
onToggle={() => Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.IMPORT_CUSTOMERS, !importCustomers)} | ||
/> | ||
</View> | ||
</OfflineWithFeedback> | ||
</View> | ||
{isSwitchOn && ( | ||
<OfflineWithFeedback pendingAction={pendingFields?.importCustomers}> | ||
<MenuItemWithTopDescription | ||
interactive={false} | ||
title={translate('workspace.common.tags')} | ||
description={translate('workspace.qbo.displayedAs')} | ||
wrapperStyle={styles.sectionMenuItemTopDescription} | ||
/> | ||
</OfflineWithFeedback> | ||
)} | ||
</View> | ||
</ConnectionLayout> | ||
); | ||
} | ||
|
||
XeroCustomerConfigurationPage.displayName = 'XeroCustomerConfigurationPage'; | ||
|
||
export default withPolicyConnections(XeroCustomerConfigurationPage); |