Skip to content

Display tooltips on the connect screen if the oauth URL fails to load #3318

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 47 additions & 25 deletions client/settings/connect-stripe-account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CardBody from '../card-body';
import StripeBanner from 'wcstripe/components/stripe-banner';
import { recordEvent } from 'wcstripe/tracking';
import InlineNotice from 'wcstripe/components/inline-notice';
import Tooltip from 'wcstripe/components/tooltip';

const CardWrapper = styled( Card )`
max-width: 560px;
Expand Down Expand Up @@ -35,6 +36,7 @@ const ButtonWrapper = styled.div`
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 16px;

> :last-child {
box-shadow: none;
Expand All @@ -58,6 +60,32 @@ const ConnectStripeAccount = ( { oauthUrl, testOauthUrl } ) => {
window.location.assign( testOauthUrl );
};

const connectButton = (
<Button
variant="primary"
onClick={ handleCreateOrConnectAccount }
disabled={ ! oauthUrl }
>
{ __(
'Create or connect an account',
'woocommerce-gateway-stripe'
) }
</Button>
);

const connectTestButton = (
<Button
variant="secondary"
onClick={ handleCreateOrConnectTestAccount }
disabled={ ! testOauthUrl }
>
{ __(
'Create or connect a test account',
'woocommerce-gateway-stripe'
) }
</Button>
);

return (
<CardWrapper>
<StripeBanner />
Expand All @@ -74,7 +102,6 @@ const ConnectStripeAccount = ( { oauthUrl, testOauthUrl } ) => {
'woocommerce-gateway-stripe'
) }
</InformationText>

{ oauthUrl || testOauthUrl ? (
<>
<TermsOfServiceText>
Expand All @@ -96,34 +123,29 @@ const ConnectStripeAccount = ( { oauthUrl, testOauthUrl } ) => {
} ) }
</TermsOfServiceText>
<ButtonWrapper>
{ oauthUrl && (
<Button
variant="primary"
onClick={ handleCreateOrConnectAccount }
>
{ __(
'Create or connect an account',
{ ! oauthUrl ? (
<Tooltip
content={ __(
'An issue occurred generating a connection to Stripe. Please try again or connect in test mode.',
'woocommerce-gateway-stripe'
) }
</Button>
>
{ connectButton }
</Tooltip>
) : (
connectButton
) }
{ testOauthUrl && (
<Button
variant={
oauthUrl ? 'secondary' : 'primary'
}
onClick={ handleCreateOrConnectTestAccount }
{ ! testOauthUrl ? (
<Tooltip
content={ __(
'An issue occurred generating a connection to Stripe in test mode. Please try again or connect in live mode.',
'woocommerce-gateway-stripe'
) }
>
{ oauthUrl
? __(
'Create or connect a test account instead',
'woocommerce-gateway-stripe'
)
: __(
'Create or connect a test account',
'woocommerce-gateway-stripe'
) }
</Button>
{ connectTestButton }
</Tooltip>
) : (
connectTestButton
) }
</ButtonWrapper>
</>
Expand Down
Loading