import { __ } from '@wordpress/i18n';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
import { PanelBody, PanelRow, TextControl, DateTimePicker } from '@wordpress/components';
import { useEntityProp } from '@wordpress/core-data';
const JVIcon = () => (
);
const SidePanel = ( { postType, metaFields, setMetaFields } ) => {
const { content, fields } = window.jvbFieldConfig || {};
const [meta, setMeta] = useEntityProp('postType', content, 'meta');
console.log(fields);
return (
<>
}
>
Metadata Sidebar
}
title="Fields"
>
setMetaFields( { _meta_fields_book_title: value } ) }
/>
setMetaFields( { _meta_fields_book_author: value } ) }
/>
setMetaFields( { _meta_fields_book_publisher: value } ) }
/>
setMetaFields( { _meta_fields_book_date: newDate } ) }
__nextRemoveHelpButton
__nextRemoveResetButton
/>
>
)
}
const applyWithSelect = withSelect( ( select ) => {
return {
metaFields: select( 'core/editor' ).getEditedPostAttribute( 'meta' ),
postType: select( 'core/editor' ).getCurrentPostType()
};
} );
const applyWithDispatch = withDispatch( ( dispatch ) => {
return {
setMetaFields ( newValue ) {
dispatch('core/editor').editPost( { meta: newValue } )
}
}
} );
export default compose([
applyWithSelect,
applyWithDispatch
])(SidePanel);