-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #44218 from mananjadhav/mj-netsuite-connect-button
[#Wave-Control: Add NetSuite]: Added `NetSuite` connect button and fixed copies
- Loading branch information
Showing
11 changed files
with
145 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import type {ConnectionName} from '@src/types/onyx/Policy'; | ||
import ConfirmModal from './ConfirmModal'; | ||
|
||
type AccountingConnectionConfirmationModalProps = { | ||
integrationToConnect: ConnectionName; | ||
onConfirm: () => void; | ||
onCancel: () => void; | ||
}; | ||
|
||
function AccountingConnectionConfirmationModal({integrationToConnect, onCancel, onConfirm}: AccountingConnectionConfirmationModalProps) { | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<ConfirmModal | ||
title={translate('workspace.accounting.connectTitle', integrationToConnect)} | ||
isVisible | ||
onConfirm={onConfirm} | ||
onCancel={onCancel} | ||
prompt={translate('workspace.accounting.connectPrompt', integrationToConnect)} | ||
confirmText={translate('workspace.accounting.setup')} | ||
cancelText={translate('common.cancel')} | ||
success | ||
/> | ||
); | ||
} | ||
|
||
AccountingConnectionConfirmationModal.displayName = 'AccountingConnectionConfirmationModal'; | ||
export default AccountingConnectionConfirmationModal; |
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,54 @@ | ||
import React, {useState} from 'react'; | ||
import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal'; | ||
import Button from '@components/Button'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useNetwork from '@hooks/useNetwork'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import {removePolicyConnection} from '@libs/actions/connections'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type {ConnectToNetSuiteButtonProps} from './types'; | ||
|
||
function ConnectToNetSuiteButton({policyID, shouldDisconnectIntegrationBeforeConnecting, integrationToDisconnect}: ConnectToNetSuiteButtonProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const {isOffline} = useNetwork(); | ||
|
||
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<Button | ||
onPress={() => { | ||
if (shouldDisconnectIntegrationBeforeConnecting && integrationToDisconnect) { | ||
setIsDisconnectModalOpen(true); | ||
return; | ||
} | ||
|
||
// TODO: Will be updated to new token input page | ||
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.getRoute(policyID)); | ||
}} | ||
text={translate('workspace.accounting.setup')} | ||
style={styles.justifyContentCenter} | ||
small | ||
isDisabled={isOffline} | ||
/> | ||
{shouldDisconnectIntegrationBeforeConnecting && isDisconnectModalOpen && integrationToDisconnect && ( | ||
<AccountingConnectionConfirmationModal | ||
onConfirm={() => { | ||
removePolicyConnection(policyID, integrationToDisconnect); | ||
|
||
// TODO: Will be updated to new token input page | ||
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.getRoute(policyID)); | ||
setIsDisconnectModalOpen(false); | ||
}} | ||
integrationToConnect={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} | ||
onCancel={() => setIsDisconnectModalOpen(false)} | ||
/> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default ConnectToNetSuiteButton; |
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,10 @@ | ||
import type {PolicyConnectionName} from '@src/types/onyx/Policy'; | ||
|
||
type ConnectToNetSuiteButtonProps = { | ||
policyID: string; | ||
shouldDisconnectIntegrationBeforeConnecting?: boolean; | ||
integrationToDisconnect?: PolicyConnectionName; | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export type {ConnectToNetSuiteButtonProps}; |
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
Oops, something went wrong.