/** * External dependencies */ import clsx from 'clsx'; import { __ } from '@wordpress/i18n'; import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { PanelBody, ExternalLink } from '@wordpress/components'; import { ADMIN_URL, getSetting } from '@woocommerce/settings'; import ExternalLinkCard from '@woocommerce/editor-components/external-link-card'; import { innerBlockAreas } from '@woocommerce/blocks-checkout'; import Noninteractive from '@woocommerce/base-components/noninteractive'; import { GlobalPaymentMethod } from '@woocommerce/types'; import { useSelect } from '@wordpress/data'; import { PAYMENT_STORE_KEY } from '@woocommerce/block-data'; import { blocksConfig } from '@woocommerce/block-settings'; import { trimCharacters, trimWords } from '@woocommerce/utils'; /** * Internal dependencies */ import { FormStepBlock, AdditionalFields, AdditionalFieldsContent, } from '../../form-step'; import Block from './block'; export const Edit = ( { attributes, setAttributes, }: { attributes: { title: string; description: string; showStepNumber: boolean; className: string; }; setAttributes: ( attributes: Record< string, unknown > ) => void; } ): JSX.Element => { const globalPaymentMethods = getSetting< GlobalPaymentMethod[] >( 'globalPaymentMethods' ); const { incompatiblePaymentMethods } = useSelect( ( select ) => { const { getIncompatiblePaymentMethods } = select( PAYMENT_STORE_KEY ); return { incompatiblePaymentMethods: getIncompatiblePaymentMethods(), }; }, [] ); const incompatiblePaymentMethodMessage = __( 'Incompatible with block-based checkout', 'woocommerce' ); const wordCountType = blocksConfig.wordCountType; return ( { globalPaymentMethods.length > 0 && (

{ __( 'You currently have the following payment integrations active.', 'woocommerce' ) }

{ globalPaymentMethods.map( ( method ) => { const isIncompatible = !! incompatiblePaymentMethods[ method.id ]; let trimmedDescription; if ( wordCountType === 'words' ) { trimmedDescription = trimWords( method.description, 30, undefined, false ); } else { trimmedDescription = trimCharacters( method.description, 30, wordCountType === 'characters_including_spaces', undefined, false ); } return ( ); } ) } { __( 'Manage payment methods', 'woocommerce' ) }
) }
); }; export const Save = (): JSX.Element => { return (
); };