-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate Account Management component into the Settings Page (#10287)
- Loading branch information
Showing
4 changed files
with
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Add the Stripe embedded account management component into the Payments → Settings page. |
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 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React, { useState } from 'react'; | ||
import { Card, CardBody } from '@wordpress/components'; | ||
import { | ||
ConnectAccountManagement, | ||
ConnectComponentsProvider, | ||
} from '@stripe/react-connect-js'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import StripeSpinner from 'wcpay/components/stripe-spinner'; | ||
import BannerNotice from 'wcpay/components/banner-notice'; | ||
import appearance from 'wcpay/utils/embedded-components/appearance'; | ||
import useAccountSession from 'wcpay/utils/embedded-components/account-session'; | ||
import './style.scss'; | ||
|
||
const AccountManagement = () => { | ||
const [ loadErrorMessage, setLoadErrorMessage ] = useState( '' ); | ||
const [ loading, setLoading ] = useState( true ); | ||
const stripeConnectInstance = useAccountSession( { | ||
setLoadErrorMessage, | ||
appearance, | ||
} ); | ||
|
||
return ( | ||
<> | ||
<Card> | ||
<CardBody> | ||
{ loading && ( | ||
<div className="account-management-loader-wrapper"> | ||
<StripeSpinner /> | ||
</div> | ||
) } | ||
{ loadErrorMessage ? ( | ||
<BannerNotice status="error"> | ||
{ loadErrorMessage } | ||
</BannerNotice> | ||
) : ( | ||
stripeConnectInstance && ( | ||
<ConnectComponentsProvider | ||
connectInstance={ stripeConnectInstance } | ||
> | ||
<ConnectAccountManagement | ||
onLoaderStart={ () => setLoading( false ) } | ||
onLoadError={ ( loadError ) => | ||
setLoadErrorMessage( | ||
loadError.error.message || | ||
'Unknown error' | ||
) | ||
} | ||
collectionOptions={ { | ||
fields: 'eventually_due', | ||
futureRequirements: 'include', | ||
} } | ||
/> | ||
</ConnectComponentsProvider> | ||
) | ||
) } | ||
</CardBody> | ||
</Card> | ||
</> | ||
); | ||
}; | ||
|
||
export default AccountManagement; |
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 @@ | ||
// Wrap loader so it's centered and does not get cut. | ||
.account-management-loader-wrapper { | ||
text-align: center; | ||
height: 35px; | ||
padding: 20px 0; | ||
} |
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