2024-12-08 09:33:49 +01:00
|
|
|
import { ToggleControl } from '@wordpress/components';
|
|
|
|
import SettingsBlock from './SettingsBlock';
|
|
|
|
import PaymentMethodIcon from '../PaymentMethodIcon';
|
|
|
|
import data from '../../../utils/data';
|
2025-01-09 00:16:12 +01:00
|
|
|
import { hasSettings } from '../../Screens/Overview/TabSettingsElements/Blocks/PaymentMethods';
|
2024-12-08 09:33:49 +01:00
|
|
|
|
2025-01-02 13:55:32 +01:00
|
|
|
const PaymentMethodItemBlock = ( {
|
|
|
|
id,
|
|
|
|
title,
|
|
|
|
description,
|
|
|
|
icon,
|
|
|
|
onTriggerModal,
|
|
|
|
onSelect,
|
|
|
|
isSelected,
|
|
|
|
} ) => {
|
2025-01-09 00:16:12 +01:00
|
|
|
// Only show settings icon if this method has fields configured
|
|
|
|
const hasModal = hasSettings( id );
|
2024-12-08 09:33:49 +01:00
|
|
|
|
|
|
|
return (
|
2025-01-02 13:55:32 +01:00
|
|
|
<SettingsBlock className="ppcp-r-settings-block__payment-methods__item">
|
|
|
|
<div className="ppcp-r-settings-block__payment-methods__item__inner">
|
|
|
|
<div className="ppcp-r-settings-block__payment-methods__item__title-wrapper">
|
|
|
|
<PaymentMethodIcon icons={ [ icon ] } type={ icon } />
|
|
|
|
<span className="ppcp-r-settings-block__payment-methods__item__title">
|
|
|
|
{ title }
|
|
|
|
</span>
|
2024-12-16 16:00:27 +01:00
|
|
|
</div>
|
2025-01-02 13:55:32 +01:00
|
|
|
<p className="ppcp-r-settings-block__payment-methods__item__description">
|
|
|
|
{ description }
|
|
|
|
</p>
|
|
|
|
<div className="ppcp-r-settings-block__payment-methods__item__footer">
|
|
|
|
<ToggleControl
|
|
|
|
__nextHasNoMarginBottom={ true }
|
|
|
|
checked={ isSelected }
|
|
|
|
onChange={ onSelect }
|
|
|
|
/>
|
|
|
|
{ hasModal && onTriggerModal && (
|
|
|
|
<div
|
|
|
|
className="ppcp-r-settings-block__payment-methods__item__settings"
|
|
|
|
onClick={ onTriggerModal }
|
|
|
|
>
|
|
|
|
{ data().getImage( 'icon-settings.svg' ) }
|
|
|
|
</div>
|
|
|
|
) }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</SettingsBlock>
|
2024-12-08 09:33:49 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PaymentMethodItemBlock;
|