// src/gmbreviews/edit.js
|
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
import { PanelBody, RangeControl, ToggleControl } from '@wordpress/components';
|
import { __ } from '@wordpress/i18n';
|
import ServerSideRender from '@wordpress/server-side-render';
|
|
export default function Edit({ attributes, setAttributes }) {
|
const blockProps = useBlockProps();
|
const { count, inheritUser, showStats, minStars, showViewAllLink, showRating, showDate, showReviewLink } = attributes;
|
|
return (
|
<>
|
<InspectorControls>
|
<PanelBody title={__('Review Settings', 'jvb')}>
|
<ToggleControl
|
label={__('Inherit User', 'jvb')}
|
checked={inheritUser}
|
onChange={(value) => setAttributes({ inheritUser: value })}
|
/>
|
<RangeControl
|
label={__('Number of Reviews', 'jvb')}
|
value={count}
|
onChange={(value) => setAttributes({ count: value })}
|
min={1}
|
max={20}
|
/>
|
<ToggleControl
|
label={__('Show Rating', 'jvb')}
|
checked={showRating}
|
onChange={(value) => setAttributes({ showRating: value })}
|
/>
|
<ToggleControl
|
label={__('Show Date', 'jvb')}
|
checked={showDate}
|
onChange={(value) => setAttributes({ showDate: value })}
|
/>
|
<ToggleControl
|
label={__('Show Review Link', 'jvb')}
|
checked={showReviewLink}
|
onChange={(value) => setAttributes({ showReviewLink: value })}
|
/>
|
<ToggleControl
|
label={__('Show Stats', 'jvb')}
|
checked={showStats}
|
onChange={(value) => setAttributes({ showStats: value })}
|
/>
|
<ToggleControl
|
label={__('Show All Reviews Link', 'jvb')}
|
checked={showViewAllLink}
|
onChange={(value) => setAttributes({ showViewAllLink: value })}
|
/>
|
<RangeControl
|
label={__('Minimum Rating', 'jvb')}
|
value={minStars}
|
onChange={(value) => setAttributes({ minStars: value })}
|
min={1}
|
max={5}
|
/>
|
</PanelBody>
|
</InspectorControls>
|
<div {...blockProps}>
|
<ServerSideRender
|
block="jvb/gmbreviews"
|
attributes={attributes}
|
/>
|
</div>
|
</>
|
);
|
}
|