import React from "react"; import {iconWithClassName} from "../IconWithClassName"; import {CardRenderer} from "../CardRenderers"; import {__} from "../../globals"; import {usingOfferOptions} from "./CardHelpers"; import {FieldType} from "../fields"; import {NumberProps} from "../fields/Number"; import {OfferCardContent} from "./OfferCardContent"; import {renderCurrencyValue} from "../fields/helpers"; import {RowOptions} from "./Fields/RowOptions"; import {ComponentCategory} from "../components"; import type {ComponentMeta} from "../ComponentsMeta"; export type PricePerItemOptions = { amount: number } export const type = 'PricePerItem' export const PricePerItemMeta: ComponentMeta = { id: type, type: 'offers', category: ComponentCategory.CartItemDiscounts, priority: 3, icon: iconWithClassName(({className, context}) => { if (context === 'card') { // solid return } // outline return }), fieldsMap: [ [ new RowOptions({ type: 'featured', colWidth: 'auto' }), { id: 'amount', renderType: FieldType.Number, fieldProps: { hasAmountStructure: false, type: 'currency', border: false } as Partial } ] ] } export const PricePerItemRenderer: CardRenderer = { type: type, prefix: "*", example: __('All clearance t-shirts $10 each, 2 hoodies for $30/each, 3 for $25/each, etc.'), icon: PricePerItemMeta.icon!, AboveComputedValue: () => false, ComputedValue: usingOfferOptions(({amount}, {color}, offer) => { return {true &&
{
{renderCurrencyValue(amount)}
}
}
}), }