UNPKG

@wordpress/editor

Version:
27 lines (23 loc) 692 B
import { __ } from '@wordpress/i18n'; import { useDispatch } from '@wordpress/data'; import { SelectControl } from '@wordpress/components'; import { store as editorStore } from '../../store'; import { useAuthorsQuery } from './hook'; export default function PostAuthorSelect() { const { editPost } = useDispatch( editorStore ); const { authorId, authorOptions } = useAuthorsQuery(); const setAuthorId = ( value ) => { const author = Number( value ); editPost( { author } ); }; return ( <SelectControl className="post-author-selector" label={ __( 'Author' ) } options={ authorOptions } onChange={ setAuthorId } value={ authorId } hideLabelFromVision /> ); }