2022-09-23 12:36:12 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { List } from '@woocommerce/components';
|
|
|
|
import { download, Icon } from '@wordpress/icons';
|
|
|
|
|
|
|
|
import {
|
|
|
|
Card,
|
|
|
|
CardBody,
|
|
|
|
CardFooter,
|
|
|
|
CardHeader,
|
|
|
|
ExternalLink,
|
|
|
|
Notice,
|
|
|
|
ToggleControl,
|
|
|
|
} from '@wordpress/components';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import strings from './strings';
|
|
|
|
import { WC_ASSET_URL } from '~/utils/admin-settings';
|
|
|
|
|
|
|
|
export interface Apm {
|
|
|
|
id: string;
|
|
|
|
title: string;
|
|
|
|
icon: string;
|
|
|
|
description: string;
|
|
|
|
link: string;
|
|
|
|
extension: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const apms: Apm[] = [
|
|
|
|
{
|
|
|
|
id: 'paypal',
|
|
|
|
title: strings.apms.paypal.title,
|
|
|
|
icon: `${ WC_ASSET_URL }images/payment_methods/72x72/paypal.png`,
|
|
|
|
description: strings.apms.paypal.description,
|
2023-11-06 11:45:26 +00:00
|
|
|
link: 'https://woo.com/products/woocommerce-paypal-payments/',
|
2022-09-23 12:36:12 +00:00
|
|
|
extension: 'woocommerce-paypal-payments',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'amazonpay',
|
|
|
|
title: strings.apms.amazonpay.title,
|
|
|
|
icon: `${ WC_ASSET_URL }images/payment_methods/72x72/amazonpay.png`,
|
|
|
|
description: strings.apms.amazonpay.description,
|
2023-11-06 11:45:26 +00:00
|
|
|
link: 'https://woo.com/products/pay-with-amazon/',
|
2022-09-23 12:36:12 +00:00
|
|
|
extension: 'woocommerce-gateway-amazon-payments-advanced',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'klarna',
|
|
|
|
title: strings.apms.klarna.title,
|
|
|
|
icon: `${ WC_ASSET_URL }images/payment_methods/72x72/klarna.png`,
|
|
|
|
description: strings.apms.klarna.description,
|
2023-11-06 11:45:26 +00:00
|
|
|
link: 'https://woo.com/products/klarna-payments/',
|
2022-09-23 12:36:12 +00:00
|
|
|
extension: 'klarna-payments-for-woocommerce',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
interface ApmListProps {
|
|
|
|
enabledApms: Set< Apm >;
|
|
|
|
setEnabledApms: ( value: Set< Apm > ) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ApmNotice = ( { enabledApms }: { enabledApms: Set< Apm > } ) => {
|
|
|
|
if ( ! enabledApms.size ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const extensions = [ ...enabledApms ]
|
|
|
|
.map( ( apm ) => apm.title )
|
|
|
|
.join( ', ' );
|
|
|
|
return (
|
2023-06-16 14:32:58 +00:00
|
|
|
<Notice
|
|
|
|
status={ 'info' }
|
|
|
|
isDismissible={ false }
|
|
|
|
className="woopayments-welcome-page__apms-notice"
|
|
|
|
>
|
|
|
|
<Icon icon={ download } />
|
|
|
|
<div>{ strings.apms.installText( extensions ) }</div>
|
|
|
|
</Notice>
|
2022-09-23 12:36:12 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const ApmList: React.FunctionComponent< ApmListProps > = ( {
|
|
|
|
enabledApms,
|
|
|
|
setEnabledApms,
|
|
|
|
} ) => {
|
|
|
|
const handleToggleChange = ( apm: Apm ) => {
|
|
|
|
if ( enabledApms.has( apm ) ) {
|
|
|
|
enabledApms.delete( apm );
|
|
|
|
} else {
|
|
|
|
enabledApms.add( apm );
|
|
|
|
}
|
|
|
|
setEnabledApms( new Set< Apm >( enabledApms ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
const apmsList = apms.map( ( apm ) => ( {
|
|
|
|
key: apm.id,
|
|
|
|
title: apm.title,
|
|
|
|
content: (
|
|
|
|
<>
|
|
|
|
{ apm.description }{ ' ' }
|
|
|
|
<a href={ apm.link } target="_blank" rel="noreferrer">
|
|
|
|
{ strings.learnMore }
|
|
|
|
</a>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
before: <img src={ apm.icon } alt="" />,
|
|
|
|
after: (
|
|
|
|
<ToggleControl
|
|
|
|
checked={ enabledApms.has( apm ) }
|
|
|
|
onChange={ () => handleToggleChange( apm ) }
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
} ) );
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<ApmNotice enabledApms={ enabledApms } />
|
2023-06-16 14:32:58 +00:00
|
|
|
<Card size="large" className="woopayments-welcome-page__apms">
|
2022-09-23 12:36:12 +00:00
|
|
|
<CardHeader>
|
|
|
|
<h1>{ strings.apms.addMoreWaysToPay }</h1>
|
|
|
|
</CardHeader>
|
|
|
|
<CardBody>
|
|
|
|
<List items={ apmsList } />
|
|
|
|
</CardBody>
|
|
|
|
<CardFooter>
|
2023-11-06 11:45:26 +00:00
|
|
|
<ExternalLink href="https://woo.com/product-category/woocommerce-extensions/payment-gateways/wallets/?categoryIds=28682&collections=product&page=1">
|
2022-09-23 12:36:12 +00:00
|
|
|
{ strings.apms.seeMore }
|
|
|
|
</ExternalLink>
|
|
|
|
</CardFooter>
|
|
|
|
</Card>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ApmList;
|