![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mets.corals.io/wp-content/plugins/give/blocks/components/select-form/ |
/** * WordPress dependencies */ import { __ } from '@wordpress/i18n' import {withSelect} from '@wordpress/data'; import { Placeholder, Spinner } from '@wordpress/components'; /** * Internal dependencies */ import './index.scss'; import GiveBlankSlate from '../blank-slate'; import NoForms from '../no-form'; import ChosenSelect from '../chosen-select'; import { getFormOptions } from '../../utils'; const SelectForm = ( { forms, setAttributes } ) => { const setFormIdTo = id => { setAttributes( { id: Number( id ) } ); }; // Render Component UI let componentUI; if ( ! forms ) { componentUI = <Placeholder><Spinner /></Placeholder>; } else if ( forms && forms.length === 0 ) { componentUI = <NoForms />; } else { componentUI = ( <GiveBlankSlate title={ __( 'Donation Form', 'give' ) }> <ChosenSelect className="give-blank-slate__select" options={ getFormOptions( forms ) } onChange={ setFormIdTo } value={ 0 } /> </GiveBlankSlate> ); } return componentUI; }; /** * Export with forms data */ export default withSelect( ( select ) => { return { forms: select( 'core' ).getEntityRecords( 'postType', 'give_forms', { per_page: 30 } ), }; } )( SelectForm );