-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 #39219 from Expensify/hayata-authenticate-with-qbo
Authenticate with QBO
- Loading branch information
Showing
39 changed files
with
480 additions
and
381 deletions.
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
68 changes: 68 additions & 0 deletions
68
src/components/ConnectToQuickbooksOnlineButton/index.native.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,68 @@ | ||
import React, {useState} from 'react'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {WebView} from 'react-native-webview'; | ||
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; | ||
import Button from '@components/Button'; | ||
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import Modal from '@components/Modal'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import {getQuickBooksOnlineSetupLink} from '@libs/actions/connections/QuickBooksOnline'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {Session} from '@src/types/onyx'; | ||
import type {ConnectToQuickbooksOnlineButtonProps} from './types'; | ||
|
||
type ConnectToQuickbooksOnlineButtonOnyxProps = { | ||
/** Session info for the currently logged in user. */ | ||
session: OnyxEntry<Session>; | ||
}; | ||
|
||
const renderLoading = () => <FullScreenLoadingIndicator />; | ||
|
||
function ConnectToQuickbooksOnlineButton({policyID, session}: ConnectToQuickbooksOnlineButtonProps & ConnectToQuickbooksOnlineButtonOnyxProps) { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<> | ||
<Button | ||
onPress={() => setIsModalOpen(true)} | ||
text={translate('workspace.accounting.setup')} | ||
/> | ||
<Modal | ||
fullscreen | ||
onClose={() => setIsModalOpen(false)} | ||
isVisible={isModalOpen} | ||
type={CONST.MODAL.MODAL_TYPE.CENTERED} | ||
> | ||
<HeaderWithBackButton | ||
title={translate('workspace.accounting.title')} | ||
onBackButtonPress={() => setIsModalOpen(false)} | ||
/> | ||
<FullPageOfflineBlockingView> | ||
<WebView | ||
source={{ | ||
uri: getQuickBooksOnlineSetupLink(policyID), | ||
headers: { | ||
Cookie: `authToken=${session?.authToken}`, | ||
}, | ||
}} | ||
incognito // 'incognito' prop required for Android, issue here https://github.com/react-native-webview/react-native-webview/issues/1352 | ||
startInLoadingState | ||
renderLoading={renderLoading} | ||
/> | ||
</FullPageOfflineBlockingView> | ||
</Modal> | ||
</> | ||
); | ||
} | ||
|
||
ConnectToQuickbooksOnlineButton.displayName = 'ConnectToQuickbooksOnlineButton'; | ||
|
||
export default withOnyx<ConnectToQuickbooksOnlineButtonProps & ConnectToQuickbooksOnlineButtonOnyxProps, ConnectToQuickbooksOnlineButtonOnyxProps>({ | ||
session: { | ||
key: ONYXKEYS.SESSION, | ||
}, | ||
})(ConnectToQuickbooksOnlineButton); |
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,25 @@ | ||
import React from 'react'; | ||
import Button from '@components/Button'; | ||
import useEnvironment from '@hooks/useEnvironment'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import {getQuickBooksOnlineSetupLink} from '@libs/actions/connections/QuickBooksOnline'; | ||
import * as Link from '@userActions/Link'; | ||
import type {ConnectToQuickbooksOnlineButtonProps} from './types'; | ||
|
||
function ConnectToQuickbooksOnlineButton({policyID}: ConnectToQuickbooksOnlineButtonProps) { | ||
const {translate} = useLocalize(); | ||
const {environmentURL} = useEnvironment(); | ||
const styles = useThemeStyles(); | ||
return ( | ||
<Button | ||
onPress={() => Link.openLink(getQuickBooksOnlineSetupLink(policyID), environmentURL, false)} | ||
text={translate('workspace.accounting.setup')} | ||
style={styles.justifyContentCenter} | ||
/> | ||
); | ||
} | ||
|
||
ConnectToQuickbooksOnlineButton.displayName = 'ConnectToQuickbooksOnlineButton'; | ||
|
||
export default ConnectToQuickbooksOnlineButton; |
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,6 @@ | ||
type ConnectToQuickbooksOnlineButtonProps = { | ||
policyID: string; | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export type {ConnectToQuickbooksOnlineButtonProps}; |
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
5 changes: 5 additions & 0 deletions
5
src/libs/API/parameters/ConnectPolicyToQuickbooksOnlineParams.ts
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,5 @@ | ||
type ConnectPolicyToQuickbooksOnlineParams = { | ||
policyID: string; | ||
}; | ||
|
||
export default ConnectPolicyToQuickbooksOnlineParams; |
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,8 @@ | ||
import type {PolicyConnectionName} from '@src/types/onyx/Policy'; | ||
|
||
type RemovePolicyConnectionParams = { | ||
policyID: string; | ||
connectionName: PolicyConnectionName; | ||
}; | ||
|
||
export default RemovePolicyConnectionParams; |
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.