// #region [Imports] ===================================================================================================
// Libraries
import {useState} from "@wordpress/element";
import ServerSideRender from '@wordpress/server-side-render';
// @ts-ignore
import {clamp} from "lodash";
import {
Button,
Placeholder,
PanelBody,
SelectControl,
RangeControl,
ToolbarGroup,
withSpokenMessages
} from "@wordpress/components";
// @ts-ignore
import { BlockControls, InspectorControls, useBlockProps } from "@wordpress/block-editor";
// Components
import CouponCategoriesControl from "../../components/CouponCategoriesControl";
import ContentSettingsControl from "../../components/ContentSettingsControl";
// Utils
import {layoutDefaults, orderByOptions} from "../../utils/sharedAtts";
// Types
import {IAttributes} from "../../types/settings";
import {ICategory} from "../../types/category";
// #endregion [Imports]
// #region [Variables] =================================================================================================
declare var acfwfBlocksi18n: any;
const {
couponsCategoryTexts,
orderTypeFieldTexts,
numberofItemsFieldLabel,
numberofColumnsFieldLabel,
contentDisplaySettings,
doneBtnText,
} = acfwfBlocksi18n;
// #endregion [Variables]
// #region [Interfaces] ================================================================================================
interface IProps {
attributes: IAttributes;
name: string;
setAttributes: (IAttributes) => void;
debouncedSpeak: (string) => void;
}
// #endregion [Interfaces]
// #region [Component] =================================================================================================
const CouponsByCategoryBlock = (props: IProps) => {
const {attributes, name, setAttributes, debouncedSpeak} = props;
const [isEditing, setIsEditing]: [boolean, any] = useState(1 > attributes.categories.length);
const [categories, setCategories]: [ICategory[], any] = useState([]);
const hasCategories = attributes.categories.length > 0;
const blockProps = useBlockProps();
return (
<>
{couponsCategoryTexts.selectDesc}