AlkantarClanX12

Your IP : 216.73.217.24


Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox/src/vdp/
Upload File :
Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox/src/vdp/vdp.js

import './editor.scss';

const { registerBlockType } = wp.blocks;
const { Fragment } = wp.element;
const { PanelBody, Button } = wp.components;
const { PlainText, InspectorControls } = wp.editor;

import { CustomFromToken } from './components';
import { resetAll } from './utils.js';

registerBlockType('leadbox/vdp-block', {

	title: 'VDP',
	icon: 'excerpt-view',
	category: 'leadbox',
	keywords: ['leadbox', 'vdp'],

	edit: (props) => {
		const { stock_vdp, stock_vdp_selected, stock_items} = props.attributes;
		
		if(stock_vdp_selected.length >= 2)
			stock_vdp_selected.shift();
		
		const stockSuggestions = stock_items;

		const shortcode = `[vdp stock="${stock_vdp}"]`;

		return (
			<div className="leadbox-vdp-block">
				<div className="block">
					<h3>VDP shortcode</h3>
					<div>This block will render on the frontend as a graphical inventory generated by the following shortcode:</div>
					<pre>
						<PlainText
							className="shortcode"
							value={shortcode} />
					</pre>
					<div>Configure this block on the right panel.</div>
				</div>
				<Fragment>
					<InspectorControls>
						<PanelBody title="Reset">
							<Button
								isPrimary={true}
								isLarge={true}
								onClick={() => resetAll(props)}
							>Reset configuration</Button>
							<span className="leadbox-inventory-hint">
								Press this button to reset all controls to their original values.
							</span>
						</PanelBody>

						<CustomFromToken
							title="Stock Number"
							propName="stock_vdp"
							value={stock_vdp_selected}
							suggestions={stockSuggestions}
							onChange={props.setAttributes}
							 />

					</InspectorControls>
				</Fragment>
			</div>
		);
	},

	save: (props) => {
		return null;
	},
});