PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.7
Yatra – Travel Booking & Tour Operator Software v3.0.2.7
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / resources / js / blocks / tour / edit.tsx

edit.tsx in Yatra – Travel Booking & Tour Operator Software 3.0.2.7, at resources/js/blocks/tour/edit.tsx

88 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { InspectorControls } from "@wordpress/block-editor";
2 import {
3 PanelBody,
4 TextControl,
5 RangeControl,
6 SelectControl,
7 ToggleControl,
8 } from "@wordpress/components";
9 import { __ } from "@wordpress/i18n";
10 import ServerSideRender from "@wordpress/server-side-render";
11
12 interface TourBlockAttributes {
13 order: "desc" | "asc";
14 featured: boolean;
15 per_page: number;
16 columns: number;
17 title: string;
18 show_pagination: boolean;
19 }
20
21 interface EditProps {
22 attributes: TourBlockAttributes;
23 setAttributes: (attrs: Partial<TourBlockAttributes>) => void;
24 }
25
26 export default function Edit({ attributes, setAttributes }: EditProps) {
27 return (
28 <>
29 <InspectorControls>
30 <PanelBody title={__("Trip Settings", "yatra")} initialOpen={true}>
31 <TextControl
32 label={__("Title", "yatra")}
33 value={attributes.title}
34 onChange={(value) => setAttributes({ title: value })}
35 />
36 <SelectControl
37 label={__("Order", "yatra")}
38 value={attributes.order}
39 options={[
40 { label: __("Descending", "yatra"), value: "desc" },
41 { label: __("Ascending", "yatra"), value: "asc" },
42 ]}
43 onChange={(value: string) =>
44 setAttributes({ order: value as "asc" | "desc" })
45 }
46 />
47 <RangeControl
48 label={__("Number of Tours", "yatra")}
49 value={attributes.per_page}
50 onChange={(value) => setAttributes({ per_page: value || 10 })}
51 min={1}
52 max={50}
53 />
54 <RangeControl
55 label={__("Columns", "yatra")}
56 value={attributes.columns}
57 onChange={(value) =>
58 setAttributes({
59 columns: value !== undefined && value !== null ? value : 3,
60 })
61 }
62 min={1}
63 max={6}
64 />
65 <ToggleControl
66 label={__("Show only featured tours", "yatra")}
67 checked={attributes.featured}
68 onChange={(value) => setAttributes({ featured: value })}
69 />
70 <ToggleControl
71 label={__("Show pagination", "yatra")}
72 checked={attributes.show_pagination}
73 onChange={(value) => setAttributes({ show_pagination: value })}
74 />
75 </PanelBody>
76 </InspectorControls>
77
78 <div className="yatra-block-editor-preview">
79 <ServerSideRender
80 block="yatra/tour"
81 attributes={attributes}
82 key={JSON.stringify(attributes)}
83 />
84 </div>
85 </>
86 );
87 }
88