← All changes
|
assets/src/apps/js/blocks/courses/course-order-by/edit.js
+34
-34
4.3.8
→
4.4.10
View file →
| @@ -1,34 +1,34 @@ | ||
| 1 | -import { __ } from '@wordpress/i18n'; | |
| 2 | -import { useBlockProps } from '@wordpress/block-editor'; | |
| 3 | -export const edit = ( props ) => { | |
| 4 | - const { attributes, setAttributes, context } = props; | |
| 5 | - const blockProps = useBlockProps(); | |
| 6 | - const orderByValue = context.lpCourseQuery?.order_by || 'post_date'; | |
| 7 | - const orderByData = [ | |
| 8 | - { label: 'Newly published', value: 'post_date' }, | |
| 9 | - { label: 'Title a-z', value: 'post_title' }, | |
| 10 | - { label: 'Title z-a', value: 'post_title_desc' }, | |
| 11 | - { label: 'Price high to low', value: 'price' }, | |
| 12 | - { label: 'Price low to high', value: 'price_low' }, | |
| 13 | - { label: 'Popular', value: 'popular' }, | |
| 14 | - { label: 'Average Ratings', value: 'rating' }, | |
| 15 | - ]; | |
| 16 | - | |
| 17 | - const orderByLabel = | |
| 18 | - orderByData.find( ( item ) => item.value === orderByValue )?.label ?? | |
| 19 | - 'Newly published'; | |
| 20 | - | |
| 21 | - return ( | |
| 22 | - <> | |
| 23 | - <div { ...blockProps }> | |
| 24 | - <div className="courses-order-by-wrapper"> | |
| 25 | - <select name="order_by" className="block-courses-order-by"> | |
| 26 | - <option selected="selected"> | |
| 27 | - { orderByLabel } | |
| 28 | - </option> | |
| 29 | - </select> | |
| 30 | - </div> | |
| 31 | - </div> | |
| 32 | - </> | |
| 33 | - ); | |
| 34 | -}; | |
| 1 | +import { __ } from '@wordpress/i18n'; | |
| 2 | +import { useBlockProps } from '@wordpress/block-editor'; | |
| 3 | +export const edit = ( props ) => { | |
| 4 | + const { attributes, setAttributes, context } = props; | |
| 5 | + const blockProps = useBlockProps(); | |
| 6 | + const orderByValue = context.lpCourseQuery?.order_by || 'post_date'; | |
| 7 | + const orderByData = [ | |
| 8 | + { label: 'Newly published', value: 'post_date' }, | |
| 9 | + { label: 'Title a-z', value: 'post_title' }, | |
| 10 | + { label: 'Title z-a', value: 'post_title_desc' }, | |
| 11 | + { label: 'Price high to low', value: 'price' }, | |
| 12 | + { label: 'Price low to high', value: 'price_low' }, | |
| 13 | + { label: 'Popular', value: 'popular' }, | |
| 14 | + { label: 'Average Ratings', value: 'rating' }, | |
| 15 | + ]; | |
| 16 | + | |
| 17 | + const orderByLabel = | |
| 18 | + orderByData.find( ( item ) => item.value === orderByValue )?.label ?? | |
| 19 | + 'Newly published'; | |
| 20 | + | |
| 21 | + return ( | |
| 22 | + <> | |
| 23 | + <div { ...blockProps }> | |
| 24 | + <div className="courses-order-by-wrapper"> | |
| 25 | + <select name="order_by" className="block-courses-order-by"> | |
| 26 | + <option selected="selected"> | |
| 27 | + { orderByLabel } | |
| 28 | + </option> | |
| 29 | + </select> | |
| 30 | + </div> | |
| 31 | + </div> | |
| 32 | + </> | |
| 33 | + ); | |
| 34 | +}; | |