-
Notifications
You must be signed in to change notification settings - Fork 21
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 #2639 from woocommerce/update/2597-connect-mc-account
Connect MC Account within combo card
- Loading branch information
Showing
22 changed files
with
728 additions
and
433 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
58 changes: 58 additions & 0 deletions
58
js/src/components/google-mc-account-card/connect-mc/actions.js
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,58 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import CreateAccountButton from '../create-account-button'; | ||
import DisconnectAccountButton from '../disconnect-account-button'; | ||
|
||
/** | ||
* Actions component. | ||
* | ||
* Conditionally renders either a button to disconnect the account if already | ||
* connected, or a button to create a new Merchant Center account. | ||
* | ||
* @param {Object} props | ||
* @param {boolean} props.isConnected Whether the Merchant Center account is connected. | ||
* @param {Object} props.resultConnectMC The result of the connection request, used to handle loading state. | ||
* @param {Object} props.resultCreateAccount The result of the create account request. | ||
* @param {Function} props.onCreateAccount Callback function for creating a new Merchant Center account. | ||
*/ | ||
const Actions = ( { | ||
isConnected, | ||
resultConnectMC, | ||
resultCreateAccount, | ||
onCreateAccount, | ||
} ) => { | ||
if ( isConnected ) { | ||
const handleOnDisconnected = () => { | ||
resultConnectMC.reset(); | ||
resultCreateAccount.reset(); | ||
}; | ||
|
||
return ( | ||
<DisconnectAccountButton | ||
onDisconnected={ handleOnDisconnected } | ||
isTertiary | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<CreateAccountButton | ||
isTertiary | ||
disabled={ resultConnectMC.loading } | ||
onCreateAccount={ onCreateAccount } | ||
> | ||
{ __( | ||
'Or, create a new Merchant Center account', | ||
'google-listings-and-ads' | ||
) } | ||
</CreateAccountButton> | ||
); | ||
}; | ||
|
||
export default Actions; |
Oops, something went wrong.