// #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 ContentSettingsControl from "../../components/ContentSettingsControl";
// Utils
import {layoutDefaults, orderByOptions} from "../../utils/sharedAtts";
// Types
import {IAttributes} from "../../types/settings";
// Helpers
import { sanitizeHtml } from "../../../shared/utils";
// #endregion [Imports]
// #region [Variables] =================================================================================================
declare var acfwfBlocksi18n: any;
const {
isPremium,
couponsCustomerTexts,
displayTypeFieldTexts,
orderTypeFieldTexts,
numberofItemsFieldLabel,
numberofColumnsFieldLabel,
contentDisplaySettings,
premiumUpsellMessage,
doneBtnText
} = acfwfBlocksi18n;
// #endregion [Variables]
// #region [Interfaces] ================================================================================================
interface IProps {
attributes: IAttributes;
name: string;
setAttributes: (IAttributes) => void;
debouncedSpeak: (string) => void;
}
// #endregion [Interfaces]
// #region [Component] =================================================================================================
const CouponsByCustomerBlock = (props: IProps) => {
const {attributes, name, setAttributes, debouncedSpeak} = props;
const [isEditing, setIsEditing]: [boolean, any] = useState('' === attributes.display_type);
const displayTypeOptions = [
{value: 'both', label: displayTypeFieldTexts.options.couponsAndVirtualCoupons},
{value: 'coupons_only', label: displayTypeFieldTexts.options.couponsOnly},
{value: 'virtual_only', label: displayTypeFieldTexts.options.virtualCouponsOnly},
];
const handleDone = () => {
if ('' === attributes.display_type) {
setAttributes({display_type: 'both'});
}
setIsEditing(false);
};
const blockProps = useBlockProps();
return (
<>