import React, { forwardRef, useCallback } from 'react' import { ProductPrice } from '../..' import SearchProductItemControl from './SearchProductItemControl' import type { PriceDefinition } from '../../typings/PriceDefinition' export interface SearchProductItemContentProps { /** * Specifies the product's title. */ title: string /** * Specifies product's prices. */ price: PriceDefinition /** * Quick order settings. */ quickOrder?: { enabled: boolean outOfStockLabel: string availability: boolean hasVariants: boolean skuMatrixControl: React.ReactNode quantity: number min?: number max?: number onChangeQuantity(value: number): void buyProps?: { onClick: (e: React.MouseEvent) => void 'data-testid': string 'data-sku': string 'data-seller': string } } /** * Event emitted when value is out of the min and max bounds */ onValidateBlur?: (min: number, maxValue: number, quantity: number) => void } const SearchProductItemContent = forwardRef< HTMLElement, SearchProductItemContentProps >(function SearchProductItemContent( { price, title, quickOrder, onValidateBlur, ...otherProps }, ref ) { const renderProductItemContent = useCallback(() => { return ( <>

{title}

{price.value !== 0 && ( )} ) }, [price.formatter, price.listPrice, price.value, title]) return (
{!quickOrder?.enabled && renderProductItemContent()} {quickOrder?.enabled && ( {renderProductItemContent()} )}
) }) export default SearchProductItemContent