import {CardRenderer} from "../CardRenderers"; import {ComponentMeta} from "../ComponentsMeta"; import {IncompatibleWithAnyProducts} from "../IncompatibleWithAnyProducts"; import {__, CouponsPlus} from "../../globals"; import {usingTestable} from "./CardHelpers"; import {iconWithClassName} from "../IconWithClassName"; import {FieldType} from "../fields"; import {ComponentCategory} from "../components"; import {TabsProps} from "../fields/tabs"; export type OnSaleOptions = { type: 'include' | 'exclude', } export const type = CouponsPlus?.components?.filters?.OnSale.type; export const OnSaleMeta: ComponentMeta = IncompatibleWithAnyProducts({ id: type, type: 'filters', fieldsTitlePrefix: false, category: ComponentCategory.Filter_Price, priority: 10, supportsCustomTitleForSuggestedScopes: (suggestedScope) => ['bogo'].includes(suggestedScope), icon: iconWithClassName(({className, context}) => { if (context === 'card') { // solid return } // outline return }), fieldsMap: [ [ {id: 'type', renderType: FieldType.Tab, fieldProps: {direction: 'vertical'} as TabsProps}, ] ] }) export const OnSaleRenderer: CardRenderer = { type: OnSaleMeta.id, icon: OnSaleMeta.icon!, prefix: false, example: __('Regular price or Discounted only'), ComputedValue: usingTestable((testable, {context}) => { const {options: {type}} = testable.getData()! if (type === 'include') { return
{__('On Sale Only')}
} return
{__('Not On Sale')}
}), AboveComputedValue: () => false, }