2019-10-03 16:03:29 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
2019-12-02 17:39:22 +00:00
|
|
|
import { Button } from '@wordpress/components';
|
2019-10-03 16:03:29 +00:00
|
|
|
import interpolateComponents from 'interpolate-components';
|
|
|
|
import { ADMIN_URL as adminUrl } from '@woocommerce/wc-admin-settings';
|
2020-03-15 21:45:19 +00:00
|
|
|
import { Link, Stepper } from '@woocommerce/components';
|
2019-10-07 20:27:34 +00:00
|
|
|
|
2019-10-03 16:03:29 +00:00
|
|
|
class Klarna extends Component {
|
|
|
|
constructor( props ) {
|
|
|
|
super( props );
|
|
|
|
this.continue = this.continue.bind( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
continue() {
|
2020-03-15 21:45:19 +00:00
|
|
|
const { markConfigured, plugin } = this.props;
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
const slug =
|
2021-02-25 06:15:57 +00:00
|
|
|
plugin === 'checkout' ? 'klarna_checkout' : 'klarna_payments';
|
2020-03-15 21:45:19 +00:00
|
|
|
|
|
|
|
markConfigured( slug );
|
2019-10-03 16:03:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-15 21:45:19 +00:00
|
|
|
renderConnectStep() {
|
|
|
|
const { plugin } = this.props;
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
const slug =
|
2020-03-15 21:45:19 +00:00
|
|
|
plugin === 'checkout' ? 'klarna-checkout' : 'klarna-payments';
|
|
|
|
const section = plugin === 'checkout' ? 'kco' : 'klarna_payments';
|
2019-10-03 16:03:29 +00:00
|
|
|
|
|
|
|
const link = (
|
|
|
|
<Link
|
2020-02-14 02:23:21 +00:00
|
|
|
href={
|
|
|
|
adminUrl +
|
|
|
|
'admin.php?page=wc-settings&tab=checkout§ion=' +
|
|
|
|
section
|
|
|
|
}
|
2019-10-03 16:03:29 +00:00
|
|
|
target="_blank"
|
|
|
|
type="external"
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const helpLink = (
|
|
|
|
<Link
|
2020-02-14 02:23:21 +00:00
|
|
|
href={
|
|
|
|
'https://docs.woocommerce.com/document/' +
|
|
|
|
slug +
|
|
|
|
'/#section-3'
|
|
|
|
}
|
2019-10-03 16:03:29 +00:00
|
|
|
target="_blank"
|
|
|
|
type="external"
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const configureText = interpolateComponents( {
|
|
|
|
mixedString: __(
|
|
|
|
'Klarna can be configured under your {{link}}store settings{{/link}}. Figure out {{helpLink}}what you need{{/helpLink}}.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
components: {
|
|
|
|
link,
|
|
|
|
helpLink,
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<p>{ configureText }</p>
|
2020-06-11 19:22:20 +00:00
|
|
|
<Button isPrimary onClick={ this.continue }>
|
2019-10-03 16:03:29 +00:00
|
|
|
{ __( 'Continue', 'woocommerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
2020-03-15 21:45:19 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { installStep } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Stepper
|
|
|
|
isVertical
|
|
|
|
isPending={ ! installStep.isComplete }
|
|
|
|
currentStep={ installStep.isComplete ? 'connect' : 'install' }
|
|
|
|
steps={ [
|
|
|
|
installStep,
|
|
|
|
{
|
|
|
|
key: 'connect',
|
|
|
|
label: __(
|
|
|
|
'Connect your Klarna account',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
content: this.renderConnectStep(),
|
|
|
|
},
|
|
|
|
] }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2019-10-03 16:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Klarna;
|