import {CardRenderer, CardRendererContext} from "../CardRenderers"; import {getCardComponentData} from "../cards"; import {ComponentMeta} from "../ComponentsMeta"; import {IncompatibleWithAnyProducts} from "../IncompatibleWithAnyProducts"; import {ToolTip} from "../../ToolTip"; import {__} from "../../globals"; import {usingTestableOptions} from "./CardHelpers"; import {iconWithClassName} from "../IconWithClassName"; import {inclusionValueValidatorFieldsMap, InclusionValueValidatorOptions} from "./InclusionValueValidator"; import {InclusionValueValidatorList} from "./InclusionValueValidatorList"; import {colors} from "../Colors"; import React from "react"; import {request} from "../Color"; export type BrandsOptions = InclusionValueValidatorOptions export const BrandsMeta: ComponentMeta = IncompatibleWithAnyProducts({ id: 'InBrands', type: 'filters', category: 'common', priority: 30, supportsCustomTitleForSuggestedScopes: (suggestedScope) => true, description: ({suggestedScope}) => { if (!suggestedScope) { return '' } else if(suggestedScope === 'bogo') { return __('Select the brands that the customer must buy to be eligible for the BOGO offer.') } else if (suggestedScope === 'item_discounts') { return __('Select the brand that will be discounted.') } else if (suggestedScope === 'cart_discounts') { return __('Select the brand that will trigger the cart discount when purchased.') } }, icon: iconWithClassName(({className, context}) => { if (context === 'card') { // solid return } // outline return }), fieldsMap: inclusionValueValidatorFieldsMap('filters', 'InBrands', (options => ({ SelectStateProps: { afterValues: () => false && options.inclusionType === 'allowed' && {__('Add a combination of products')}

]} width={'full'} background={'lighter'} mainContentAlignment={'title'} mainContentTextColor={'text-gray-500'} titleAndContentGap={'narrower'} animationDirection={'bottom-to-top'} /> } }))) }) export const BrandsRenderer: CardRenderer = { type: BrandsMeta.id, icon: BrandsMeta.icon!, example: __('Apple, Samsung, Google, etc.'), ComputedValue: usingTestableOptions((options, {id, context, color}) => { if (context === 'tier-base') { return getCardComponentData('filter', BrandsMeta.id).name } if (options.expectedValues.length === 0) { return {__('Select Brands')} } if (context === 'testable' || context === 'tier-subchild') { return } }), AboveComputedValue: usingTestableOptions(({inclusionType, expectedValues}, {id, context}) => { if ((['tier-base', 'tier-subchild'] as CardRendererContext[]).includes(context)) { return false } return inclusionType === 'forbidden' ? __('Excluding') : undefined // undefined will make the decorator render the normal name }), }