/** * External dependencies */ import { Fragment, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import FormStep from '@woocommerce/base-components/checkout/form-step'; import CheckoutForm from '@woocommerce/base-components/checkout/form'; import NoShipping from '@woocommerce/base-components/checkout/no-shipping'; import TextInput from '@woocommerce/base-components/text-input'; import RadioControl from '@woocommerce/base-components/radio-control'; import InputRow from '@woocommerce/base-components/input-row'; import { CheckboxControl } from '@wordpress/components'; import CheckoutProvider from '@woocommerce/base-context/checkout-context'; import { ExpressCheckoutFormControl, PaymentMethods, } from '@woocommerce/base-components/payment-methods'; /** * Internal dependencies */ import placeholderShippingMethods from '../placeholder-shipping-methods'; import './style.scss'; import '../../../payment-methods-demo'; /** * Component displaying an attribute filter. */ const Block = ( { shippingMethods = [], isEditor = false } ) => { const [ shippingMethod, setShippingMethod ] = useState( {} ); const [ contactFields, setContactFields ] = useState( {} ); const [ shouldSavePayment, setShouldSavePayment ] = useState( true ); const [ shippingFields, setShippingFields ] = useState( {} ); return ( ( { __( 'Already have an account? ', 'woo-gutenberg-products-block' ) } { __( 'Log in.', 'woo-gutenberg-products-block' ) } ) } > setContactFields( { ...contactFields, email: newValue, } ) } /> setContactFields( { ...contactFields, keepUpdated: ! contactFields.keepUpdated, } ) } /> { shippingMethods.length === 0 && ( { isEditor && } ) } { shippingMethods.length > 0 && ( setShippingFields( { ...shippingFields, firstName: newValue, } ) } /> setShippingFields( { ...shippingFields, lastName: newValue, } ) } /> setShippingFields( { ...shippingFields, streetAddress: newValue, } ) } /> setShippingFields( { ...shippingFields, apartment: newValue, } ) } /> setShippingFields( { ...shippingFields, country: newValue, } ) } /> setShippingFields( { ...shippingFields, city: newValue, } ) } /> setShippingFields( { ...shippingFields, county: newValue, } ) } /> setShippingFields( { ...shippingFields, postalCode: newValue, } ) } /> setShippingFields( { ...shippingFields, phone: newValue, } ) } /> setShippingFields( { ...shippingFields, useSameForBilling: ! shippingFields.useSameForBilling, } ) } /> setShippingMethod( { ...shippingMethod, method: option, } ) } options={ placeholderShippingMethods.map( ( option ) => ( { label: option.label, value: option.value, description: option.dispatcher, secondaryLabel: option.price, secondaryDescription: option.schedule, } ) ) } /> setShippingMethod( { ...shippingMethod, orderNote: ! shippingMethod.orderNote, } ) } /> ) } { /*@todo this should be something the payment method controls*/ } setShouldSavePayment( ! shouldSavePayment ) } /> ); }; export default Block;