/** * WordPress dependencies */ const { __ } = wp.i18n; const { apiFetch } = wp; const { Component, Fragment } = wp.element; const { Button, PanelBody, Placeholder, SelectControl, Spinner } = wp.components; class ChartImport extends Component { constructor() { super( ...arguments ); this.state = { id: '', charts: [] }; } async componentDidMount() { let charts = await apiFetch({ path: 'wp/v2/visualizer/?per_page=100' }); let id; charts = charts.map( ( i, index ) => { let label = i['chart_data']['visualizer-settings'].title ? i['chart_data']['visualizer-settings'].title : `#${i.id}`; if ( 0 === index ) { id = i.id; } return { value: i.id, label }; }); this.setState({ id, charts }); } render() { return ( ( 'community' !== visualizerLocalize.isPro ) ? { 1 <= ( this.state.charts ).length ? this.setState({ id }) } /> this.props.getChartData( this.state.id ) } > { __( 'Import Chart' ) } : } : { __( 'Enable this feature in PRO version!' ) } { __( 'Buy Now' ) } ); } } export default ChartImport;
{ __( 'Enable this feature in PRO version!' ) }