import { registerBlockType } from '@wordpress/blocks';
import { InspectorControls } from '@wordpress/block-editor';
import ServerSideRender from '@wordpress/server-side-render';
import { PanelBody, TextControl } from '@wordpress/components';

import metadata from '../../../blocks/premium/subscription-management/block.json';

registerBlockType( metadata.name, {
    edit: ( { attributes, setAttributes } ) => (
        <>
            <InspectorControls>
                <PanelBody title="Content">
                    <TextControl
                        label="No Subscriptions Message"
                        value={ attributes.empty_message }
                        onChange={ ( val ) => setAttributes( { empty_message: val } ) }
                    />
                    <TextControl
                        label="Not Logged In Message"
                        value={ attributes.login_message }
                        onChange={ ( val ) => setAttributes( { login_message: val } ) }
                    />
                </PanelBody>
            </InspectorControls>
            <ServerSideRender block={ metadata.name } attributes={ attributes } />
        </>
    ),
    save: () => null,
} );
