Jake Vanderwerf
7 days ago 46d681c6b825d21b3f698d793c4e630c687d90ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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>
        </>
    );
}