📂 FileMgr
📍
/home/coemyoza/public_html/wp-content/plugins/give/blocks/components/select-form
✏️ Edit File: /home/coemyoza/public_html/wp-content/plugins/give/blocks/components/select-form/index.js
⬅ Kembali
/** * 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 );
💾 Simpan File
Batal
⬅ Naik ke components
2 item
Nama
Tipe
Ukuran
Diubah
Aksi
📜
index.js
js
1.2 KB
2022-11-29 18:00
✏️ Edit
👁️ View
🗑 Hapus
📄
index.scss
scss
134 B
2022-11-29 18:00
✏️ Edit
👁️ View
🗑 Hapus